Merge remote-tracking branch 'origin/developer' into developer
This commit is contained in:
commit
ae4203ccf9
@ -7,8 +7,9 @@ const MessageSchema = mongoose.Schema({
|
||||
subject: { type: String, required: true },
|
||||
message: { type: String, required: true },
|
||||
user: { type: String, required: true },
|
||||
tag: [{type: String, index: true }],
|
||||
tag: [{type: String }],
|
||||
//createtime: { type: Date, default: Date.now },
|
||||
});
|
||||
MessageSchema.index({tag:'text'});
|
||||
|
||||
module.exports = mongoose.model('Message', MessageSchema);
|
||||
|
84
mong.js
Normal file
84
mong.js
Normal file
@ -0,0 +1,84 @@
|
||||
db = db.getSiblingDB('omdb')
|
||||
|
||||
print(db.getCollectionNames())
|
||||
db.messages.insert(
|
||||
[
|
||||
{
|
||||
"subject": "DOLORE LABORIS AUTE",
|
||||
"message": "Ex sunt elit elit in ex ad labore minim. Elit amet irure sit aliquip excepteur sit qui et aute qui mollit cillum.",
|
||||
"user": "Jaime Potter",
|
||||
"tag": [
|
||||
"sit",
|
||||
"in",
|
||||
"dolore",
|
||||
"ullamco"
|
||||
]
|
||||
},
|
||||
{
|
||||
"subject": "NON IPSUM MOLLIT",
|
||||
"message": "Ut laborum proident magna magna qui non in voluptate reprehenderit labore. Qui consectetur dolor nisi culpa cillum quis.",
|
||||
"user": "Goff Durham",
|
||||
"tag": [
|
||||
"aliqua",
|
||||
"sunt",
|
||||
"labore",
|
||||
"minim"
|
||||
]
|
||||
},
|
||||
{
|
||||
"subject": "ESSE IPSUM INCIDIDUNT",
|
||||
"message": "Esse enim amet laboris proident do do ut cupidatat laborum ex. Sit esse id laborum aliqua id.",
|
||||
"user": "Helena Mercado",
|
||||
"tag": [
|
||||
"fugiat",
|
||||
"nisi",
|
||||
"incididunt",
|
||||
"ullamco"
|
||||
]
|
||||
},
|
||||
{
|
||||
"subject": "PARIATUR DOLOR SUNT",
|
||||
"message": "Exercitation officia ad consequat est voluptate est incididunt ut culpa consectetur. Consectetur irure veniam ipsum sint sit anim minim aute exercitation ullamco nostrud reprehenderit consequat.",
|
||||
"user": "Christi Walker",
|
||||
"tag": [
|
||||
"consectetur",
|
||||
"sint",
|
||||
"qui",
|
||||
"ipsum"
|
||||
]
|
||||
},
|
||||
{
|
||||
"subject": "TEMPOR ID VOLUPTATE",
|
||||
"message": "Anim ex commodo officia consequat in magna esse sunt mollit sunt commodo. Ex sit aute reprehenderit elit magna sunt irure pariatur cupidatat labore.",
|
||||
"user": "Kent Schroeder",
|
||||
"tag": [
|
||||
"adipisicing",
|
||||
"nulla",
|
||||
"tempor",
|
||||
"veniam"
|
||||
]
|
||||
},
|
||||
{
|
||||
"subject": "LOREM EST AUTE",
|
||||
"message": "Irure excepteur laborum quis tempor officia cillum officia est ea adipisicing duis enim aliqua. Est dolor laborum officia elit ullamco.",
|
||||
"user": "Dominguez Stevens",
|
||||
"tag": [
|
||||
"mollit",
|
||||
"amet",
|
||||
"consectetur",
|
||||
"dolore"
|
||||
]
|
||||
},
|
||||
{
|
||||
"subject": "ESSE MOLLIT CILLUM",
|
||||
"message": "Eu culpa laborum consequat sunt aliqua excepteur. Voluptate pariatur deserunt consequat id nostrud do magna occaecat sint nulla non nostrud.",
|
||||
"user": "Terrell Padilla",
|
||||
"tag": [
|
||||
"Lorem",
|
||||
"consequat",
|
||||
"fugiat",
|
||||
"aliqua"
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
1
node_modules/.bin/bunyan
generated
vendored
Symbolic link
1
node_modules/.bin/bunyan
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../bunyan/bin/bunyan
|
1
node_modules/.bin/ldapjs-add
generated
vendored
Symbolic link
1
node_modules/.bin/ldapjs-add
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ldapjs/bin/ldapjs-add
|
1
node_modules/.bin/ldapjs-compare
generated
vendored
Symbolic link
1
node_modules/.bin/ldapjs-compare
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ldapjs/bin/ldapjs-compare
|
1
node_modules/.bin/ldapjs-delete
generated
vendored
Symbolic link
1
node_modules/.bin/ldapjs-delete
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ldapjs/bin/ldapjs-delete
|
1
node_modules/.bin/ldapjs-modify
generated
vendored
Symbolic link
1
node_modules/.bin/ldapjs-modify
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ldapjs/bin/ldapjs-modify
|
1
node_modules/.bin/ldapjs-search
generated
vendored
Symbolic link
1
node_modules/.bin/ldapjs-search
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ldapjs/bin/ldapjs-search
|
1
node_modules/.bin/ncp
generated
vendored
Symbolic link
1
node_modules/.bin/ncp
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ncp/bin/ncp
|
9
node_modules/ansi-escapes/index.js
generated
vendored
9
node_modules/ansi-escapes/index.js
generated
vendored
@ -78,6 +78,15 @@ x.scrollUp = ESC + 'S';
|
||||
x.scrollDown = ESC + 'T';
|
||||
|
||||
x.clearScreen = '\u001Bc';
|
||||
|
||||
x.clearTerminal = process.platform === 'win32' ?
|
||||
`${x.eraseScreen}${ESC}0f` :
|
||||
// 1. Erases the screen (Only done in case `2` is not supported)
|
||||
// 2. Erases the whole screen including scrollback buffer
|
||||
// 3. Moves cursor to the top-left position
|
||||
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
||||
`${x.eraseScreen}${ESC}3J${ESC}H`;
|
||||
|
||||
x.beep = BEL;
|
||||
|
||||
x.link = (text, url) => {
|
||||
|
22
node_modules/ansi-escapes/package.json
generated
vendored
22
node_modules/ansi-escapes/package.json
generated
vendored
@ -1,27 +1,27 @@
|
||||
{
|
||||
"_from": "ansi-escapes@^3.0.0",
|
||||
"_id": "ansi-escapes@3.1.0",
|
||||
"_from": "ansi-escapes@^3.2.0",
|
||||
"_id": "ansi-escapes@3.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==",
|
||||
"_integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==",
|
||||
"_location": "/ansi-escapes",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ansi-escapes@^3.0.0",
|
||||
"raw": "ansi-escapes@^3.2.0",
|
||||
"name": "ansi-escapes",
|
||||
"escapedName": "ansi-escapes",
|
||||
"rawSpec": "^3.0.0",
|
||||
"rawSpec": "^3.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.0.0"
|
||||
"fetchSpec": "^3.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/inquirer"
|
||||
],
|
||||
"_resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz",
|
||||
"_shasum": "f73207bb81207d75fd6c83f125af26eea378ca30",
|
||||
"_spec": "ansi-escapes@^3.0.0",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/BME_Project_Ohm/om/node_modules/inquirer",
|
||||
"_resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz",
|
||||
"_shasum": "8780b98ff9dbf5638152d1f1fe5c1d7b4442976b",
|
||||
"_spec": "ansi-escapes@^3.2.0",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/a1_BME_Project_Ohm/om/node_modules/inquirer",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
@ -78,5 +78,5 @@
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "3.1.0"
|
||||
"version": "3.2.0"
|
||||
}
|
||||
|
6
node_modules/ansi-escapes/readme.md
generated
vendored
6
node_modules/ansi-escapes/readme.md
generated
vendored
@ -117,7 +117,11 @@ Scroll display down one line.
|
||||
|
||||
### clearScreen
|
||||
|
||||
Clear the terminal screen.
|
||||
Clear the terminal screen. (Viewport)
|
||||
|
||||
### clearTerminal
|
||||
|
||||
Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
|
||||
|
||||
### beep
|
||||
|
||||
|
2
node_modules/asn1/.npmignore
generated
vendored
Normal file
2
node_modules/asn1/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
*.log
|
4
node_modules/asn1/.travis.yml
generated
vendored
Normal file
4
node_modules/asn1/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
- 0.10
|
19
node_modules/asn1/LICENSE
generated
vendored
Normal file
19
node_modules/asn1/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2011 Mark Cavage, All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE
|
50
node_modules/asn1/README.md
generated
vendored
Normal file
50
node_modules/asn1/README.md
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS.
|
||||
Currently BER encoding is supported; at some point I'll likely have to do DER.
|
||||
|
||||
## Usage
|
||||
|
||||
Mostly, if you're *actually* needing to read and write ASN.1, you probably don't
|
||||
need this readme to explain what and why. If you have no idea what ASN.1 is,
|
||||
see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
|
||||
|
||||
The source is pretty much self-explanatory, and has read/write methods for the
|
||||
common types out there.
|
||||
|
||||
### Decoding
|
||||
|
||||
The following reads an ASN.1 sequence with a boolean.
|
||||
|
||||
var Ber = require('asn1').Ber;
|
||||
|
||||
var reader = new Ber.Reader(new Buffer([0x30, 0x03, 0x01, 0x01, 0xff]));
|
||||
|
||||
reader.readSequence();
|
||||
console.log('Sequence len: ' + reader.length);
|
||||
if (reader.peek() === Ber.Boolean)
|
||||
console.log(reader.readBoolean());
|
||||
|
||||
### Encoding
|
||||
|
||||
The following generates the same payload as above.
|
||||
|
||||
var Ber = require('asn1').Ber;
|
||||
|
||||
var writer = new Ber.Writer();
|
||||
|
||||
writer.startSequence();
|
||||
writer.writeBoolean(true);
|
||||
writer.endSequence();
|
||||
|
||||
console.log(writer.buffer);
|
||||
|
||||
## Installation
|
||||
|
||||
npm install asn1
|
||||
|
||||
## License
|
||||
|
||||
MIT.
|
||||
|
||||
## Bugs
|
||||
|
||||
See <https://github.com/mcavage/node-asn1/issues>.
|
13
node_modules/asn1/lib/ber/errors.js
generated
vendored
Normal file
13
node_modules/asn1/lib/ber/errors.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
newInvalidAsn1Error: function(msg) {
|
||||
var e = new Error();
|
||||
e.name = 'InvalidAsn1Error';
|
||||
e.message = msg || '';
|
||||
return e;
|
||||
}
|
||||
|
||||
};
|
27
node_modules/asn1/lib/ber/index.js
generated
vendored
Normal file
27
node_modules/asn1/lib/ber/index.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var errors = require('./errors');
|
||||
var types = require('./types');
|
||||
|
||||
var Reader = require('./reader');
|
||||
var Writer = require('./writer');
|
||||
|
||||
|
||||
///--- Exports
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reader: Reader,
|
||||
|
||||
Writer: Writer
|
||||
|
||||
};
|
||||
|
||||
for (var t in types) {
|
||||
if (types.hasOwnProperty(t))
|
||||
module.exports[t] = types[t];
|
||||
}
|
||||
for (var e in errors) {
|
||||
if (errors.hasOwnProperty(e))
|
||||
module.exports[e] = errors[e];
|
||||
}
|
261
node_modules/asn1/lib/ber/reader.js
generated
vendored
Normal file
261
node_modules/asn1/lib/ber/reader.js
generated
vendored
Normal file
@ -0,0 +1,261 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var ASN1 = require('./types');
|
||||
var errors = require('./errors');
|
||||
|
||||
|
||||
///--- Globals
|
||||
|
||||
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
|
||||
|
||||
|
||||
|
||||
///--- API
|
||||
|
||||
function Reader(data) {
|
||||
if (!data || !Buffer.isBuffer(data))
|
||||
throw new TypeError('data must be a node Buffer');
|
||||
|
||||
this._buf = data;
|
||||
this._size = data.length;
|
||||
|
||||
// These hold the "current" state
|
||||
this._len = 0;
|
||||
this._offset = 0;
|
||||
}
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'length', {
|
||||
enumerable: true,
|
||||
get: function () { return (this._len); }
|
||||
});
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'offset', {
|
||||
enumerable: true,
|
||||
get: function () { return (this._offset); }
|
||||
});
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'remain', {
|
||||
get: function () { return (this._size - this._offset); }
|
||||
});
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'buffer', {
|
||||
get: function () { return (this._buf.slice(this._offset)); }
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Reads a single byte and advances offset; you can pass in `true` to make this
|
||||
* a "peek" operation (i.e., get the byte, but don't advance the offset).
|
||||
*
|
||||
* @param {Boolean} peek true means don't move offset.
|
||||
* @return {Number} the next byte, null if not enough data.
|
||||
*/
|
||||
Reader.prototype.readByte = function(peek) {
|
||||
if (this._size - this._offset < 1)
|
||||
return null;
|
||||
|
||||
var b = this._buf[this._offset] & 0xff;
|
||||
|
||||
if (!peek)
|
||||
this._offset += 1;
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.peek = function() {
|
||||
return this.readByte(true);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Reads a (potentially) variable length off the BER buffer. This call is
|
||||
* not really meant to be called directly, as callers have to manipulate
|
||||
* the internal buffer afterwards.
|
||||
*
|
||||
* As a result of this call, you can call `Reader.length`, until the
|
||||
* next thing called that does a readLength.
|
||||
*
|
||||
* @return {Number} the amount of offset to advance the buffer.
|
||||
* @throws {InvalidAsn1Error} on bad ASN.1
|
||||
*/
|
||||
Reader.prototype.readLength = function(offset) {
|
||||
if (offset === undefined)
|
||||
offset = this._offset;
|
||||
|
||||
if (offset >= this._size)
|
||||
return null;
|
||||
|
||||
var lenB = this._buf[offset++] & 0xff;
|
||||
if (lenB === null)
|
||||
return null;
|
||||
|
||||
if ((lenB & 0x80) == 0x80) {
|
||||
lenB &= 0x7f;
|
||||
|
||||
if (lenB == 0)
|
||||
throw newInvalidAsn1Error('Indefinite length not supported');
|
||||
|
||||
if (lenB > 4)
|
||||
throw newInvalidAsn1Error('encoding too long');
|
||||
|
||||
if (this._size - offset < lenB)
|
||||
return null;
|
||||
|
||||
this._len = 0;
|
||||
for (var i = 0; i < lenB; i++)
|
||||
this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
|
||||
|
||||
} else {
|
||||
// Wasn't a variable length
|
||||
this._len = lenB;
|
||||
}
|
||||
|
||||
return offset;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parses the next sequence in this BER buffer.
|
||||
*
|
||||
* To get the length of the sequence, call `Reader.length`.
|
||||
*
|
||||
* @return {Number} the sequence's tag.
|
||||
*/
|
||||
Reader.prototype.readSequence = function(tag) {
|
||||
var seq = this.peek();
|
||||
if (seq === null)
|
||||
return null;
|
||||
if (tag !== undefined && tag !== seq)
|
||||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
||||
': got 0x' + seq.toString(16));
|
||||
|
||||
var o = this.readLength(this._offset + 1); // stored in `length`
|
||||
if (o === null)
|
||||
return null;
|
||||
|
||||
this._offset = o;
|
||||
return seq;
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readInt = function() {
|
||||
return this._readTag(ASN1.Integer);
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readBoolean = function() {
|
||||
return (this._readTag(ASN1.Boolean) === 0 ? false : true);
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readEnumeration = function() {
|
||||
return this._readTag(ASN1.Enumeration);
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readString = function(tag, retbuf) {
|
||||
if (!tag)
|
||||
tag = ASN1.OctetString;
|
||||
|
||||
var b = this.peek();
|
||||
if (b === null)
|
||||
return null;
|
||||
|
||||
if (b !== tag)
|
||||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
||||
': got 0x' + b.toString(16));
|
||||
|
||||
var o = this.readLength(this._offset + 1); // stored in `length`
|
||||
|
||||
if (o === null)
|
||||
return null;
|
||||
|
||||
if (this.length > this._size - o)
|
||||
return null;
|
||||
|
||||
this._offset = o;
|
||||
|
||||
if (this.length === 0)
|
||||
return retbuf ? new Buffer(0) : '';
|
||||
|
||||
var str = this._buf.slice(this._offset, this._offset + this.length);
|
||||
this._offset += this.length;
|
||||
|
||||
return retbuf ? str : str.toString('utf8');
|
||||
};
|
||||
|
||||
Reader.prototype.readOID = function(tag) {
|
||||
if (!tag)
|
||||
tag = ASN1.OID;
|
||||
|
||||
var b = this.readString(tag, true);
|
||||
if (b === null)
|
||||
return null;
|
||||
|
||||
var values = [];
|
||||
var value = 0;
|
||||
|
||||
for (var i = 0; i < b.length; i++) {
|
||||
var byte = b[i] & 0xff;
|
||||
|
||||
value <<= 7;
|
||||
value += byte & 0x7f;
|
||||
if ((byte & 0x80) == 0) {
|
||||
values.push(value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
value = values.shift();
|
||||
values.unshift(value % 40);
|
||||
values.unshift((value / 40) >> 0);
|
||||
|
||||
return values.join('.');
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype._readTag = function(tag) {
|
||||
assert.ok(tag !== undefined);
|
||||
|
||||
var b = this.peek();
|
||||
|
||||
if (b === null)
|
||||
return null;
|
||||
|
||||
if (b !== tag)
|
||||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
||||
': got 0x' + b.toString(16));
|
||||
|
||||
var o = this.readLength(this._offset + 1); // stored in `length`
|
||||
if (o === null)
|
||||
return null;
|
||||
|
||||
if (this.length > 4)
|
||||
throw newInvalidAsn1Error('Integer too long: ' + this.length);
|
||||
|
||||
if (this.length > this._size - o)
|
||||
return null;
|
||||
this._offset = o;
|
||||
|
||||
var fb = this._buf[this._offset];
|
||||
var value = 0;
|
||||
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
value <<= 8;
|
||||
value |= (this._buf[this._offset++] & 0xff);
|
||||
}
|
||||
|
||||
if ((fb & 0x80) == 0x80 && i !== 4)
|
||||
value -= (1 << (i * 8));
|
||||
|
||||
return value >> 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
///--- Exported API
|
||||
|
||||
module.exports = Reader;
|
36
node_modules/asn1/lib/ber/types.js
generated
vendored
Normal file
36
node_modules/asn1/lib/ber/types.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
|
||||
module.exports = {
|
||||
EOC: 0,
|
||||
Boolean: 1,
|
||||
Integer: 2,
|
||||
BitString: 3,
|
||||
OctetString: 4,
|
||||
Null: 5,
|
||||
OID: 6,
|
||||
ObjectDescriptor: 7,
|
||||
External: 8,
|
||||
Real: 9, // float
|
||||
Enumeration: 10,
|
||||
PDV: 11,
|
||||
Utf8String: 12,
|
||||
RelativeOID: 13,
|
||||
Sequence: 16,
|
||||
Set: 17,
|
||||
NumericString: 18,
|
||||
PrintableString: 19,
|
||||
T61String: 20,
|
||||
VideotexString: 21,
|
||||
IA5String: 22,
|
||||
UTCTime: 23,
|
||||
GeneralizedTime: 24,
|
||||
GraphicString: 25,
|
||||
VisibleString: 26,
|
||||
GeneralString: 28,
|
||||
UniversalString: 29,
|
||||
CharacterString: 30,
|
||||
BMPString: 31,
|
||||
Constructor: 32,
|
||||
Context: 128
|
||||
};
|
316
node_modules/asn1/lib/ber/writer.js
generated
vendored
Normal file
316
node_modules/asn1/lib/ber/writer.js
generated
vendored
Normal file
@ -0,0 +1,316 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var assert = require('assert');
|
||||
var ASN1 = require('./types');
|
||||
var errors = require('./errors');
|
||||
|
||||
|
||||
///--- Globals
|
||||
|
||||
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
|
||||
|
||||
var DEFAULT_OPTS = {
|
||||
size: 1024,
|
||||
growthFactor: 8
|
||||
};
|
||||
|
||||
|
||||
///--- Helpers
|
||||
|
||||
function merge(from, to) {
|
||||
assert.ok(from);
|
||||
assert.equal(typeof(from), 'object');
|
||||
assert.ok(to);
|
||||
assert.equal(typeof(to), 'object');
|
||||
|
||||
var keys = Object.getOwnPropertyNames(from);
|
||||
keys.forEach(function(key) {
|
||||
if (to[key])
|
||||
return;
|
||||
|
||||
var value = Object.getOwnPropertyDescriptor(from, key);
|
||||
Object.defineProperty(to, key, value);
|
||||
});
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///--- API
|
||||
|
||||
function Writer(options) {
|
||||
options = merge(DEFAULT_OPTS, options || {});
|
||||
|
||||
this._buf = new Buffer(options.size || 1024);
|
||||
this._size = this._buf.length;
|
||||
this._offset = 0;
|
||||
this._options = options;
|
||||
|
||||
// A list of offsets in the buffer where we need to insert
|
||||
// sequence tag/len pairs.
|
||||
this._seq = [];
|
||||
}
|
||||
|
||||
Object.defineProperty(Writer.prototype, 'buffer', {
|
||||
get: function () {
|
||||
if (this._seq.length)
|
||||
throw new InvalidAsn1Error(this._seq.length + ' unended sequence(s)');
|
||||
|
||||
return (this._buf.slice(0, this._offset));
|
||||
}
|
||||
});
|
||||
|
||||
Writer.prototype.writeByte = function(b) {
|
||||
if (typeof(b) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
|
||||
this._ensure(1);
|
||||
this._buf[this._offset++] = b;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeInt = function(i, tag) {
|
||||
if (typeof(i) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
if (typeof(tag) !== 'number')
|
||||
tag = ASN1.Integer;
|
||||
|
||||
var sz = 4;
|
||||
|
||||
while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&
|
||||
(sz > 1)) {
|
||||
sz--;
|
||||
i <<= 8;
|
||||
}
|
||||
|
||||
if (sz > 4)
|
||||
throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff');
|
||||
|
||||
this._ensure(2 + sz);
|
||||
this._buf[this._offset++] = tag;
|
||||
this._buf[this._offset++] = sz;
|
||||
|
||||
while (sz-- > 0) {
|
||||
this._buf[this._offset++] = ((i & 0xff000000) >>> 24);
|
||||
i <<= 8;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeNull = function() {
|
||||
this.writeByte(ASN1.Null);
|
||||
this.writeByte(0x00);
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeEnumeration = function(i, tag) {
|
||||
if (typeof(i) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
if (typeof(tag) !== 'number')
|
||||
tag = ASN1.Enumeration;
|
||||
|
||||
return this.writeInt(i, tag);
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeBoolean = function(b, tag) {
|
||||
if (typeof(b) !== 'boolean')
|
||||
throw new TypeError('argument must be a Boolean');
|
||||
if (typeof(tag) !== 'number')
|
||||
tag = ASN1.Boolean;
|
||||
|
||||
this._ensure(3);
|
||||
this._buf[this._offset++] = tag;
|
||||
this._buf[this._offset++] = 0x01;
|
||||
this._buf[this._offset++] = b ? 0xff : 0x00;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeString = function(s, tag) {
|
||||
if (typeof(s) !== 'string')
|
||||
throw new TypeError('argument must be a string (was: ' + typeof(s) + ')');
|
||||
if (typeof(tag) !== 'number')
|
||||
tag = ASN1.OctetString;
|
||||
|
||||
var len = Buffer.byteLength(s);
|
||||
this.writeByte(tag);
|
||||
this.writeLength(len);
|
||||
if (len) {
|
||||
this._ensure(len);
|
||||
this._buf.write(s, this._offset);
|
||||
this._offset += len;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeBuffer = function(buf, tag) {
|
||||
if (typeof(tag) !== 'number')
|
||||
throw new TypeError('tag must be a number');
|
||||
if (!Buffer.isBuffer(buf))
|
||||
throw new TypeError('argument must be a buffer');
|
||||
|
||||
this.writeByte(tag);
|
||||
this.writeLength(buf.length);
|
||||
this._ensure(buf.length);
|
||||
buf.copy(this._buf, this._offset, 0, buf.length);
|
||||
this._offset += buf.length;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeStringArray = function(strings) {
|
||||
if ((!strings instanceof Array))
|
||||
throw new TypeError('argument must be an Array[String]');
|
||||
|
||||
var self = this;
|
||||
strings.forEach(function(s) {
|
||||
self.writeString(s);
|
||||
});
|
||||
};
|
||||
|
||||
// This is really to solve DER cases, but whatever for now
|
||||
Writer.prototype.writeOID = function(s, tag) {
|
||||
if (typeof(s) !== 'string')
|
||||
throw new TypeError('argument must be a string');
|
||||
if (typeof(tag) !== 'number')
|
||||
tag = ASN1.OID;
|
||||
|
||||
if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
|
||||
throw new Error('argument is not a valid OID string');
|
||||
|
||||
function encodeOctet(bytes, octet) {
|
||||
if (octet < 128) {
|
||||
bytes.push(octet);
|
||||
} else if (octet < 16384) {
|
||||
bytes.push((octet >>> 7) | 0x80);
|
||||
bytes.push(octet & 0x7F);
|
||||
} else if (octet < 2097152) {
|
||||
bytes.push((octet >>> 14) | 0x80);
|
||||
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
||||
bytes.push(octet & 0x7F);
|
||||
} else if (octet < 268435456) {
|
||||
bytes.push((octet >>> 21) | 0x80);
|
||||
bytes.push(((octet >>> 14) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
||||
bytes.push(octet & 0x7F);
|
||||
} else {
|
||||
bytes.push(((octet >>> 28) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 21) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 14) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
||||
bytes.push(octet & 0x7F);
|
||||
}
|
||||
}
|
||||
|
||||
var tmp = s.split('.');
|
||||
var bytes = [];
|
||||
bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
|
||||
tmp.slice(2).forEach(function(b) {
|
||||
encodeOctet(bytes, parseInt(b, 10));
|
||||
});
|
||||
|
||||
var self = this;
|
||||
this._ensure(2 + bytes.length);
|
||||
this.writeByte(tag);
|
||||
this.writeLength(bytes.length);
|
||||
bytes.forEach(function(b) {
|
||||
self.writeByte(b);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeLength = function(len) {
|
||||
if (typeof(len) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
|
||||
this._ensure(4);
|
||||
|
||||
if (len <= 0x7f) {
|
||||
this._buf[this._offset++] = len;
|
||||
} else if (len <= 0xff) {
|
||||
this._buf[this._offset++] = 0x81;
|
||||
this._buf[this._offset++] = len;
|
||||
} else if (len <= 0xffff) {
|
||||
this._buf[this._offset++] = 0x82;
|
||||
this._buf[this._offset++] = len >> 8;
|
||||
this._buf[this._offset++] = len;
|
||||
} else if (len <= 0xffffff) {
|
||||
this._buf[this._offset++] = 0x83;
|
||||
this._buf[this._offset++] = len >> 16;
|
||||
this._buf[this._offset++] = len >> 8;
|
||||
this._buf[this._offset++] = len;
|
||||
} else {
|
||||
throw new InvalidAsn1ERror('Length too long (> 4 bytes)');
|
||||
}
|
||||
};
|
||||
|
||||
Writer.prototype.startSequence = function(tag) {
|
||||
if (typeof(tag) !== 'number')
|
||||
tag = ASN1.Sequence | ASN1.Constructor;
|
||||
|
||||
this.writeByte(tag);
|
||||
this._seq.push(this._offset);
|
||||
this._ensure(3);
|
||||
this._offset += 3;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.endSequence = function() {
|
||||
var seq = this._seq.pop();
|
||||
var start = seq + 3;
|
||||
var len = this._offset - start;
|
||||
|
||||
if (len <= 0x7f) {
|
||||
this._shift(start, len, -2);
|
||||
this._buf[seq] = len;
|
||||
} else if (len <= 0xff) {
|
||||
this._shift(start, len, -1);
|
||||
this._buf[seq] = 0x81;
|
||||
this._buf[seq + 1] = len;
|
||||
} else if (len <= 0xffff) {
|
||||
this._buf[seq] = 0x82;
|
||||
this._buf[seq + 1] = len >> 8;
|
||||
this._buf[seq + 2] = len;
|
||||
} else if (len <= 0xffffff) {
|
||||
this._shift(start, len, 1);
|
||||
this._buf[seq] = 0x83;
|
||||
this._buf[seq + 1] = len >> 16;
|
||||
this._buf[seq + 2] = len >> 8;
|
||||
this._buf[seq + 3] = len;
|
||||
} else {
|
||||
throw new InvalidAsn1Error('Sequence too long');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype._shift = function(start, len, shift) {
|
||||
assert.ok(start !== undefined);
|
||||
assert.ok(len !== undefined);
|
||||
assert.ok(shift);
|
||||
|
||||
this._buf.copy(this._buf, start + shift, start, start + len);
|
||||
this._offset += shift;
|
||||
};
|
||||
|
||||
Writer.prototype._ensure = function(len) {
|
||||
assert.ok(len);
|
||||
|
||||
if (this._size - this._offset < len) {
|
||||
var sz = this._size * this._options.growthFactor;
|
||||
if (sz - this._offset < len)
|
||||
sz += len;
|
||||
|
||||
var buf = new Buffer(sz);
|
||||
|
||||
this._buf.copy(buf, 0, 0, this._offset);
|
||||
this._buf = buf;
|
||||
this._size = sz;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///--- Exported API
|
||||
|
||||
module.exports = Writer;
|
20
node_modules/asn1/lib/index.js
generated
vendored
Normal file
20
node_modules/asn1/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
// If you have no idea what ASN.1 or BER is, see this:
|
||||
// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
|
||||
|
||||
var Ber = require('./ber/index');
|
||||
|
||||
|
||||
|
||||
///--- Exported API
|
||||
|
||||
module.exports = {
|
||||
|
||||
Ber: Ber,
|
||||
|
||||
BerReader: Ber.Reader,
|
||||
|
||||
BerWriter: Ber.Writer
|
||||
|
||||
};
|
65
node_modules/asn1/package.json
generated
vendored
Normal file
65
node_modules/asn1/package.json
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"_from": "asn1@0.2.3",
|
||||
"_id": "asn1@0.2.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=",
|
||||
"_location": "/asn1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "asn1@0.2.3",
|
||||
"name": "asn1",
|
||||
"escapedName": "asn1",
|
||||
"rawSpec": "0.2.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.2.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/ldapjs"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
|
||||
"_shasum": "dac8787713c9966849fc8180777ebe9c1ddf3b86",
|
||||
"_spec": "asn1@0.2.3",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/a1_BME_Project_Ohm/om/node_modules/ldapjs",
|
||||
"author": {
|
||||
"name": "Mark Cavage",
|
||||
"email": "mcavage@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mcavage/node-asn1/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "David Gwynne",
|
||||
"email": "loki@animata.net"
|
||||
},
|
||||
{
|
||||
"name": "Yunong Xiao",
|
||||
"email": "yunong@joyent.com"
|
||||
},
|
||||
{
|
||||
"name": "Alex Wilson",
|
||||
"email": "alex.wilson@joyent.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Contains parsers and serializers for ASN.1 (currently BER only)",
|
||||
"devDependencies": {
|
||||
"tap": "0.4.8"
|
||||
},
|
||||
"homepage": "https://github.com/mcavage/node-asn1#readme",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "asn1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mcavage/node-asn1.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap ./tst"
|
||||
},
|
||||
"version": "0.2.3"
|
||||
}
|
208
node_modules/asn1/tst/ber/reader.test.js
generated
vendored
Normal file
208
node_modules/asn1/tst/ber/reader.test.js
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var test = require('tap').test;
|
||||
|
||||
|
||||
|
||||
///--- Globals
|
||||
|
||||
var BerReader;
|
||||
|
||||
|
||||
|
||||
///--- Tests
|
||||
|
||||
test('load library', function(t) {
|
||||
BerReader = require('../../lib/index').BerReader;
|
||||
t.ok(BerReader);
|
||||
try {
|
||||
new BerReader();
|
||||
t.fail('Should have thrown');
|
||||
} catch (e) {
|
||||
t.ok(e instanceof TypeError, 'Should have been a type error');
|
||||
}
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read byte', function(t) {
|
||||
var reader = new BerReader(new Buffer([0xde]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readByte(), 0xde, 'wrong value');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 1 byte int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x01, 0x03]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), 0x03, 'wrong value');
|
||||
t.equal(reader.length, 0x01, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 2 byte int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x02, 0x7e, 0xde]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), 0x7ede, 'wrong value');
|
||||
t.equal(reader.length, 0x02, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 3 byte int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x03, 0x7e, 0xde, 0x03]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), 0x7ede03, 'wrong value');
|
||||
t.equal(reader.length, 0x03, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 4 byte int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x04, 0x7e, 0xde, 0x03, 0x01]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), 0x7ede0301, 'wrong value');
|
||||
t.equal(reader.length, 0x04, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 1 byte negative int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x01, 0xdc]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), -36, 'wrong value');
|
||||
t.equal(reader.length, 0x01, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 2 byte negative int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x02, 0xc0, 0x4e]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), -16306, 'wrong value');
|
||||
t.equal(reader.length, 0x02, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 3 byte negative int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x03, 0xff, 0x00, 0x19]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), -65511, 'wrong value');
|
||||
t.equal(reader.length, 0x03, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read 4 byte negative int', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x02, 0x04, 0x91, 0x7c, 0x22, 0x1f]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readInt(), -1854135777, 'wrong value');
|
||||
t.equal(reader.length, 0x04, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read boolean true', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x01, 0x01, 0xff]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readBoolean(), true, 'wrong value');
|
||||
t.equal(reader.length, 0x01, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read boolean false', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x01, 0x01, 0x00]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readBoolean(), false, 'wrong value');
|
||||
t.equal(reader.length, 0x01, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read enumeration', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x0a, 0x01, 0x20]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readEnumeration(), 0x20, 'wrong value');
|
||||
t.equal(reader.length, 0x01, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read string', function(t) {
|
||||
var dn = 'cn=foo,ou=unit,o=test';
|
||||
var buf = new Buffer(dn.length + 2);
|
||||
buf[0] = 0x04;
|
||||
buf[1] = Buffer.byteLength(dn);
|
||||
buf.write(dn, 2);
|
||||
var reader = new BerReader(buf);
|
||||
t.ok(reader);
|
||||
t.equal(reader.readString(), dn, 'wrong value');
|
||||
t.equal(reader.length, dn.length, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('read sequence', function(t) {
|
||||
var reader = new BerReader(new Buffer([0x30, 0x03, 0x01, 0x01, 0xff]));
|
||||
t.ok(reader);
|
||||
t.equal(reader.readSequence(), 0x30, 'wrong value');
|
||||
t.equal(reader.length, 0x03, 'wrong length');
|
||||
t.equal(reader.readBoolean(), true, 'wrong value');
|
||||
t.equal(reader.length, 0x01, 'wrong length');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('anonymous LDAPv3 bind', function(t) {
|
||||
var BIND = new Buffer(14);
|
||||
BIND[0] = 0x30; // Sequence
|
||||
BIND[1] = 12; // len
|
||||
BIND[2] = 0x02; // ASN.1 Integer
|
||||
BIND[3] = 1; // len
|
||||
BIND[4] = 0x04; // msgid (make up 4)
|
||||
BIND[5] = 0x60; // Bind Request
|
||||
BIND[6] = 7; // len
|
||||
BIND[7] = 0x02; // ASN.1 Integer
|
||||
BIND[8] = 1; // len
|
||||
BIND[9] = 0x03; // v3
|
||||
BIND[10] = 0x04; // String (bind dn)
|
||||
BIND[11] = 0; // len
|
||||
BIND[12] = 0x80; // ContextSpecific (choice)
|
||||
BIND[13] = 0; // simple bind
|
||||
|
||||
// Start testing ^^
|
||||
var ber = new BerReader(BIND);
|
||||
t.equal(ber.readSequence(), 48, 'Not an ASN.1 Sequence');
|
||||
t.equal(ber.length, 12, 'Message length should be 12');
|
||||
t.equal(ber.readInt(), 4, 'Message id should have been 4');
|
||||
t.equal(ber.readSequence(), 96, 'Bind Request should have been 96');
|
||||
t.equal(ber.length, 7, 'Bind length should have been 7');
|
||||
t.equal(ber.readInt(), 3, 'LDAP version should have been 3');
|
||||
t.equal(ber.readString(), '', 'Bind DN should have been empty');
|
||||
t.equal(ber.length, 0, 'string length should have been 0');
|
||||
t.equal(ber.readByte(), 0x80, 'Should have been ContextSpecific (choice)');
|
||||
t.equal(ber.readByte(), 0, 'Should have been simple bind');
|
||||
t.equal(null, ber.readByte(), 'Should be out of data');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('long string', function(t) {
|
||||
var buf = new Buffer(256);
|
||||
var o;
|
||||
var s =
|
||||
'2;649;CN=Red Hat CS 71GA Demo,O=Red Hat CS 71GA Demo,C=US;' +
|
||||
'CN=RHCS Agent - admin01,UID=admin01,O=redhat,C=US [1] This is ' +
|
||||
'Teena Vradmin\'s description.';
|
||||
buf[0] = 0x04;
|
||||
buf[1] = 0x81;
|
||||
buf[2] = 0x94;
|
||||
buf.write(s, 3);
|
||||
var ber = new BerReader(buf.slice(0, 3 + s.length));
|
||||
t.equal(ber.readString(), s);
|
||||
t.end();
|
||||
});
|
370
node_modules/asn1/tst/ber/writer.test.js
generated
vendored
Normal file
370
node_modules/asn1/tst/ber/writer.test.js
generated
vendored
Normal file
@ -0,0 +1,370 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var test = require('tap').test;
|
||||
var sys = require('sys');
|
||||
|
||||
///--- Globals
|
||||
|
||||
var BerWriter;
|
||||
|
||||
var BerReader;
|
||||
|
||||
|
||||
///--- Tests
|
||||
|
||||
test('load library', function(t) {
|
||||
BerWriter = require('../../lib/index').BerWriter;
|
||||
t.ok(BerWriter);
|
||||
t.ok(new BerWriter());
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write byte', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeByte(0xC2);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 1, 'Wrong length');
|
||||
t.equal(ber[0], 0xC2, 'value wrong');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 1 byte int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(0x7f);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 3, 'Wrong length for an int: ' + ber.length);
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong (2) -> ' + ber[0]);
|
||||
t.equal(ber[1], 0x01, 'length wrong(1) -> ' + ber[1]);
|
||||
t.equal(ber[2], 0x7f, 'value wrong(3) -> ' + ber[2]);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 2 byte int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(0x7ffe);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 4, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x02, 'length wrong');
|
||||
t.equal(ber[2], 0x7f, 'value wrong (byte 1)');
|
||||
t.equal(ber[3], 0xfe, 'value wrong (byte 2)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 3 byte int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(0x7ffffe);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 5, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x03, 'length wrong');
|
||||
t.equal(ber[2], 0x7f, 'value wrong (byte 1)');
|
||||
t.equal(ber[3], 0xff, 'value wrong (byte 2)');
|
||||
t.equal(ber[4], 0xfe, 'value wrong (byte 3)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 4 byte int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(0x7ffffffe);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
|
||||
t.equal(ber.length, 6, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x04, 'length wrong');
|
||||
t.equal(ber[2], 0x7f, 'value wrong (byte 1)');
|
||||
t.equal(ber[3], 0xff, 'value wrong (byte 2)');
|
||||
t.equal(ber[4], 0xff, 'value wrong (byte 3)');
|
||||
t.equal(ber[5], 0xfe, 'value wrong (byte 4)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 1 byte negative int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(-128);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
|
||||
t.equal(ber.length, 3, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x01, 'length wrong');
|
||||
t.equal(ber[2], 0x80, 'value wrong (byte 1)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 2 byte negative int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(-22400);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
|
||||
t.equal(ber.length, 4, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x02, 'length wrong');
|
||||
t.equal(ber[2], 0xa8, 'value wrong (byte 1)');
|
||||
t.equal(ber[3], 0x80, 'value wrong (byte 2)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 3 byte negative int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(-481653);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
|
||||
t.equal(ber.length, 5, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x03, 'length wrong');
|
||||
t.equal(ber[2], 0xf8, 'value wrong (byte 1)');
|
||||
t.equal(ber[3], 0xa6, 'value wrong (byte 2)');
|
||||
t.equal(ber[4], 0x8b, 'value wrong (byte 3)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write 4 byte negative int', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeInt(-1522904131);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
|
||||
t.equal(ber.length, 6, 'Wrong length for an int');
|
||||
t.equal(ber[0], 0x02, 'ASN.1 tag wrong');
|
||||
t.equal(ber[1], 0x04, 'length wrong');
|
||||
t.equal(ber[2], 0xa5, 'value wrong (byte 1)');
|
||||
t.equal(ber[3], 0x3a, 'value wrong (byte 2)');
|
||||
t.equal(ber[4], 0x53, 'value wrong (byte 3)');
|
||||
t.equal(ber[5], 0xbd, 'value wrong (byte 4)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write boolean', function(t) {
|
||||
var writer = new BerWriter();
|
||||
|
||||
writer.writeBoolean(true);
|
||||
writer.writeBoolean(false);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 6, 'Wrong length');
|
||||
t.equal(ber[0], 0x01, 'tag wrong');
|
||||
t.equal(ber[1], 0x01, 'length wrong');
|
||||
t.equal(ber[2], 0xff, 'value wrong');
|
||||
t.equal(ber[3], 0x01, 'tag wrong');
|
||||
t.equal(ber[4], 0x01, 'length wrong');
|
||||
t.equal(ber[5], 0x00, 'value wrong');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('write string', function(t) {
|
||||
var writer = new BerWriter();
|
||||
writer.writeString('hello world');
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 13, 'wrong length');
|
||||
t.equal(ber[0], 0x04, 'wrong tag');
|
||||
t.equal(ber[1], 11, 'wrong length');
|
||||
t.equal(ber.slice(2).toString('utf8'), 'hello world', 'wrong value');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('write buffer', function(t) {
|
||||
var writer = new BerWriter();
|
||||
// write some stuff to start with
|
||||
writer.writeString('hello world');
|
||||
var ber = writer.buffer;
|
||||
var buf = new Buffer([0x04, 0x0b, 0x30, 0x09, 0x02, 0x01, 0x0f, 0x01, 0x01,
|
||||
0xff, 0x01, 0x01, 0xff]);
|
||||
writer.writeBuffer(buf.slice(2, buf.length), 0x04);
|
||||
ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 26, 'wrong length');
|
||||
t.equal(ber[0], 0x04, 'wrong tag');
|
||||
t.equal(ber[1], 11, 'wrong length');
|
||||
t.equal(ber.slice(2, 13).toString('utf8'), 'hello world', 'wrong value');
|
||||
t.equal(ber[13], buf[0], 'wrong tag');
|
||||
t.equal(ber[14], buf[1], 'wrong length');
|
||||
for (var i = 13, j = 0; i < ber.length && j < buf.length; i++, j++) {
|
||||
t.equal(ber[i], buf[j], 'buffer contents not identical');
|
||||
}
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('write string array', function(t) {
|
||||
var writer = new BerWriter();
|
||||
writer.writeStringArray(['hello world', 'fubar!']);
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
|
||||
t.equal(ber.length, 21, 'wrong length');
|
||||
t.equal(ber[0], 0x04, 'wrong tag');
|
||||
t.equal(ber[1], 11, 'wrong length');
|
||||
t.equal(ber.slice(2, 13).toString('utf8'), 'hello world', 'wrong value');
|
||||
|
||||
t.equal(ber[13], 0x04, 'wrong tag');
|
||||
t.equal(ber[14], 6, 'wrong length');
|
||||
t.equal(ber.slice(15).toString('utf8'), 'fubar!', 'wrong value');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('resize internal buffer', function(t) {
|
||||
var writer = new BerWriter({size: 2});
|
||||
writer.writeString('hello world');
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 13, 'wrong length');
|
||||
t.equal(ber[0], 0x04, 'wrong tag');
|
||||
t.equal(ber[1], 11, 'wrong length');
|
||||
t.equal(ber.slice(2).toString('utf8'), 'hello world', 'wrong value');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('sequence', function(t) {
|
||||
var writer = new BerWriter({size: 25});
|
||||
writer.startSequence();
|
||||
writer.writeString('hello world');
|
||||
writer.endSequence();
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
console.log(ber);
|
||||
t.equal(ber.length, 15, 'wrong length');
|
||||
t.equal(ber[0], 0x30, 'wrong tag');
|
||||
t.equal(ber[1], 13, 'wrong length');
|
||||
t.equal(ber[2], 0x04, 'wrong tag');
|
||||
t.equal(ber[3], 11, 'wrong length');
|
||||
t.equal(ber.slice(4).toString('utf8'), 'hello world', 'wrong value');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('nested sequence', function(t) {
|
||||
var writer = new BerWriter({size: 25});
|
||||
writer.startSequence();
|
||||
writer.writeString('hello world');
|
||||
writer.startSequence();
|
||||
writer.writeString('hello world');
|
||||
writer.endSequence();
|
||||
writer.endSequence();
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 30, 'wrong length');
|
||||
t.equal(ber[0], 0x30, 'wrong tag');
|
||||
t.equal(ber[1], 28, 'wrong length');
|
||||
t.equal(ber[2], 0x04, 'wrong tag');
|
||||
t.equal(ber[3], 11, 'wrong length');
|
||||
t.equal(ber.slice(4, 15).toString('utf8'), 'hello world', 'wrong value');
|
||||
t.equal(ber[15], 0x30, 'wrong tag');
|
||||
t.equal(ber[16], 13, 'wrong length');
|
||||
t.equal(ber[17], 0x04, 'wrong tag');
|
||||
t.equal(ber[18], 11, 'wrong length');
|
||||
t.equal(ber.slice(19, 30).toString('utf8'), 'hello world', 'wrong value');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('LDAP bind message', function(t) {
|
||||
var dn = 'cn=foo,ou=unit,o=test';
|
||||
var writer = new BerWriter();
|
||||
writer.startSequence();
|
||||
writer.writeInt(3); // msgid = 3
|
||||
writer.startSequence(0x60); // ldap bind
|
||||
writer.writeInt(3); // ldap v3
|
||||
writer.writeString(dn);
|
||||
writer.writeByte(0x80);
|
||||
writer.writeByte(0x00);
|
||||
writer.endSequence();
|
||||
writer.endSequence();
|
||||
var ber = writer.buffer;
|
||||
|
||||
t.ok(ber);
|
||||
t.equal(ber.length, 35, 'wrong length (buffer)');
|
||||
t.equal(ber[0], 0x30, 'wrong tag');
|
||||
t.equal(ber[1], 33, 'wrong length');
|
||||
t.equal(ber[2], 0x02, 'wrong tag');
|
||||
t.equal(ber[3], 1, 'wrong length');
|
||||
t.equal(ber[4], 0x03, 'wrong value');
|
||||
t.equal(ber[5], 0x60, 'wrong tag');
|
||||
t.equal(ber[6], 28, 'wrong length');
|
||||
t.equal(ber[7], 0x02, 'wrong tag');
|
||||
t.equal(ber[8], 1, 'wrong length');
|
||||
t.equal(ber[9], 0x03, 'wrong value');
|
||||
t.equal(ber[10], 0x04, 'wrong tag');
|
||||
t.equal(ber[11], dn.length, 'wrong length');
|
||||
t.equal(ber.slice(12, 33).toString('utf8'), dn, 'wrong value');
|
||||
t.equal(ber[33], 0x80, 'wrong tag');
|
||||
t.equal(ber[34], 0x00, 'wrong len');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('Write OID', function(t) {
|
||||
var oid = '1.2.840.113549.1.1.1';
|
||||
var writer = new BerWriter();
|
||||
writer.writeOID(oid);
|
||||
|
||||
var ber = writer.buffer;
|
||||
t.ok(ber);
|
||||
console.log(require('util').inspect(ber));
|
||||
console.log(require('util').inspect(new Buffer([0x06, 0x09, 0x2a, 0x86,
|
||||
0x48, 0x86, 0xf7, 0x0d,
|
||||
0x01, 0x01, 0x01])));
|
||||
|
||||
t.end();
|
||||
});
|
6
node_modules/assert-plus/AUTHORS
generated
vendored
Normal file
6
node_modules/assert-plus/AUTHORS
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Dave Eddy <dave@daveeddy.com>
|
||||
Fred Kuo <fred.kuo@joyent.com>
|
||||
Lars-Magnus Skog <ralphtheninja@riseup.net>
|
||||
Mark Cavage <mcavage@gmail.com>
|
||||
Patrick Mooney <pmooney@pfmooney.com>
|
||||
Rob Gulewich <robert.gulewich@joyent.com>
|
14
node_modules/assert-plus/CHANGES.md
generated
vendored
Normal file
14
node_modules/assert-plus/CHANGES.md
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# assert-plus Changelog
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- *BREAKING* assert.number (and derivatives) now accept Infinity as valid input
|
||||
- Add assert.finite check. Previous assert.number callers should use this if
|
||||
they expect Infinity inputs to throw.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Fix `assert.object(null)` so it throws
|
||||
- Fix optional/arrayOf exports for non-type-of asserts
|
||||
- Add optiona/arrayOf exports for Stream/Date/Regex/uuid
|
||||
- Add basic unit test coverage
|
162
node_modules/assert-plus/README.md
generated
vendored
Normal file
162
node_modules/assert-plus/README.md
generated
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
# assert-plus
|
||||
|
||||
This library is a super small wrapper over node's assert module that has two
|
||||
things: (1) the ability to disable assertions with the environment variable
|
||||
NODE\_NDEBUG, and (2) some API wrappers for argument testing. Like
|
||||
`assert.string(myArg, 'myArg')`. As a simple example, most of my code looks
|
||||
like this:
|
||||
|
||||
```javascript
|
||||
var assert = require('assert-plus');
|
||||
|
||||
function fooAccount(options, callback) {
|
||||
assert.object(options, 'options');
|
||||
assert.number(options.id, 'options.id');
|
||||
assert.bool(options.isManager, 'options.isManager');
|
||||
assert.string(options.name, 'options.name');
|
||||
assert.arrayOfString(options.email, 'options.email');
|
||||
assert.func(callback, 'callback');
|
||||
|
||||
// Do stuff
|
||||
callback(null, {});
|
||||
}
|
||||
```
|
||||
|
||||
# API
|
||||
|
||||
All methods that *aren't* part of node's core assert API are simply assumed to
|
||||
take an argument, and then a string 'name' that's not a message; `AssertionError`
|
||||
will be thrown if the assertion fails with a message like:
|
||||
|
||||
AssertionError: foo (string) is required
|
||||
at test (/home/mark/work/foo/foo.js:3:9)
|
||||
at Object.<anonymous> (/home/mark/work/foo/foo.js:15:1)
|
||||
at Module._compile (module.js:446:26)
|
||||
at Object..js (module.js:464:10)
|
||||
at Module.load (module.js:353:31)
|
||||
at Function._load (module.js:311:12)
|
||||
at Array.0 (module.js:484:10)
|
||||
at EventEmitter._tickCallback (node.js:190:38)
|
||||
|
||||
from:
|
||||
|
||||
```javascript
|
||||
function test(foo) {
|
||||
assert.string(foo, 'foo');
|
||||
}
|
||||
```
|
||||
|
||||
There you go. You can check that arrays are of a homogeneous type with `Arrayof$Type`:
|
||||
|
||||
```javascript
|
||||
function test(foo) {
|
||||
assert.arrayOfString(foo, 'foo');
|
||||
}
|
||||
```
|
||||
|
||||
You can assert IFF an argument is not `undefined` (i.e., an optional arg):
|
||||
|
||||
```javascript
|
||||
assert.optionalString(foo, 'foo');
|
||||
```
|
||||
|
||||
Lastly, you can opt-out of assertion checking altogether by setting the
|
||||
environment variable `NODE_NDEBUG=1`. This is pseudo-useful if you have
|
||||
lots of assertions, and don't want to pay `typeof ()` taxes to v8 in
|
||||
production. Be advised: The standard functions re-exported from `assert` are
|
||||
also disabled in assert-plus if NDEBUG is specified. Using them directly from
|
||||
the `assert` module avoids this behavior.
|
||||
|
||||
The complete list of APIs is:
|
||||
|
||||
* assert.array
|
||||
* assert.bool
|
||||
* assert.buffer
|
||||
* assert.func
|
||||
* assert.number
|
||||
* assert.finite
|
||||
* assert.object
|
||||
* assert.string
|
||||
* assert.stream
|
||||
* assert.date
|
||||
* assert.regexp
|
||||
* assert.uuid
|
||||
* assert.arrayOfArray
|
||||
* assert.arrayOfBool
|
||||
* assert.arrayOfBuffer
|
||||
* assert.arrayOfFunc
|
||||
* assert.arrayOfNumber
|
||||
* assert.arrayOfFinite
|
||||
* assert.arrayOfObject
|
||||
* assert.arrayOfString
|
||||
* assert.arrayOfStream
|
||||
* assert.arrayOfDate
|
||||
* assert.arrayOfRegexp
|
||||
* assert.arrayOfUuid
|
||||
* assert.optionalArray
|
||||
* assert.optionalBool
|
||||
* assert.optionalBuffer
|
||||
* assert.optionalFunc
|
||||
* assert.optionalNumber
|
||||
* assert.optionalFinite
|
||||
* assert.optionalObject
|
||||
* assert.optionalString
|
||||
* assert.optionalStream
|
||||
* assert.optionalDate
|
||||
* assert.optionalRegexp
|
||||
* assert.optionalUuid
|
||||
* assert.optionalArrayOfArray
|
||||
* assert.optionalArrayOfBool
|
||||
* assert.optionalArrayOfBuffer
|
||||
* assert.optionalArrayOfFunc
|
||||
* assert.optionalArrayOfNumber
|
||||
* assert.optionalArrayOfFinite
|
||||
* assert.optionalArrayOfObject
|
||||
* assert.optionalArrayOfString
|
||||
* assert.optionalArrayOfStream
|
||||
* assert.optionalArrayOfDate
|
||||
* assert.optionalArrayOfRegexp
|
||||
* assert.optionalArrayOfUuid
|
||||
* assert.AssertionError
|
||||
* assert.fail
|
||||
* assert.ok
|
||||
* assert.equal
|
||||
* assert.notEqual
|
||||
* assert.deepEqual
|
||||
* assert.notDeepEqual
|
||||
* assert.strictEqual
|
||||
* assert.notStrictEqual
|
||||
* assert.throws
|
||||
* assert.doesNotThrow
|
||||
* assert.ifError
|
||||
|
||||
# Installation
|
||||
|
||||
npm install assert-plus
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2012 Mark Cavage
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## Bugs
|
||||
|
||||
See <https://github.com/mcavage/node-assert-plus/issues>.
|
211
node_modules/assert-plus/assert.js
generated
vendored
Normal file
211
node_modules/assert-plus/assert.js
generated
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
// Copyright (c) 2012, Mark Cavage. All rights reserved.
|
||||
// Copyright 2015 Joyent, Inc.
|
||||
|
||||
var assert = require('assert');
|
||||
var Stream = require('stream').Stream;
|
||||
var util = require('util');
|
||||
|
||||
|
||||
///--- Globals
|
||||
|
||||
/* JSSTYLED */
|
||||
var UUID_REGEXP = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
|
||||
|
||||
|
||||
///--- Internal
|
||||
|
||||
function _capitalize(str) {
|
||||
return (str.charAt(0).toUpperCase() + str.slice(1));
|
||||
}
|
||||
|
||||
function _toss(name, expected, oper, arg, actual) {
|
||||
throw new assert.AssertionError({
|
||||
message: util.format('%s (%s) is required', name, expected),
|
||||
actual: (actual === undefined) ? typeof (arg) : actual(arg),
|
||||
expected: expected,
|
||||
operator: oper || '===',
|
||||
stackStartFunction: _toss.caller
|
||||
});
|
||||
}
|
||||
|
||||
function _getClass(arg) {
|
||||
return (Object.prototype.toString.call(arg).slice(8, -1));
|
||||
}
|
||||
|
||||
function noop() {
|
||||
// Why even bother with asserts?
|
||||
}
|
||||
|
||||
|
||||
///--- Exports
|
||||
|
||||
var types = {
|
||||
bool: {
|
||||
check: function (arg) { return typeof (arg) === 'boolean'; }
|
||||
},
|
||||
func: {
|
||||
check: function (arg) { return typeof (arg) === 'function'; }
|
||||
},
|
||||
string: {
|
||||
check: function (arg) { return typeof (arg) === 'string'; }
|
||||
},
|
||||
object: {
|
||||
check: function (arg) {
|
||||
return typeof (arg) === 'object' && arg !== null;
|
||||
}
|
||||
},
|
||||
number: {
|
||||
check: function (arg) {
|
||||
return typeof (arg) === 'number' && !isNaN(arg);
|
||||
}
|
||||
},
|
||||
finite: {
|
||||
check: function (arg) {
|
||||
return typeof (arg) === 'number' && !isNaN(arg) && isFinite(arg);
|
||||
}
|
||||
},
|
||||
buffer: {
|
||||
check: function (arg) { return Buffer.isBuffer(arg); },
|
||||
operator: 'Buffer.isBuffer'
|
||||
},
|
||||
array: {
|
||||
check: function (arg) { return Array.isArray(arg); },
|
||||
operator: 'Array.isArray'
|
||||
},
|
||||
stream: {
|
||||
check: function (arg) { return arg instanceof Stream; },
|
||||
operator: 'instanceof',
|
||||
actual: _getClass
|
||||
},
|
||||
date: {
|
||||
check: function (arg) { return arg instanceof Date; },
|
||||
operator: 'instanceof',
|
||||
actual: _getClass
|
||||
},
|
||||
regexp: {
|
||||
check: function (arg) { return arg instanceof RegExp; },
|
||||
operator: 'instanceof',
|
||||
actual: _getClass
|
||||
},
|
||||
uuid: {
|
||||
check: function (arg) {
|
||||
return typeof (arg) === 'string' && UUID_REGEXP.test(arg);
|
||||
},
|
||||
operator: 'isUUID'
|
||||
}
|
||||
};
|
||||
|
||||
function _setExports(ndebug) {
|
||||
var keys = Object.keys(types);
|
||||
var out;
|
||||
|
||||
/* re-export standard assert */
|
||||
if (process.env.NODE_NDEBUG) {
|
||||
out = noop;
|
||||
} else {
|
||||
out = function (arg, msg) {
|
||||
if (!arg) {
|
||||
_toss(msg, 'true', arg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* standard checks */
|
||||
keys.forEach(function (k) {
|
||||
if (ndebug) {
|
||||
out[k] = noop;
|
||||
return;
|
||||
}
|
||||
var type = types[k];
|
||||
out[k] = function (arg, msg) {
|
||||
if (!type.check(arg)) {
|
||||
_toss(msg, k, type.operator, arg, type.actual);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/* optional checks */
|
||||
keys.forEach(function (k) {
|
||||
var name = 'optional' + _capitalize(k);
|
||||
if (ndebug) {
|
||||
out[name] = noop;
|
||||
return;
|
||||
}
|
||||
var type = types[k];
|
||||
out[name] = function (arg, msg) {
|
||||
if (arg === undefined || arg === null) {
|
||||
return;
|
||||
}
|
||||
if (!type.check(arg)) {
|
||||
_toss(msg, k, type.operator, arg, type.actual);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/* arrayOf checks */
|
||||
keys.forEach(function (k) {
|
||||
var name = 'arrayOf' + _capitalize(k);
|
||||
if (ndebug) {
|
||||
out[name] = noop;
|
||||
return;
|
||||
}
|
||||
var type = types[k];
|
||||
var expected = '[' + k + ']';
|
||||
out[name] = function (arg, msg) {
|
||||
if (!Array.isArray(arg)) {
|
||||
_toss(msg, expected, type.operator, arg, type.actual);
|
||||
}
|
||||
var i;
|
||||
for (i = 0; i < arg.length; i++) {
|
||||
if (!type.check(arg[i])) {
|
||||
_toss(msg, expected, type.operator, arg, type.actual);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/* optionalArrayOf checks */
|
||||
keys.forEach(function (k) {
|
||||
var name = 'optionalArrayOf' + _capitalize(k);
|
||||
if (ndebug) {
|
||||
out[name] = noop;
|
||||
return;
|
||||
}
|
||||
var type = types[k];
|
||||
var expected = '[' + k + ']';
|
||||
out[name] = function (arg, msg) {
|
||||
if (arg === undefined || arg === null) {
|
||||
return;
|
||||
}
|
||||
if (!Array.isArray(arg)) {
|
||||
_toss(msg, expected, type.operator, arg, type.actual);
|
||||
}
|
||||
var i;
|
||||
for (i = 0; i < arg.length; i++) {
|
||||
if (!type.check(arg[i])) {
|
||||
_toss(msg, expected, type.operator, arg, type.actual);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/* re-export built-in assertions */
|
||||
Object.keys(assert).forEach(function (k) {
|
||||
if (k === 'AssertionError') {
|
||||
out[k] = assert[k];
|
||||
return;
|
||||
}
|
||||
if (ndebug) {
|
||||
out[k] = noop;
|
||||
return;
|
||||
}
|
||||
out[k] = assert[k];
|
||||
});
|
||||
|
||||
/* export ourselves (for unit tests _only_) */
|
||||
out._setExports = _setExports;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
module.exports = _setExports(process.env.NODE_NDEBUG);
|
84
node_modules/assert-plus/package.json
generated
vendored
Normal file
84
node_modules/assert-plus/package.json
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"_from": "assert-plus@^1.0.0",
|
||||
"_id": "assert-plus@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
|
||||
"_location": "/assert-plus",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "assert-plus@^1.0.0",
|
||||
"name": "assert-plus",
|
||||
"escapedName": "assert-plus",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/dashdash",
|
||||
"/ldapjs",
|
||||
"/verror"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"_shasum": "f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525",
|
||||
"_spec": "assert-plus@^1.0.0",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/a1_BME_Project_Ohm/om/node_modules/ldapjs",
|
||||
"author": {
|
||||
"name": "Mark Cavage",
|
||||
"email": "mcavage@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mcavage/node-assert-plus/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Dave Eddy",
|
||||
"email": "dave@daveeddy.com"
|
||||
},
|
||||
{
|
||||
"name": "Fred Kuo",
|
||||
"email": "fred.kuo@joyent.com"
|
||||
},
|
||||
{
|
||||
"name": "Lars-Magnus Skog",
|
||||
"email": "ralphtheninja@riseup.net"
|
||||
},
|
||||
{
|
||||
"name": "Mark Cavage",
|
||||
"email": "mcavage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Patrick Mooney",
|
||||
"email": "pmooney@pfmooney.com"
|
||||
},
|
||||
{
|
||||
"name": "Rob Gulewich",
|
||||
"email": "robert.gulewich@joyent.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Extra assertions on top of node's assert module",
|
||||
"devDependencies": {
|
||||
"faucet": "0.0.1",
|
||||
"tape": "4.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
},
|
||||
"homepage": "https://github.com/mcavage/node-assert-plus#readme",
|
||||
"license": "MIT",
|
||||
"main": "./assert.js",
|
||||
"name": "assert-plus",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mcavage/node-assert-plus.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape tests/*.js | ./node_modules/.bin/faucet"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
3
node_modules/async/CHANGELOG.md
generated
vendored
3
node_modules/async/CHANGELOG.md
generated
vendored
@ -1,3 +1,6 @@
|
||||
#v2.6.2
|
||||
- Updated lodash to squelch a security warning (#1620)
|
||||
|
||||
# v2.6.1
|
||||
- Updated lodash to prevent `npm audit` warnings. (#1532, #1533)
|
||||
- Made `async-es` more optimized for webpack users (#1517)
|
||||
|
24
node_modules/async/package.json
generated
vendored
24
node_modules/async/package.json
generated
vendored
@ -1,27 +1,27 @@
|
||||
{
|
||||
"_from": "async@2.6.1",
|
||||
"_id": "async@2.6.1",
|
||||
"_from": "async@2.6.2",
|
||||
"_id": "async@2.6.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
|
||||
"_integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
|
||||
"_location": "/async",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "async@2.6.1",
|
||||
"raw": "async@2.6.2",
|
||||
"name": "async",
|
||||
"escapedName": "async",
|
||||
"rawSpec": "2.6.1",
|
||||
"rawSpec": "2.6.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.6.1"
|
||||
"fetchSpec": "2.6.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mongoose"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
|
||||
"_shasum": "b245a23ca71930044ec53fa46aa00a3e87c6a610",
|
||||
"_spec": "async@2.6.1",
|
||||
"_where": "D:\\Gitterra\\om\\node_modules\\mongoose",
|
||||
"_resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz",
|
||||
"_shasum": "18330ea7e6e313887f5d2f2a904bac6fe4dd5381",
|
||||
"_spec": "async@2.6.2",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/a1_BME_Project_Ohm/om/node_modules/mongoose",
|
||||
"author": {
|
||||
"name": "Caolan McMahon"
|
||||
},
|
||||
@ -30,7 +30,7 @@
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.10"
|
||||
"lodash": "^4.17.11"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Higher-order functions and common patterns for asynchronous code",
|
||||
@ -103,5 +103,5 @@
|
||||
"mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
|
||||
"test": "npm run lint && npm run mocha-node-test"
|
||||
},
|
||||
"version": "2.6.1"
|
||||
"version": "2.6.2"
|
||||
}
|
||||
|
86
node_modules/backoff/CHANGES.md
generated
vendored
Normal file
86
node_modules/backoff/CHANGES.md
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
# Changelog
|
||||
|
||||
## 2.5.0
|
||||
|
||||
Those changes are not released yet.
|
||||
|
||||
- In the functional API, invoke the wrapped function callback on abort and emit
|
||||
an `abort` event. This makes it possible to detect when abort is called.
|
||||
- Add a method on the function API, `call.retryIf(predicate)`, which specifies
|
||||
a predicate used to determine whether a given error is retriable or not. The
|
||||
default behavior is unaffected, errors remain retriable by default.
|
||||
|
||||
## 2.4.1
|
||||
|
||||
- Add support for specifying the factor to use in the `ExponentialStrategy`.
|
||||
|
||||
## 2.4.0
|
||||
|
||||
- Replace `FunctionCall.getResults` by `FunctionCall.getLastResult` to avoid
|
||||
storing intermediary results forever as this may lead to memory exhaustion
|
||||
when used in conjunction with an infinite number of backoffs.
|
||||
- Add `FunctionCall.getNumRetries` which returns the number of times the
|
||||
wrapped function was retried.
|
||||
|
||||
## 2.3.0
|
||||
|
||||
- Add four new methods to `FunctionCall` to query the state of the call.
|
||||
- isPending
|
||||
- isRunning
|
||||
- isCompleted
|
||||
- isAborted
|
||||
|
||||
## 2.2.0
|
||||
|
||||
- To match `Backoff` default behavior, `FunctionCall` no longer sets a
|
||||
default failAfter of 5, i.e. the maximum number of backoffs is now
|
||||
unbounded by default.
|
||||
|
||||
## 2.1.0
|
||||
|
||||
- `Backoff.backoff` now accepts an optional error argument that is re-emitted
|
||||
as the last argument of the `backoff` and `fail` events. This provides some
|
||||
context to the listeners as to why a given backoff operation was attempted.
|
||||
- The `backoff` event emitted by the `FunctionCall` class now contains, as its
|
||||
last argument, the error that caused the backoff operation to be attempted.
|
||||
This provides some context to the listeners as to why a given backoff
|
||||
operation was attempted.
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- `FunctionCall.call` renamed into `FunctionCall.start`.
|
||||
- `backoff.call` no longer invokes the wrapped function on `nextTick`. That
|
||||
way, the first attempt is not delayed until the end of the current event
|
||||
loop.
|
||||
|
||||
## 1.2.1
|
||||
|
||||
- Make `FunctionCall.backoffFactory` a private member.
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- Add `backoff.call` and the associated `FunctionCall` class.
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Add a `Backoff.failAfter`.
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Rename `start` and `done` events `backoff` and `ready`.
|
||||
- Remove deprecated `backoff.fibonnaci`.
|
||||
|
||||
## 0.2.1
|
||||
|
||||
- Create `backoff.fibonacci`.
|
||||
- Deprecate `backoff.fibonnaci`.
|
||||
- Expose fibonacci and exponential strategies.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Provide exponential and fibonacci backoffs.
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- Change `initialTimeout` and `maxTimeout` to `initialDelay` and `maxDelay`.
|
||||
- Use fibonnaci backoff.
|
19
node_modules/backoff/LICENSE
generated
vendored
Normal file
19
node_modules/backoff/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (C) 2012 Mathieu Turcotte
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
382
node_modules/backoff/README.md
generated
vendored
Normal file
382
node_modules/backoff/README.md
generated
vendored
Normal file
@ -0,0 +1,382 @@
|
||||
# Backoff for Node.js
|
||||
[](http://travis-ci.org/MathieuTurcotte/node-backoff)
|
||||
[](http://badge.fury.io/js/backoff)
|
||||
|
||||
Fibonacci and exponential backoffs for Node.js.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install backoff
|
||||
```
|
||||
|
||||
## Unit tests
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Object Oriented
|
||||
|
||||
The usual way to instantiate a new `Backoff` object is to use one predefined
|
||||
factory method: `backoff.fibonacci([options])`, `backoff.exponential([options])`.
|
||||
|
||||
`Backoff` inherits from `EventEmitter`. When a backoff starts, a `backoff`
|
||||
event is emitted and, when a backoff ends, a `ready` event is emitted.
|
||||
Handlers for these two events are called with the current backoff number and
|
||||
delay.
|
||||
|
||||
``` js
|
||||
var backoff = require('backoff');
|
||||
|
||||
var fibonacciBackoff = backoff.fibonacci({
|
||||
randomisationFactor: 0,
|
||||
initialDelay: 10,
|
||||
maxDelay: 300
|
||||
});
|
||||
|
||||
fibonacciBackoff.failAfter(10);
|
||||
|
||||
fibonacciBackoff.on('backoff', function(number, delay) {
|
||||
// Do something when backoff starts, e.g. show to the
|
||||
// user the delay before next reconnection attempt.
|
||||
console.log(number + ' ' + delay + 'ms');
|
||||
});
|
||||
|
||||
fibonacciBackoff.on('ready', function(number, delay) {
|
||||
// Do something when backoff ends, e.g. retry a failed
|
||||
// operation (DNS lookup, API call, etc.). If it fails
|
||||
// again then backoff, otherwise reset the backoff
|
||||
// instance.
|
||||
fibonacciBackoff.backoff();
|
||||
});
|
||||
|
||||
fibonacciBackoff.on('fail', function() {
|
||||
// Do something when the maximum number of backoffs is
|
||||
// reached, e.g. ask the user to check its connection.
|
||||
console.log('fail');
|
||||
});
|
||||
|
||||
fibonacciBackoff.backoff();
|
||||
```
|
||||
|
||||
The previous example would print the following.
|
||||
|
||||
```
|
||||
0 10ms
|
||||
1 10ms
|
||||
2 20ms
|
||||
3 30ms
|
||||
4 50ms
|
||||
5 80ms
|
||||
6 130ms
|
||||
7 210ms
|
||||
8 300ms
|
||||
9 300ms
|
||||
fail
|
||||
```
|
||||
|
||||
Note that `Backoff` objects are meant to be instantiated once and reused
|
||||
several times by calling `reset` after a successful "retry".
|
||||
|
||||
### Functional
|
||||
|
||||
It's also possible to avoid some boilerplate code when invoking an asynchronous
|
||||
function in a backoff loop by using `backoff.call(fn, [args, ...], callback)`.
|
||||
|
||||
Typical usage looks like the following.
|
||||
|
||||
``` js
|
||||
var call = backoff.call(get, 'https://duplika.ca/', function(err, res) {
|
||||
console.log('Num retries: ' + call.getNumRetries());
|
||||
|
||||
if (err) {
|
||||
console.log('Error: ' + err.message);
|
||||
} else {
|
||||
console.log('Status: ' + res.statusCode);
|
||||
}
|
||||
});
|
||||
|
||||
call.retryIf(function(err) { return err.status == 503; });
|
||||
call.setStrategy(new backoff.ExponentialStrategy());
|
||||
call.failAfter(10);
|
||||
call.start();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### backoff.fibonacci([options])
|
||||
|
||||
Constructs a Fibonacci backoff (10, 10, 20, 30, 50, etc.).
|
||||
|
||||
The options are the following.
|
||||
|
||||
- randomisationFactor: defaults to 0, must be between 0 and 1
|
||||
- initialDelay: defaults to 100 ms
|
||||
- maxDelay: defaults to 10000 ms
|
||||
|
||||
With these values, the backoff delay will increase from 100 ms to 10000 ms. The
|
||||
randomisation factor controls the range of randomness and must be between 0
|
||||
and 1. By default, no randomisation is applied on the backoff delay.
|
||||
|
||||
### backoff.exponential([options])
|
||||
|
||||
Constructs an exponential backoff (10, 20, 40, 80, etc.).
|
||||
|
||||
The options are the following.
|
||||
|
||||
- randomisationFactor: defaults to 0, must be between 0 and 1
|
||||
- initialDelay: defaults to 100 ms
|
||||
- maxDelay: defaults to 10000 ms
|
||||
- factor: defaults to 2, must be greater than 1
|
||||
|
||||
With these values, the backoff delay will increase from 100 ms to 10000 ms. The
|
||||
randomisation factor controls the range of randomness and must be between 0
|
||||
and 1. By default, no randomisation is applied on the backoff delay.
|
||||
|
||||
### backoff.call(fn, [args, ...], callback)
|
||||
|
||||
- fn: function to call in a backoff handler, i.e. the wrapped function
|
||||
- args: function's arguments
|
||||
- callback: function's callback accepting an error as its first argument
|
||||
|
||||
Constructs a `FunctionCall` instance for the given function. The wrapped
|
||||
function will get retried until it succeds or reaches the maximum number
|
||||
of backoffs. In both cases, the callback function will be invoked with the
|
||||
last result returned by the wrapped function.
|
||||
|
||||
It is the caller's responsability to initiate the call by invoking the
|
||||
`start` method on the returned `FunctionCall` instance.
|
||||
|
||||
### Class Backoff
|
||||
|
||||
#### new Backoff(strategy)
|
||||
|
||||
- strategy: the backoff strategy to use
|
||||
|
||||
Constructs a new backoff object from a specific backoff strategy. The backoff
|
||||
strategy must implement the `BackoffStrategy`interface defined bellow.
|
||||
|
||||
#### backoff.failAfter(numberOfBackoffs)
|
||||
|
||||
- numberOfBackoffs: maximum number of backoffs before the fail event gets
|
||||
emitted, must be greater than 0
|
||||
|
||||
Sets a limit on the maximum number of backoffs that can be performed before
|
||||
a fail event gets emitted and the backoff instance is reset. By default, there
|
||||
is no limit on the number of backoffs that can be performed.
|
||||
|
||||
#### backoff.backoff([err])
|
||||
|
||||
Starts a backoff operation. If provided, the error parameter will be emitted
|
||||
as the last argument of the `backoff` and `fail` events to let the listeners
|
||||
know why the backoff operation was attempted.
|
||||
|
||||
An error will be thrown if a backoff operation is already in progress.
|
||||
|
||||
In practice, this method should be called after a failed attempt to perform a
|
||||
sensitive operation (connecting to a database, downloading a resource over the
|
||||
network, etc.).
|
||||
|
||||
#### backoff.reset()
|
||||
|
||||
Resets the backoff delay to the initial backoff delay and stop any backoff
|
||||
operation in progress. After reset, a backoff instance can and should be
|
||||
reused.
|
||||
|
||||
In practice, this method should be called after having successfully completed
|
||||
the sensitive operation guarded by the backoff instance or if the client code
|
||||
request to stop any reconnection attempt.
|
||||
|
||||
#### Event: 'backoff'
|
||||
|
||||
- number: number of backoffs since last reset, starting at 0
|
||||
- delay: backoff delay in milliseconds
|
||||
- err: optional error parameter passed to `backoff.backoff([err])`
|
||||
|
||||
Emitted when a backoff operation is started. Signals to the client how long
|
||||
the next backoff delay will be.
|
||||
|
||||
#### Event: 'ready'
|
||||
|
||||
- number: number of backoffs since last reset, starting at 0
|
||||
- delay: backoff delay in milliseconds
|
||||
|
||||
Emitted when a backoff operation is done. Signals that the failing operation
|
||||
should be retried.
|
||||
|
||||
#### Event: 'fail'
|
||||
|
||||
- err: optional error parameter passed to `backoff.backoff([err])`
|
||||
|
||||
Emitted when the maximum number of backoffs is reached. This event will only
|
||||
be emitted if the client has set a limit on the number of backoffs by calling
|
||||
`backoff.failAfter(numberOfBackoffs)`. The backoff instance is automatically
|
||||
reset after this event is emitted.
|
||||
|
||||
### Interface BackoffStrategy
|
||||
|
||||
A backoff strategy must provide the following methods.
|
||||
|
||||
#### strategy.next()
|
||||
|
||||
Computes and returns the next backoff delay.
|
||||
|
||||
#### strategy.reset()
|
||||
|
||||
Resets the backoff delay to its initial value.
|
||||
|
||||
### Class ExponentialStrategy
|
||||
|
||||
Exponential (10, 20, 40, 80, etc.) backoff strategy implementation.
|
||||
|
||||
#### new ExponentialStrategy([options])
|
||||
|
||||
The options are the following.
|
||||
|
||||
- randomisationFactor: defaults to 0, must be between 0 and 1
|
||||
- initialDelay: defaults to 100 ms
|
||||
- maxDelay: defaults to 10000 ms
|
||||
- factor: defaults to 2, must be greater than 1
|
||||
|
||||
### Class FibonacciStrategy
|
||||
|
||||
Fibonnaci (10, 10, 20, 30, 50, etc.) backoff strategy implementation.
|
||||
|
||||
#### new FibonacciStrategy([options])
|
||||
|
||||
The options are the following.
|
||||
|
||||
- randomisationFactor: defaults to 0, must be between 0 and 1
|
||||
- initialDelay: defaults to 100 ms
|
||||
- maxDelay: defaults to 10000 ms
|
||||
|
||||
### Class FunctionCall
|
||||
|
||||
This class manages the calling of an asynchronous function within a backoff
|
||||
loop.
|
||||
|
||||
This class should rarely be instantiated directly since the factory method
|
||||
`backoff.call(fn, [args, ...], callback)` offers a more convenient and safer
|
||||
way to create `FunctionCall` instances.
|
||||
|
||||
#### new FunctionCall(fn, args, callback)
|
||||
|
||||
- fn: asynchronous function to call
|
||||
- args: an array containing fn's args
|
||||
- callback: fn's callback
|
||||
|
||||
Constructs a function handler for the given asynchronous function.
|
||||
|
||||
#### call.isPending()
|
||||
|
||||
Returns whether the call is pending, i.e. hasn't been started.
|
||||
|
||||
#### call.isRunning()
|
||||
|
||||
Returns whether the call is in progress.
|
||||
|
||||
#### call.isCompleted()
|
||||
|
||||
Returns whether the call is completed.
|
||||
|
||||
#### call.isAborted()
|
||||
|
||||
Returns whether the call is aborted.
|
||||
|
||||
#### call.setStrategy(strategy)
|
||||
|
||||
- strategy: strategy instance to use, defaults to `FibonacciStrategy`.
|
||||
|
||||
Sets the backoff strategy to use. This method should be called before
|
||||
`call.start()` otherwise an exception will be thrown.
|
||||
|
||||
#### call.failAfter(maxNumberOfBackoffs)
|
||||
|
||||
- maxNumberOfBackoffs: maximum number of backoffs before the call is aborted
|
||||
|
||||
Sets the maximum number of backoffs before the call is aborted. By default,
|
||||
there is no limit on the number of backoffs that can be performed.
|
||||
|
||||
This method should be called before `call.start()` otherwise an exception will
|
||||
be thrown..
|
||||
|
||||
#### call.retryIf(predicate)
|
||||
|
||||
- predicate: a function which takes in as its argument the error returned
|
||||
by the wrapped function and determines whether it is retriable.
|
||||
|
||||
Sets the predicate which will be invoked to determine whether a given error
|
||||
should be retried or not, e.g. a network error would be retriable while a type
|
||||
error would stop the function call. By default, all errors are considered to be
|
||||
retriable.
|
||||
|
||||
This method should be called before `call.start()` otherwise an exception will
|
||||
be thrown.
|
||||
|
||||
#### call.getLastResult()
|
||||
|
||||
Returns an array containing the last arguments passed to the completion callback
|
||||
of the wrapped function. For example, to get the error code returned by the last
|
||||
call, one would do the following.
|
||||
|
||||
``` js
|
||||
var results = call.getLastResult();
|
||||
// The error code is the first parameter of the callback.
|
||||
var error = results[0];
|
||||
```
|
||||
|
||||
Note that if the call was aborted, it will contain the abort error and not the
|
||||
last error returned by the wrapped function.
|
||||
|
||||
#### call.getNumRetries()
|
||||
|
||||
Returns the number of times the wrapped function call was retried. For a
|
||||
wrapped function that succeeded immediately, this would return 0. This
|
||||
method can be called at any point in time during the call life cycle, i.e.
|
||||
before, during and after the wrapped function invocation.
|
||||
|
||||
#### call.start()
|
||||
|
||||
Initiates the call the wrapped function. This method should only be called
|
||||
once otherwise an exception will be thrown.
|
||||
|
||||
#### call.abort()
|
||||
|
||||
Aborts the call and causes the completion callback to be invoked with an abort
|
||||
error if the call was pending or running; does nothing otherwise. This method
|
||||
can safely be called mutliple times.
|
||||
|
||||
#### Event: 'call'
|
||||
|
||||
- args: wrapped function's arguments
|
||||
|
||||
Emitted each time the wrapped function is called.
|
||||
|
||||
#### Event: 'callback'
|
||||
|
||||
- results: wrapped function's return values
|
||||
|
||||
Emitted each time the wrapped function invokes its callback.
|
||||
|
||||
#### Event: 'backoff'
|
||||
|
||||
- number: backoff number, starts at 0
|
||||
- delay: backoff delay in milliseconds
|
||||
- err: the error that triggered the backoff operation
|
||||
|
||||
Emitted each time a backoff operation is started.
|
||||
|
||||
#### Event: 'abort'
|
||||
|
||||
Emitted when a call is aborted.
|
||||
|
||||
## Annotated source code
|
||||
|
||||
The annotated source code can be found at [mathieuturcotte.github.io/node-backoff/docs](http://mathieuturcotte.github.io/node-backoff/docs/).
|
||||
|
||||
## License
|
||||
|
||||
This code is free to use under the terms of the [MIT license](http://mturcotte.mit-license.org/).
|
31
node_modules/backoff/index.js
generated
vendored
Normal file
31
node_modules/backoff/index.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2012 Mathieu Turcotte
|
||||
// Licensed under the MIT license.
|
||||
|
||||
var Backoff = require('./lib/backoff');
|
||||
var ExponentialBackoffStrategy = require('./lib/strategy/exponential');
|
||||
var FibonacciBackoffStrategy = require('./lib/strategy/fibonacci');
|
||||
var FunctionCall = require('./lib/function_call.js');
|
||||
|
||||
module.exports.Backoff = Backoff;
|
||||
module.exports.FunctionCall = FunctionCall;
|
||||
module.exports.FibonacciStrategy = FibonacciBackoffStrategy;
|
||||
module.exports.ExponentialStrategy = ExponentialBackoffStrategy;
|
||||
|
||||
// Constructs a Fibonacci backoff.
|
||||
module.exports.fibonacci = function(options) {
|
||||
return new Backoff(new FibonacciBackoffStrategy(options));
|
||||
};
|
||||
|
||||
// Constructs an exponential backoff.
|
||||
module.exports.exponential = function(options) {
|
||||
return new Backoff(new ExponentialBackoffStrategy(options));
|
||||
};
|
||||
|
||||
// Constructs a FunctionCall for the given function and arguments.
|
||||
module.exports.call = function(fn, vargs, callback) {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
fn = args[0];
|
||||
vargs = args.slice(1, args.length - 1);
|
||||
callback = args[args.length - 1];
|
||||
return new FunctionCall(fn, vargs, callback);
|
||||
};
|
65
node_modules/backoff/lib/backoff.js
generated
vendored
Normal file
65
node_modules/backoff/lib/backoff.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (c) 2012 Mathieu Turcotte
|
||||
// Licensed under the MIT license.
|
||||
|
||||
var events = require('events');
|
||||
var precond = require('precond');
|
||||
var util = require('util');
|
||||
|
||||
// A class to hold the state of a backoff operation. Accepts a backoff strategy
|
||||
// to generate the backoff delays.
|
||||
function Backoff(backoffStrategy) {
|
||||
events.EventEmitter.call(this);
|
||||
|
||||
this.backoffStrategy_ = backoffStrategy;
|
||||
this.maxNumberOfRetry_ = -1;
|
||||
this.backoffNumber_ = 0;
|
||||
this.backoffDelay_ = 0;
|
||||
this.timeoutID_ = -1;
|
||||
|
||||
this.handlers = {
|
||||
backoff: this.onBackoff_.bind(this)
|
||||
};
|
||||
}
|
||||
util.inherits(Backoff, events.EventEmitter);
|
||||
|
||||
// Sets a limit, greater than 0, on the maximum number of backoffs. A 'fail'
|
||||
// event will be emitted when the limit is reached.
|
||||
Backoff.prototype.failAfter = function(maxNumberOfRetry) {
|
||||
precond.checkArgument(maxNumberOfRetry > 0,
|
||||
'Expected a maximum number of retry greater than 0 but got %s.',
|
||||
maxNumberOfRetry);
|
||||
|
||||
this.maxNumberOfRetry_ = maxNumberOfRetry;
|
||||
};
|
||||
|
||||
// Starts a backoff operation. Accepts an optional parameter to let the
|
||||
// listeners know why the backoff operation was started.
|
||||
Backoff.prototype.backoff = function(err) {
|
||||
precond.checkState(this.timeoutID_ === -1, 'Backoff in progress.');
|
||||
|
||||
if (this.backoffNumber_ === this.maxNumberOfRetry_) {
|
||||
this.emit('fail', err);
|
||||
this.reset();
|
||||
} else {
|
||||
this.backoffDelay_ = this.backoffStrategy_.next();
|
||||
this.timeoutID_ = setTimeout(this.handlers.backoff, this.backoffDelay_);
|
||||
this.emit('backoff', this.backoffNumber_, this.backoffDelay_, err);
|
||||
}
|
||||
};
|
||||
|
||||
// Handles the backoff timeout completion.
|
||||
Backoff.prototype.onBackoff_ = function() {
|
||||
this.timeoutID_ = -1;
|
||||
this.emit('ready', this.backoffNumber_, this.backoffDelay_);
|
||||
this.backoffNumber_++;
|
||||
};
|
||||
|
||||
// Stops any backoff operation and resets the backoff delay to its inital value.
|
||||
Backoff.prototype.reset = function() {
|
||||
this.backoffNumber_ = 0;
|
||||
this.backoffStrategy_.reset();
|
||||
clearTimeout(this.timeoutID_);
|
||||
this.timeoutID_ = -1;
|
||||
};
|
||||
|
||||
module.exports = Backoff;
|
190
node_modules/backoff/lib/function_call.js
generated
vendored
Normal file
190
node_modules/backoff/lib/function_call.js
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
// Copyright (c) 2012 Mathieu Turcotte
|
||||
// Licensed under the MIT license.
|
||||
|
||||
var events = require('events');
|
||||
var precond = require('precond');
|
||||
var util = require('util');
|
||||
|
||||
var Backoff = require('./backoff');
|
||||
var FibonacciBackoffStrategy = require('./strategy/fibonacci');
|
||||
|
||||
// Wraps a function to be called in a backoff loop.
|
||||
function FunctionCall(fn, args, callback) {
|
||||
events.EventEmitter.call(this);
|
||||
|
||||
precond.checkIsFunction(fn, 'Expected fn to be a function.');
|
||||
precond.checkIsArray(args, 'Expected args to be an array.');
|
||||
precond.checkIsFunction(callback, 'Expected callback to be a function.');
|
||||
|
||||
this.function_ = fn;
|
||||
this.arguments_ = args;
|
||||
this.callback_ = callback;
|
||||
this.lastResult_ = [];
|
||||
this.numRetries_ = 0;
|
||||
|
||||
this.backoff_ = null;
|
||||
this.strategy_ = null;
|
||||
this.failAfter_ = -1;
|
||||
this.retryPredicate_ = FunctionCall.DEFAULT_RETRY_PREDICATE_;
|
||||
|
||||
this.state_ = FunctionCall.State_.PENDING;
|
||||
}
|
||||
util.inherits(FunctionCall, events.EventEmitter);
|
||||
|
||||
// States in which the call can be.
|
||||
FunctionCall.State_ = {
|
||||
// Call isn't started yet.
|
||||
PENDING: 0,
|
||||
// Call is in progress.
|
||||
RUNNING: 1,
|
||||
// Call completed successfully which means that either the wrapped function
|
||||
// returned successfully or the maximal number of backoffs was reached.
|
||||
COMPLETED: 2,
|
||||
// The call was aborted.
|
||||
ABORTED: 3
|
||||
};
|
||||
|
||||
// The default retry predicate which considers any error as retriable.
|
||||
FunctionCall.DEFAULT_RETRY_PREDICATE_ = function(err) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// Checks whether the call is pending.
|
||||
FunctionCall.prototype.isPending = function() {
|
||||
return this.state_ == FunctionCall.State_.PENDING;
|
||||
};
|
||||
|
||||
// Checks whether the call is in progress.
|
||||
FunctionCall.prototype.isRunning = function() {
|
||||
return this.state_ == FunctionCall.State_.RUNNING;
|
||||
};
|
||||
|
||||
// Checks whether the call is completed.
|
||||
FunctionCall.prototype.isCompleted = function() {
|
||||
return this.state_ == FunctionCall.State_.COMPLETED;
|
||||
};
|
||||
|
||||
// Checks whether the call is aborted.
|
||||
FunctionCall.prototype.isAborted = function() {
|
||||
return this.state_ == FunctionCall.State_.ABORTED;
|
||||
};
|
||||
|
||||
// Sets the backoff strategy to use. Can only be called before the call is
|
||||
// started otherwise an exception will be thrown.
|
||||
FunctionCall.prototype.setStrategy = function(strategy) {
|
||||
precond.checkState(this.isPending(), 'FunctionCall in progress.');
|
||||
this.strategy_ = strategy;
|
||||
return this; // Return this for chaining.
|
||||
};
|
||||
|
||||
// Sets the predicate which will be used to determine whether the errors
|
||||
// returned from the wrapped function should be retried or not, e.g. a
|
||||
// network error would be retriable while a type error would stop the
|
||||
// function call.
|
||||
FunctionCall.prototype.retryIf = function(retryPredicate) {
|
||||
precond.checkState(this.isPending(), 'FunctionCall in progress.');
|
||||
this.retryPredicate_ = retryPredicate;
|
||||
return this;
|
||||
};
|
||||
|
||||
// Returns all intermediary results returned by the wrapped function since
|
||||
// the initial call.
|
||||
FunctionCall.prototype.getLastResult = function() {
|
||||
return this.lastResult_.concat();
|
||||
};
|
||||
|
||||
// Returns the number of times the wrapped function call was retried.
|
||||
FunctionCall.prototype.getNumRetries = function() {
|
||||
return this.numRetries_;
|
||||
};
|
||||
|
||||
// Sets the backoff limit.
|
||||
FunctionCall.prototype.failAfter = function(maxNumberOfRetry) {
|
||||
precond.checkState(this.isPending(), 'FunctionCall in progress.');
|
||||
this.failAfter_ = maxNumberOfRetry;
|
||||
return this; // Return this for chaining.
|
||||
};
|
||||
|
||||
// Aborts the call.
|
||||
FunctionCall.prototype.abort = function() {
|
||||
if (this.isCompleted() || this.isAborted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isRunning()) {
|
||||
this.backoff_.reset();
|
||||
}
|
||||
|
||||
this.state_ = FunctionCall.State_.ABORTED;
|
||||
this.lastResult_ = [new Error('Backoff aborted.')];
|
||||
this.emit('abort');
|
||||
this.doCallback_();
|
||||
};
|
||||
|
||||
// Initiates the call to the wrapped function. Accepts an optional factory
|
||||
// function used to create the backoff instance; used when testing.
|
||||
FunctionCall.prototype.start = function(backoffFactory) {
|
||||
precond.checkState(!this.isAborted(), 'FunctionCall is aborted.');
|
||||
precond.checkState(this.isPending(), 'FunctionCall already started.');
|
||||
|
||||
var strategy = this.strategy_ || new FibonacciBackoffStrategy();
|
||||
|
||||
this.backoff_ = backoffFactory ?
|
||||
backoffFactory(strategy) :
|
||||
new Backoff(strategy);
|
||||
|
||||
this.backoff_.on('ready', this.doCall_.bind(this, true /* isRetry */));
|
||||
this.backoff_.on('fail', this.doCallback_.bind(this));
|
||||
this.backoff_.on('backoff', this.handleBackoff_.bind(this));
|
||||
|
||||
if (this.failAfter_ > 0) {
|
||||
this.backoff_.failAfter(this.failAfter_);
|
||||
}
|
||||
|
||||
this.state_ = FunctionCall.State_.RUNNING;
|
||||
this.doCall_(false /* isRetry */);
|
||||
};
|
||||
|
||||
// Calls the wrapped function.
|
||||
FunctionCall.prototype.doCall_ = function(isRetry) {
|
||||
if (isRetry) {
|
||||
this.numRetries_++;
|
||||
}
|
||||
var eventArgs = ['call'].concat(this.arguments_);
|
||||
events.EventEmitter.prototype.emit.apply(this, eventArgs);
|
||||
var callback = this.handleFunctionCallback_.bind(this);
|
||||
this.function_.apply(null, this.arguments_.concat(callback));
|
||||
};
|
||||
|
||||
// Calls the wrapped function's callback with the last result returned by the
|
||||
// wrapped function.
|
||||
FunctionCall.prototype.doCallback_ = function() {
|
||||
this.callback_.apply(null, this.lastResult_);
|
||||
};
|
||||
|
||||
// Handles wrapped function's completion. This method acts as a replacement
|
||||
// for the original callback function.
|
||||
FunctionCall.prototype.handleFunctionCallback_ = function() {
|
||||
if (this.isAborted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
this.lastResult_ = args; // Save last callback arguments.
|
||||
events.EventEmitter.prototype.emit.apply(this, ['callback'].concat(args));
|
||||
|
||||
var err = args[0];
|
||||
if (err && this.retryPredicate_(err)) {
|
||||
this.backoff_.backoff(err);
|
||||
} else {
|
||||
this.state_ = FunctionCall.State_.COMPLETED;
|
||||
this.doCallback_();
|
||||
}
|
||||
};
|
||||
|
||||
// Handles the backoff event by reemitting it.
|
||||
FunctionCall.prototype.handleBackoff_ = function(number, delay, err) {
|
||||
this.emit('backoff', number, delay, err);
|
||||
};
|
||||
|
||||
module.exports = FunctionCall;
|
41
node_modules/backoff/lib/strategy/exponential.js
generated
vendored
Normal file
41
node_modules/backoff/lib/strategy/exponential.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2012 Mathieu Turcotte
|
||||
// Licensed under the MIT license.
|
||||
|
||||
var util = require('util');
|
||||
var precond = require('precond');
|
||||
|
||||
var BackoffStrategy = require('./strategy');
|
||||
|
||||
// Exponential backoff strategy.
|
||||
function ExponentialBackoffStrategy(options) {
|
||||
BackoffStrategy.call(this, options);
|
||||
this.backoffDelay_ = 0;
|
||||
this.nextBackoffDelay_ = this.getInitialDelay();
|
||||
this.factor_ = ExponentialBackoffStrategy.DEFAULT_FACTOR;
|
||||
|
||||
if (options && options.factor !== undefined) {
|
||||
precond.checkArgument(options.factor > 1,
|
||||
'Exponential factor should be greater than 1 but got %s.',
|
||||
options.factor);
|
||||
this.factor_ = options.factor;
|
||||
}
|
||||
}
|
||||
util.inherits(ExponentialBackoffStrategy, BackoffStrategy);
|
||||
|
||||
// Default multiplication factor used to compute the next backoff delay from
|
||||
// the current one. The value can be overridden by passing a custom factor as
|
||||
// part of the options.
|
||||
ExponentialBackoffStrategy.DEFAULT_FACTOR = 2;
|
||||
|
||||
ExponentialBackoffStrategy.prototype.next_ = function() {
|
||||
this.backoffDelay_ = Math.min(this.nextBackoffDelay_, this.getMaxDelay());
|
||||
this.nextBackoffDelay_ = this.backoffDelay_ * this.factor_;
|
||||
return this.backoffDelay_;
|
||||
};
|
||||
|
||||
ExponentialBackoffStrategy.prototype.reset_ = function() {
|
||||
this.backoffDelay_ = 0;
|
||||
this.nextBackoffDelay_ = this.getInitialDelay();
|
||||
};
|
||||
|
||||
module.exports = ExponentialBackoffStrategy;
|
28
node_modules/backoff/lib/strategy/fibonacci.js
generated
vendored
Normal file
28
node_modules/backoff/lib/strategy/fibonacci.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2012 Mathieu Turcotte
|
||||
// Licensed under the MIT license.
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var BackoffStrategy = require('./strategy');
|
||||
|
||||
// Fibonacci backoff strategy.
|
||||
function FibonacciBackoffStrategy(options) {
|
||||
BackoffStrategy.call(this, options);
|
||||
this.backoffDelay_ = 0;
|
||||
this.nextBackoffDelay_ = this.getInitialDelay();
|
||||
}
|
||||
util.inherits(FibonacciBackoffStrategy, BackoffStrategy);
|
||||
|
||||
FibonacciBackoffStrategy.prototype.next_ = function() {
|
||||
var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay());
|
||||
this.nextBackoffDelay_ += this.backoffDelay_;
|
||||
this.backoffDelay_ = backoffDelay;
|
||||
return backoffDelay;
|
||||
};
|
||||
|
||||
FibonacciBackoffStrategy.prototype.reset_ = function() {
|
||||
this.nextBackoffDelay_ = this.getInitialDelay();
|
||||
this.backoffDelay_ = 0;
|
||||
};
|
||||
|
||||
module.exports = FibonacciBackoffStrategy;
|
80
node_modules/backoff/lib/strategy/strategy.js
generated
vendored
Normal file
80
node_modules/backoff/lib/strategy/strategy.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright (c) 2012 Mathieu Turcotte
|
||||
// Licensed under the MIT license.
|
||||
|
||||
var events = require('events');
|
||||
var util = require('util');
|
||||
|
||||
function isDef(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
|
||||
// Abstract class defining the skeleton for the backoff strategies. Accepts an
|
||||
// object holding the options for the backoff strategy:
|
||||
//
|
||||
// * `randomisationFactor`: The randomisation factor which must be between 0
|
||||
// and 1 where 1 equates to a randomization factor of 100% and 0 to no
|
||||
// randomization.
|
||||
// * `initialDelay`: The backoff initial delay in milliseconds.
|
||||
// * `maxDelay`: The backoff maximal delay in milliseconds.
|
||||
function BackoffStrategy(options) {
|
||||
options = options || {};
|
||||
|
||||
if (isDef(options.initialDelay) && options.initialDelay < 1) {
|
||||
throw new Error('The initial timeout must be greater than 0.');
|
||||
} else if (isDef(options.maxDelay) && options.maxDelay < 1) {
|
||||
throw new Error('The maximal timeout must be greater than 0.');
|
||||
}
|
||||
|
||||
this.initialDelay_ = options.initialDelay || 100;
|
||||
this.maxDelay_ = options.maxDelay || 10000;
|
||||
|
||||
if (this.maxDelay_ <= this.initialDelay_) {
|
||||
throw new Error('The maximal backoff delay must be ' +
|
||||
'greater than the initial backoff delay.');
|
||||
}
|
||||
|
||||
if (isDef(options.randomisationFactor) &&
|
||||
(options.randomisationFactor < 0 || options.randomisationFactor > 1)) {
|
||||
throw new Error('The randomisation factor must be between 0 and 1.');
|
||||
}
|
||||
|
||||
this.randomisationFactor_ = options.randomisationFactor || 0;
|
||||
}
|
||||
|
||||
// Gets the maximal backoff delay.
|
||||
BackoffStrategy.prototype.getMaxDelay = function() {
|
||||
return this.maxDelay_;
|
||||
};
|
||||
|
||||
// Gets the initial backoff delay.
|
||||
BackoffStrategy.prototype.getInitialDelay = function() {
|
||||
return this.initialDelay_;
|
||||
};
|
||||
|
||||
// Template method that computes and returns the next backoff delay in
|
||||
// milliseconds.
|
||||
BackoffStrategy.prototype.next = function() {
|
||||
var backoffDelay = this.next_();
|
||||
var randomisationMultiple = 1 + Math.random() * this.randomisationFactor_;
|
||||
var randomizedDelay = Math.round(backoffDelay * randomisationMultiple);
|
||||
return randomizedDelay;
|
||||
};
|
||||
|
||||
// Computes and returns the next backoff delay. Intended to be overridden by
|
||||
// subclasses.
|
||||
BackoffStrategy.prototype.next_ = function() {
|
||||
throw new Error('BackoffStrategy.next_() unimplemented.');
|
||||
};
|
||||
|
||||
// Template method that resets the backoff delay to its initial value.
|
||||
BackoffStrategy.prototype.reset = function() {
|
||||
this.reset_();
|
||||
};
|
||||
|
||||
// Resets the backoff delay to its initial value. Intended to be overridden by
|
||||
// subclasses.
|
||||
BackoffStrategy.prototype.reset_ = function() {
|
||||
throw new Error('BackoffStrategy.reset_() unimplemented.');
|
||||
};
|
||||
|
||||
module.exports = BackoffStrategy;
|
69
node_modules/backoff/package.json
generated
vendored
Normal file
69
node_modules/backoff/package.json
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "backoff@^2.5.0",
|
||||
"_id": "backoff@2.5.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-9hbtqdPktmuMp/ynn2lXIsX44m8=",
|
||||
"_location": "/backoff",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "backoff@^2.5.0",
|
||||
"name": "backoff",
|
||||
"escapedName": "backoff",
|
||||
"rawSpec": "^2.5.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.5.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/ldapjs"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz",
|
||||
"_shasum": "f616eda9d3e4b66b8ca7fca79f695722c5f8e26f",
|
||||
"_spec": "backoff@^2.5.0",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/a1_BME_Project_Ohm/om/node_modules/ldapjs",
|
||||
"author": {
|
||||
"name": "Mathieu Turcotte",
|
||||
"email": "turcotte.mat@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/MathieuTurcotte/node-backoff/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"precond": "0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Fibonacci and exponential backoffs.",
|
||||
"devDependencies": {
|
||||
"nodeunit": "0.9",
|
||||
"sinon": "1.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib",
|
||||
"tests"
|
||||
],
|
||||
"homepage": "https://github.com/MathieuTurcotte/node-backoff#readme",
|
||||
"keywords": [
|
||||
"backoff",
|
||||
"retry",
|
||||
"fibonacci",
|
||||
"exponential"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "backoff",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/MathieuTurcotte/node-backoff.git"
|
||||
},
|
||||
"scripts": {
|
||||
"docco": "docco lib/*.js lib/strategy/* index.js",
|
||||
"pretest": "jshint lib/ tests/ examples/ index.js",
|
||||
"test": "node_modules/nodeunit/bin/nodeunit tests/"
|
||||
},
|
||||
"version": "2.5.0"
|
||||
}
|
68
node_modules/backoff/tests/api.js
generated
vendored
Normal file
68
node_modules/backoff/tests/api.js
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mathieu Turcotte
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var sinon = require('sinon');
|
||||
|
||||
var backoff = require('../index');
|
||||
|
||||
exports["API"] = {
|
||||
"backoff.fibonnaci should be a function that returns a backoff instance": function(test) {
|
||||
test.ok(backoff.fibonacci, 'backoff.fibonacci should be defined.');
|
||||
test.equal(typeof backoff.fibonacci, 'function',
|
||||
'backoff.fibonacci should be a function.');
|
||||
test.equal(backoff.fibonacci().constructor.name, 'Backoff');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff.exponential should be a function that returns a backoff instance": function(test) {
|
||||
test.ok(backoff.exponential, 'backoff.exponential should be defined.');
|
||||
test.equal(typeof backoff.exponential, 'function',
|
||||
'backoff.exponential should be a function.');
|
||||
test.equal(backoff.exponential().constructor.name, 'Backoff');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff.call should be a function that returns a FunctionCall instance": function(test) {
|
||||
var fn = function() {};
|
||||
var callback = function() {};
|
||||
test.ok(backoff.Backoff, 'backoff.call should be defined.');
|
||||
test.equal(typeof backoff.call, 'function',
|
||||
'backoff.call should be a function.');
|
||||
test.equal(backoff.call(fn, 1, 2, 3, callback).constructor.name,
|
||||
'FunctionCall');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff.Backoff should be defined and a function": function(test) {
|
||||
test.ok(backoff.Backoff, 'backoff.Backoff should be defined.');
|
||||
test.equal(typeof backoff.Backoff, 'function',
|
||||
'backoff.Backoff should be a function.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff.FunctionCall should be defined and a function": function(test) {
|
||||
test.ok(backoff.FunctionCall,
|
||||
'backoff.FunctionCall should be defined.');
|
||||
test.equal(typeof backoff.FunctionCall, 'function',
|
||||
'backoff.FunctionCall should be a function.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff.FibonacciStrategy should be defined and a function": function(test) {
|
||||
test.ok(backoff.FibonacciStrategy,
|
||||
'backoff.FibonacciStrategy should be defined.');
|
||||
test.equal(typeof backoff.FibonacciStrategy, 'function',
|
||||
'backoff.FibonacciStrategy should be a function.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff.ExponentialStrategy should be defined and a function": function(test) {
|
||||
test.ok(backoff.ExponentialStrategy,
|
||||
'backoff.ExponentialStrategy should be defined.');
|
||||
test.equal(typeof backoff.ExponentialStrategy, 'function',
|
||||
'backoff.ExponentialStrategy should be a function.');
|
||||
test.done();
|
||||
}
|
||||
};
|
166
node_modules/backoff/tests/backoff.js
generated
vendored
Normal file
166
node_modules/backoff/tests/backoff.js
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mathieu Turcotte
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var sinon = require('sinon');
|
||||
|
||||
var Backoff = require('../lib/backoff');
|
||||
var BackoffStrategy = require('../lib/strategy/strategy');
|
||||
|
||||
exports["Backoff"] = {
|
||||
setUp: function(callback) {
|
||||
this.backoffStrategy = sinon.stub(new BackoffStrategy());
|
||||
this.backoff = new Backoff(this.backoffStrategy);
|
||||
this.clock = sinon.useFakeTimers();
|
||||
this.spy = new sinon.spy();
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function(callback) {
|
||||
this.clock.restore();
|
||||
callback();
|
||||
},
|
||||
|
||||
"the backoff event should be emitted when backoff starts": function(test) {
|
||||
this.backoffStrategy.next.returns(10);
|
||||
this.backoff.on('backoff', this.spy);
|
||||
|
||||
this.backoff.backoff();
|
||||
|
||||
test.ok(this.spy.calledOnce,
|
||||
'Backoff event should be emitted when backoff starts.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the ready event should be emitted on backoff completion": function(test) {
|
||||
this.backoffStrategy.next.returns(10);
|
||||
this.backoff.on('ready', this.spy);
|
||||
|
||||
this.backoff.backoff();
|
||||
this.clock.tick(10);
|
||||
|
||||
test.ok(this.spy.calledOnce,
|
||||
'Ready event should be emitted when backoff ends.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the backoff event should be passed the backoff delay": function(test) {
|
||||
this.backoffStrategy.next.returns(989);
|
||||
this.backoff.on('backoff', this.spy);
|
||||
|
||||
this.backoff.backoff();
|
||||
|
||||
test.equal(this.spy.getCall(0).args[1], 989, 'Backoff event should ' +
|
||||
'carry the backoff delay as its second argument.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the ready event should be passed the backoff delay": function(test) {
|
||||
this.backoffStrategy.next.returns(989);
|
||||
this.backoff.on('ready', this.spy);
|
||||
|
||||
this.backoff.backoff();
|
||||
this.clock.tick(989);
|
||||
|
||||
test.equal(this.spy.getCall(0).args[1], 989, 'Ready event should ' +
|
||||
'carry the backoff delay as its second argument.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the fail event should be emitted when backoff limit is reached": function(test) {
|
||||
var err = new Error('Fail');
|
||||
|
||||
this.backoffStrategy.next.returns(10);
|
||||
this.backoff.on('fail', this.spy);
|
||||
|
||||
this.backoff.failAfter(2);
|
||||
|
||||
// Consume first 2 backoffs.
|
||||
for (var i = 0; i < 2; i++) {
|
||||
this.backoff.backoff();
|
||||
this.clock.tick(10);
|
||||
}
|
||||
|
||||
// Failure should occur on the third call, and not before.
|
||||
test.ok(!this.spy.calledOnce, 'Fail event shouldn\'t have been emitted.');
|
||||
this.backoff.backoff(err);
|
||||
test.ok(this.spy.calledOnce, 'Fail event should have been emitted.');
|
||||
test.equal(this.spy.getCall(0).args[0], err, 'Error should be passed');
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"calling backoff while a backoff is in progress should throw an error": function(test) {
|
||||
this.backoffStrategy.next.returns(10);
|
||||
var backoff = this.backoff;
|
||||
|
||||
backoff.backoff();
|
||||
|
||||
test.throws(function() {
|
||||
backoff.backoff();
|
||||
}, /in progress/);
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff limit should be greater than 0": function(test) {
|
||||
var backoff = this.backoff;
|
||||
test.throws(function() {
|
||||
backoff.failAfter(0);
|
||||
}, /greater than 0 but got 0/);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"reset should cancel any backoff in progress": function(test) {
|
||||
this.backoffStrategy.next.returns(10);
|
||||
this.backoff.on('ready', this.spy);
|
||||
|
||||
this.backoff.backoff();
|
||||
|
||||
this.backoff.reset();
|
||||
this.clock.tick(100); // 'ready' should not be emitted.
|
||||
|
||||
test.equals(this.spy.callCount, 0, 'Reset should have aborted the backoff.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"reset should reset the backoff strategy": function(test) {
|
||||
this.backoff.reset();
|
||||
test.ok(this.backoffStrategy.reset.calledOnce,
|
||||
'The backoff strategy should have been resetted.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff should be reset after fail": function(test) {
|
||||
this.backoffStrategy.next.returns(10);
|
||||
|
||||
this.backoff.failAfter(1);
|
||||
|
||||
this.backoff.backoff();
|
||||
this.clock.tick(10);
|
||||
this.backoff.backoff();
|
||||
|
||||
test.ok(this.backoffStrategy.reset.calledOnce,
|
||||
'Backoff should have been resetted after failure.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the backoff number should increase from 0 to N - 1": function(test) {
|
||||
this.backoffStrategy.next.returns(10);
|
||||
this.backoff.on('backoff', this.spy);
|
||||
|
||||
var expectedNumbers = [0, 1, 2, 3, 4];
|
||||
var actualNumbers = [];
|
||||
|
||||
for (var i = 0; i < expectedNumbers.length; i++) {
|
||||
this.backoff.backoff();
|
||||
this.clock.tick(10);
|
||||
actualNumbers.push(this.spy.getCall(i).args[0]);
|
||||
}
|
||||
|
||||
test.deepEqual(expectedNumbers, actualNumbers,
|
||||
'Backoff number should increase from 0 to N - 1.');
|
||||
test.done();
|
||||
}
|
||||
};
|
123
node_modules/backoff/tests/backoff_strategy.js
generated
vendored
Normal file
123
node_modules/backoff/tests/backoff_strategy.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mathieu Turcotte
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var sinon = require('sinon');
|
||||
var util = require('util');
|
||||
|
||||
var BackoffStrategy = require('../lib/strategy/strategy');
|
||||
|
||||
function SampleBackoffStrategy(options) {
|
||||
BackoffStrategy.call(this, options);
|
||||
}
|
||||
util.inherits(SampleBackoffStrategy, BackoffStrategy);
|
||||
|
||||
SampleBackoffStrategy.prototype.next_ = function() {
|
||||
return this.getInitialDelay();
|
||||
};
|
||||
|
||||
SampleBackoffStrategy.prototype.reset_ = function() {};
|
||||
|
||||
exports["BackoffStrategy"] = {
|
||||
setUp: function(callback) {
|
||||
this.random = sinon.stub(Math, 'random');
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function(callback) {
|
||||
this.random.restore();
|
||||
callback();
|
||||
},
|
||||
|
||||
"the randomisation factor should be between 0 and 1": function(test) {
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
randomisationFactor: -0.1
|
||||
});
|
||||
});
|
||||
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
randomisationFactor: 1.1
|
||||
});
|
||||
});
|
||||
|
||||
test.doesNotThrow(function() {
|
||||
new BackoffStrategy({
|
||||
randomisationFactor: 0.5
|
||||
});
|
||||
});
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the raw delay should be randomized based on the randomisation factor": function(test) {
|
||||
var strategy = new SampleBackoffStrategy({
|
||||
randomisationFactor: 0.5,
|
||||
initialDelay: 1000
|
||||
});
|
||||
this.random.returns(0.5);
|
||||
|
||||
var backoffDelay = strategy.next();
|
||||
|
||||
test.equals(backoffDelay, 1000 + (1000 * 0.5 * 0.5));
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the initial backoff delay should be greater than 0": function(test) {
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
initialDelay: -1
|
||||
});
|
||||
});
|
||||
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
initialDelay: 0
|
||||
});
|
||||
});
|
||||
|
||||
test.doesNotThrow(function() {
|
||||
new BackoffStrategy({
|
||||
initialDelay: 1
|
||||
});
|
||||
});
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the maximal backoff delay should be greater than 0": function(test) {
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
maxDelay: -1
|
||||
});
|
||||
});
|
||||
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
maxDelay: 0
|
||||
});
|
||||
});
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"the maximal backoff delay should be greater than the initial backoff delay": function(test) {
|
||||
test.throws(function() {
|
||||
new BackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 10
|
||||
});
|
||||
});
|
||||
|
||||
test.doesNotThrow(function() {
|
||||
new BackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 11
|
||||
});
|
||||
});
|
||||
|
||||
test.done();
|
||||
}
|
||||
};
|
61
node_modules/backoff/tests/exponential_backoff_strategy.js
generated
vendored
Normal file
61
node_modules/backoff/tests/exponential_backoff_strategy.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mathieu Turcotte
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var sinon = require('sinon');
|
||||
|
||||
var ExponentialBackoffStrategy = require('../lib/strategy/exponential');
|
||||
|
||||
exports["ExponentialBackoffStrategy"] = {
|
||||
|
||||
"backoff delays should follow an exponential sequence": function(test) {
|
||||
var strategy = new ExponentialBackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 1000
|
||||
});
|
||||
|
||||
// Exponential sequence: x[i] = x[i-1] * 2.
|
||||
var expectedDelays = [10, 20, 40, 80, 160, 320, 640, 1000, 1000];
|
||||
var actualDelays = expectedDelays.map(function () {
|
||||
return strategy.next();
|
||||
});
|
||||
|
||||
test.deepEqual(expectedDelays, actualDelays,
|
||||
'Generated delays should follow an exponential sequence.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff delay factor should be configurable": function (test) {
|
||||
var strategy = new ExponentialBackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 270,
|
||||
factor: 3
|
||||
});
|
||||
|
||||
// Exponential sequence: x[i] = x[i-1] * 3.
|
||||
var expectedDelays = [10, 30, 90, 270, 270];
|
||||
var actualDelays = expectedDelays.map(function () {
|
||||
return strategy.next();
|
||||
});
|
||||
|
||||
test.deepEqual(expectedDelays, actualDelays,
|
||||
'Generated delays should follow a configurable exponential sequence.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff delays should restart from the initial delay after reset": function(test) {
|
||||
var strategy = new ExponentialBackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 1000
|
||||
});
|
||||
|
||||
strategy.next();
|
||||
strategy.reset();
|
||||
|
||||
var backoffDelay = strategy.next();
|
||||
test.equals(backoffDelay, 10,
|
||||
'Strategy should return the initial delay after reset.');
|
||||
test.done();
|
||||
}
|
||||
};
|
47
node_modules/backoff/tests/fibonacci_backoff_strategy.js
generated
vendored
Normal file
47
node_modules/backoff/tests/fibonacci_backoff_strategy.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mathieu Turcotte
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var sinon = require('sinon');
|
||||
|
||||
var FibonacciBackoffStrategy = require('../lib/strategy/fibonacci');
|
||||
|
||||
exports["FibonacciBackoffStrategy"] = {
|
||||
setUp: function(callback) {
|
||||
this.strategy = new FibonacciBackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 1000
|
||||
});
|
||||
callback();
|
||||
},
|
||||
|
||||
"backoff delays should follow a Fibonacci sequence": function(test) {
|
||||
// Fibonacci sequence: x[i] = x[i-1] + x[i-2].
|
||||
var expectedDelays = [10, 10, 20, 30, 50, 80, 130, 210, 340, 550, 890, 1000];
|
||||
var actualDelays = [];
|
||||
|
||||
for (var i = 0; i < expectedDelays.length; i++) {
|
||||
actualDelays.push(this.strategy.next());
|
||||
}
|
||||
|
||||
test.deepEqual(expectedDelays, actualDelays,
|
||||
'Generated delays should follow a Fibonacci sequence.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff delays should restart from the initial delay after reset": function(test) {
|
||||
var strategy = new FibonacciBackoffStrategy({
|
||||
initialDelay: 10,
|
||||
maxDelay: 1000
|
||||
});
|
||||
|
||||
strategy.next();
|
||||
strategy.reset();
|
||||
|
||||
var backoffDelay = strategy.next();
|
||||
test.equals(backoffDelay, 10,
|
||||
'Strategy should return the initial delay after reset.');
|
||||
test.done();
|
||||
}
|
||||
};
|
406
node_modules/backoff/tests/function_call.js
generated
vendored
Normal file
406
node_modules/backoff/tests/function_call.js
generated
vendored
Normal file
@ -0,0 +1,406 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mathieu Turcotte
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('events');
|
||||
var sinon = require('sinon');
|
||||
var util = require('util');
|
||||
|
||||
var FunctionCall = require('../lib/function_call');
|
||||
|
||||
function MockBackoff() {
|
||||
events.EventEmitter.call(this);
|
||||
|
||||
this.reset = sinon.spy();
|
||||
this.backoff = sinon.spy();
|
||||
this.failAfter = sinon.spy();
|
||||
}
|
||||
util.inherits(MockBackoff, events.EventEmitter);
|
||||
|
||||
exports["FunctionCall"] = {
|
||||
setUp: function(callback) {
|
||||
this.wrappedFn = sinon.stub();
|
||||
this.callback = sinon.stub();
|
||||
this.backoff = new MockBackoff();
|
||||
this.backoffFactory = sinon.stub();
|
||||
this.backoffFactory.returns(this.backoff);
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function(callback) {
|
||||
callback();
|
||||
},
|
||||
|
||||
"constructor's first argument should be a function": function(test) {
|
||||
test.throws(function() {
|
||||
new FunctionCall(1, [], function() {});
|
||||
}, /Expected fn to be a function./);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"constructor's last argument should be a function": function(test) {
|
||||
test.throws(function() {
|
||||
new FunctionCall(function() {}, [], 3);
|
||||
}, /Expected callback to be a function./);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"isPending should return false once the call is started": function(test) {
|
||||
this.wrappedFn.
|
||||
onFirstCall().yields(new Error()).
|
||||
onSecondCall().yields(null, 'Success!');
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
|
||||
test.ok(call.isPending());
|
||||
|
||||
call.start(this.backoffFactory);
|
||||
test.ok(!call.isPending());
|
||||
|
||||
this.backoff.emit('ready');
|
||||
test.ok(!call.isPending());
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"isRunning should return true when call is in progress": function(test) {
|
||||
this.wrappedFn.
|
||||
onFirstCall().yields(new Error()).
|
||||
onSecondCall().yields(null, 'Success!');
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
|
||||
test.ok(!call.isRunning());
|
||||
|
||||
call.start(this.backoffFactory);
|
||||
test.ok(call.isRunning());
|
||||
|
||||
this.backoff.emit('ready');
|
||||
test.ok(!call.isRunning());
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"isCompleted should return true once the call completes": function(test) {
|
||||
this.wrappedFn.
|
||||
onFirstCall().yields(new Error()).
|
||||
onSecondCall().yields(null, 'Success!');
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
|
||||
test.ok(!call.isCompleted());
|
||||
|
||||
call.start(this.backoffFactory);
|
||||
test.ok(!call.isCompleted());
|
||||
|
||||
this.backoff.emit('ready');
|
||||
test.ok(call.isCompleted());
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"isAborted should return true once the call is aborted": function(test) {
|
||||
this.wrappedFn.
|
||||
onFirstCall().yields(new Error()).
|
||||
onSecondCall().yields(null, 'Success!');
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
|
||||
test.ok(!call.isAborted());
|
||||
call.abort();
|
||||
test.ok(call.isAborted());
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"setStrategy should overwrite the default strategy": function(test) {
|
||||
var replacementStrategy = {};
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
call.setStrategy(replacementStrategy);
|
||||
call.start(this.backoffFactory);
|
||||
test.ok(this.backoffFactory.calledWith(replacementStrategy),
|
||||
'User defined strategy should be used to instantiate ' +
|
||||
'the backoff instance.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"setStrategy should throw if the call is in progress": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
call.start(this.backoffFactory);
|
||||
test.throws(function() {
|
||||
call.setStrategy({});
|
||||
}, /in progress/);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"failAfter should not be set by default": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
call.start(this.backoffFactory);
|
||||
test.equal(0, this.backoff.failAfter.callCount);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"failAfter should be used as the maximum number of backoffs": function(test) {
|
||||
var failAfterValue = 99;
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
call.failAfter(failAfterValue);
|
||||
call.start(this.backoffFactory);
|
||||
test.ok(this.backoff.failAfter.calledWith(failAfterValue),
|
||||
'User defined maximum number of backoffs shoud be ' +
|
||||
'used to configure the backoff instance.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"failAfter should throw if the call is in progress": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
call.start(this.backoffFactory);
|
||||
test.throws(function() {
|
||||
call.failAfter(1234);
|
||||
}, /in progress/);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"start shouldn't allow overlapping invocation": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
var backoffFactory = this.backoffFactory;
|
||||
|
||||
call.start(backoffFactory);
|
||||
test.throws(function() {
|
||||
call.start(backoffFactory);
|
||||
}, /already started/);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"start shouldn't allow invocation of aborted call": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
var backoffFactory = this.backoffFactory;
|
||||
|
||||
call.abort();
|
||||
test.throws(function() {
|
||||
call.start(backoffFactory);
|
||||
}, /aborted/);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"call should forward its arguments to the wrapped function": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 2, 3], this.callback);
|
||||
call.start(this.backoffFactory);
|
||||
test.ok(this.wrappedFn.calledWith(1, 2, 3));
|
||||
test.done();
|
||||
},
|
||||
|
||||
"call should complete when the wrapped function succeeds": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 2, 3], this.callback);
|
||||
this.wrappedFn.
|
||||
onCall(0).yields(new Error()).
|
||||
onCall(1).yields(new Error()).
|
||||
onCall(2).yields(new Error()).
|
||||
onCall(3).yields(null, 'Success!');
|
||||
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
for (var i = 0; i < 2; i++) {
|
||||
this.backoff.emit('ready');
|
||||
}
|
||||
|
||||
test.equals(this.callback.callCount, 0);
|
||||
this.backoff.emit('ready');
|
||||
|
||||
test.ok(this.callback.calledWith(null, 'Success!'));
|
||||
test.ok(this.wrappedFn.alwaysCalledWith(1, 2, 3));
|
||||
test.done();
|
||||
},
|
||||
|
||||
"call should fail when the backoff limit is reached": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 2, 3], this.callback);
|
||||
var error = new Error();
|
||||
this.wrappedFn.yields(error);
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
for (var i = 0; i < 3; i++) {
|
||||
this.backoff.emit('ready');
|
||||
}
|
||||
|
||||
test.equals(this.callback.callCount, 0);
|
||||
|
||||
this.backoff.emit('fail');
|
||||
|
||||
test.ok(this.callback.calledWith(error));
|
||||
test.ok(this.wrappedFn.alwaysCalledWith(1, 2, 3));
|
||||
test.done();
|
||||
},
|
||||
|
||||
"call should fail when the retry predicate returns false": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 2, 3], this.callback);
|
||||
call.retryIf(function(err) { return err.retriable; });
|
||||
|
||||
var retriableError = new Error();
|
||||
retriableError.retriable = true;
|
||||
|
||||
var fatalError = new Error();
|
||||
fatalError.retriable = false;
|
||||
|
||||
this.wrappedFn.
|
||||
onCall(0).yields(retriableError).
|
||||
onCall(1).yields(retriableError).
|
||||
onCall(2).yields(fatalError);
|
||||
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
for (var i = 0; i < 2; i++) {
|
||||
this.backoff.emit('ready');
|
||||
}
|
||||
|
||||
test.equals(this.callback.callCount, 1);
|
||||
test.ok(this.callback.calledWith(fatalError));
|
||||
test.ok(this.wrappedFn.alwaysCalledWith(1, 2, 3));
|
||||
test.done();
|
||||
},
|
||||
|
||||
"wrapped function's callback shouldn't be called after abort": function(test) {
|
||||
var call = new FunctionCall(function(callback) {
|
||||
call.abort(); // Abort in middle of wrapped function's execution.
|
||||
callback(null, 'ok');
|
||||
}, [], this.callback);
|
||||
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
test.equals(this.callback.callCount, 1,
|
||||
'Wrapped function\'s callback shouldn\'t be called after abort.');
|
||||
test.ok(this.callback.calledWithMatch(sinon.match(function (err) {
|
||||
return !!err.message.match(/Backoff aborted/);
|
||||
}, "abort error")));
|
||||
test.done();
|
||||
},
|
||||
|
||||
"abort event is emitted once when abort is called": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
this.wrappedFn.yields(new Error());
|
||||
var callEventSpy = sinon.spy();
|
||||
|
||||
call.on('abort', callEventSpy);
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
call.abort();
|
||||
call.abort();
|
||||
call.abort();
|
||||
|
||||
test.equals(callEventSpy.callCount, 1);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"getLastResult should return the last intermediary result": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
this.wrappedFn.yields(1);
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
for (var i = 2; i < 5; i++) {
|
||||
this.wrappedFn.yields(i);
|
||||
this.backoff.emit('ready');
|
||||
test.deepEqual([i], call.getLastResult());
|
||||
}
|
||||
|
||||
this.wrappedFn.yields(null);
|
||||
this.backoff.emit('ready');
|
||||
test.deepEqual([null], call.getLastResult());
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"getNumRetries should return the number of retries": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [], this.callback);
|
||||
|
||||
this.wrappedFn.yields(1);
|
||||
call.start(this.backoffFactory);
|
||||
// The inital call doesn't count as a retry.
|
||||
test.equals(0, call.getNumRetries());
|
||||
|
||||
for (var i = 2; i < 5; i++) {
|
||||
this.wrappedFn.yields(i);
|
||||
this.backoff.emit('ready');
|
||||
test.equals(i - 1, call.getNumRetries());
|
||||
}
|
||||
|
||||
this.wrappedFn.yields(null);
|
||||
this.backoff.emit('ready');
|
||||
test.equals(4, call.getNumRetries());
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
"wrapped function's errors should be propagated": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 2, 3], this.callback);
|
||||
this.wrappedFn.throws(new Error());
|
||||
test.throws(function() {
|
||||
call.start(this.backoffFactory);
|
||||
}, Error);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"wrapped callback's errors should be propagated": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 2, 3], this.callback);
|
||||
this.wrappedFn.yields(null, 'Success!');
|
||||
this.callback.throws(new Error());
|
||||
test.throws(function() {
|
||||
call.start(this.backoffFactory);
|
||||
}, Error);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"call event should be emitted when wrapped function gets called": function(test) {
|
||||
this.wrappedFn.yields(1);
|
||||
var callEventSpy = sinon.spy();
|
||||
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 'two'], this.callback);
|
||||
call.on('call', callEventSpy);
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
for (var i = 1; i < 5; i++) {
|
||||
this.backoff.emit('ready');
|
||||
}
|
||||
|
||||
test.equal(5, callEventSpy.callCount,
|
||||
'The call event should have been emitted 5 times.');
|
||||
test.deepEqual([1, 'two'], callEventSpy.getCall(0).args,
|
||||
'The call event should carry function\'s args.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"callback event should be emitted when callback is called": function(test) {
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 'two'], this.callback);
|
||||
var callbackSpy = sinon.spy();
|
||||
call.on('callback', callbackSpy);
|
||||
|
||||
this.wrappedFn.yields('error');
|
||||
call.start(this.backoffFactory);
|
||||
|
||||
this.wrappedFn.yields(null, 'done');
|
||||
this.backoff.emit('ready');
|
||||
|
||||
test.equal(2, callbackSpy.callCount,
|
||||
'Callback event should have been emitted 2 times.');
|
||||
test.deepEqual(['error'], callbackSpy.firstCall.args,
|
||||
'First callback event should carry first call\'s results.');
|
||||
test.deepEqual([null, 'done'], callbackSpy.secondCall.args,
|
||||
'Second callback event should carry second call\'s results.');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"backoff event should be emitted on backoff start": function(test) {
|
||||
var err = new Error('backoff event error');
|
||||
var call = new FunctionCall(this.wrappedFn, [1, 'two'], this.callback);
|
||||
var backoffSpy = sinon.spy();
|
||||
|
||||
call.on('backoff', backoffSpy);
|
||||
|
||||
this.wrappedFn.yields(err);
|
||||
call.start(this.backoffFactory);
|
||||
this.backoff.emit('backoff', 3, 1234, err);
|
||||
|
||||
test.ok(this.backoff.backoff.calledWith(err),
|
||||
'The backoff instance should have been called with the error.');
|
||||
test.equal(1, backoffSpy.callCount,
|
||||
'Backoff event should have been emitted 1 time.');
|
||||
test.deepEqual([3, 1234, err], backoffSpy.firstCall.args,
|
||||
'Backoff event should carry the backoff number, delay and error.');
|
||||
test.done();
|
||||
}
|
||||
};
|
707
node_modules/buefy/CHANGELOG.md
generated
vendored
Normal file
707
node_modules/buefy/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,707 @@
|
||||
# Buefy Changelog
|
||||
|
||||
## 0.7.5
|
||||
|
||||
* **New component: Numberinput**, [see docs](https://buefy.org/documentation/numberinput)
|
||||
* **Loading improved**: can show a custom content, [see docs](https://buefy.org/documentation/loading)
|
||||
* Add ``destroy-on-hide`` prop to tabs
|
||||
* Add ``custom-detail-row`` prop to table
|
||||
* Add ``open-on-focus`` prop and improved accessibility for datepicker (thanks @imfaber)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix #1320 space keydown on Firefox to checkbox and switch
|
||||
* Fix #1325 input emit to upload
|
||||
* Enable native timepicker to clockpicker when ``mobile-native`` (default ``true``)
|
||||
* Fix clockpicker docs and input size
|
||||
* Fix upload opening in IE 11
|
||||
|
||||
## 0.7.4
|
||||
|
||||
### New features
|
||||
|
||||
* **New component: Button**, [see docs](https://buefy.org/documentation/button)
|
||||
* **New component: Clockpicker**, [see docs](https://buefy.org/documentation/clockpicker) (thanks @SharpSeeEr)
|
||||
* **Notification improved**: can show a notification programmatically, [see docs](https://buefy.org/documentation/notification)
|
||||
* Add ``custom-formatter`` prop to autocomplete
|
||||
* Add ``draggable`` prop to table (thanks @suneab)
|
||||
* Improve accessibility for notification, message and pagination (thanks @mateuswetah)
|
||||
|
||||
### Fixes
|
||||
|
||||
* #956 Fix hidden overflow on tabs (thanks @Baggs)
|
||||
* #1246 Fix Cleave.js example using Vue 2.6.x (thanks @yxngl)
|
||||
* #1251 Fix Datepicker closing when page back to ``min-date`` month
|
||||
* #1257 Fix Datepicker slow/freeze on big year input
|
||||
* #1282 Fix Datepicker event display wich have a time set (thanks @DonNicoJs)
|
||||
* #1290 Fix double click event for CheckBox(Button) and Radio(Button) (thanks @yxngl)
|
||||
* Fix tabindex on switch (thanks @yxngl), radio (thanks @Sacmanxman2) and checkbox
|
||||
|
||||
## 0.7.3
|
||||
|
||||
### New features
|
||||
|
||||
* **Update Bulma to 0.7.4**
|
||||
* Add ``required`` prop to radio-button and checkbox-button
|
||||
* Add ``defaultModalCanCancel`` constructor options (thanks @quimarche)
|
||||
* Add ``typing`` event to autocomplete (thanks @adrlen)
|
||||
* Add ``native-autocomplete`` prop to taginput
|
||||
* Add support to [Font Awesome SVG component](https://www.npmjs.com/package/@fortawesome/vue-fontawesome) (thanks @rhwilr)
|
||||
* Add ``custom-key-row`` prop to table
|
||||
* Add ``defaultToastPosition`` and ``defaultSnackbarPosition`` constructor options
|
||||
* Improve accessibility for collapse and dropdown (thanks @mateuswetah)
|
||||
* Revert tab as confirm key code to taginput
|
||||
* #1233 Change left margin to right margin when spacing nested fields (thanks @yxngl)
|
||||
|
||||
### Fixes
|
||||
|
||||
* #1177 Fix IE/Edge datepicker content size
|
||||
* #1216 Fix reset v-model when upload cancel
|
||||
* #1219 Fix modal ``width`` prop (thanks @yxngl)
|
||||
|
||||
## 0.7.2
|
||||
|
||||
### New features
|
||||
|
||||
* Add ``header`` autocomplete slot to taginput
|
||||
* Add ``required`` prop to switch
|
||||
* Add ``mobile-sort-placeholder`` prop to table
|
||||
* Add ``contextmenu`` event to table (thanks @gps-dev)
|
||||
* Add ``show-detail-icon`` prop to table and toggle row detail programmatically (thanks @omer2500)
|
||||
* Add ``use-html5-validation`` prop to form components and ``defaultUseHtml5Validation`` constructor options (thanks @lukio3)
|
||||
* #1164 Disable selecting row on checkbox click when table is ``checkable``
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix taginput when ``allow-new`` is enabled
|
||||
* Fix pagination order when simple
|
||||
* #1126 Fix init sort using columns table prop
|
||||
* #898, #1154 Fix browser autocomplete using multiple fields
|
||||
|
||||
## 0.7.1
|
||||
|
||||
### New features
|
||||
|
||||
* **Update Bulma to 0.7.2**
|
||||
* Add ``indeterminate`` prop to checkbox (thanks @guanzo)
|
||||
* #1029 Upgrade vue-test-utils to latest version (thanks @lordfuoco)
|
||||
* #1065 Add tab as confirm key code to taginput (thanks @williamabbott)
|
||||
* #1083 Add ``date-creator`` prop to datepicker (thanks @jonagoldman)
|
||||
|
||||
### Fixes
|
||||
|
||||
* #1024 Fix upload SSR support
|
||||
* #1027 Fix ``icon-pack`` prop when individual components
|
||||
* #1040 Fix prevent radio with multi-line text from shrinking (thanks @rhwilr)
|
||||
* #1067 Fix IE 11 UI switch (thanks @patrickabkarian)
|
||||
* #1072 Fix sorting boolean fields
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Change path to import components to use outside main vue instance, like:
|
||||
```javascript
|
||||
// see Toast, Snackbar, Modal and Dialog doc pages for more examples
|
||||
import { Toast } from 'buefy/dist/components/toast'
|
||||
Toast.open('Toasty!')
|
||||
```
|
||||
* Upload component accepts a single `File` and `Array<File>` when multiple as ``v-model``
|
||||
* Rename ``readonly`` to ``editable`` on datepicker and timepicker (now just use the prop without false value)
|
||||
* **Removed Panel component**, it was deprecated since 0.5.3
|
||||
|
||||
### New features
|
||||
|
||||
* Add ``closable`` prop to taginput (thanks @adrlen)
|
||||
* #970 Add Object type to ``type`` prop of field and icon
|
||||
|
||||
### Fixes
|
||||
|
||||
* Updated timepicker style (it's a little smaller now)
|
||||
* #992 Fix table header disappear with pagination
|
||||
* #999 Fix ``size`` prop to datepicker and timepicker
|
||||
|
||||
## 0.6.7
|
||||
|
||||
### New features
|
||||
|
||||
* **Table improved**: can change columns dynamically
|
||||
* Add ``auto-close`` and ``duration`` props to message and notification
|
||||
* Add ``allow-duplicates`` prop to taginput
|
||||
* Add ``required`` prop to radio and checkbox
|
||||
* Add ``defaultInputHasCounter`` constructor options
|
||||
|
||||
### Fixes and changes
|
||||
|
||||
* #839 Fix ``icon-pack`` from icon to be reactive
|
||||
* #840 Fix loading position to tagInput (thanks @adrlen)
|
||||
* #852 Fix label class to field when horizontal
|
||||
* #872 Fix datepicker default formatter
|
||||
* #895 Fix loading overlay when not in full page (thanks @adrlen)
|
||||
* #927 Fix autocomplete when option text is too long (thanks @8bu)
|
||||
* #948 Fix switch when multi line text (thanks @rhwilr)
|
||||
|
||||
## 0.6.6
|
||||
|
||||
### New features
|
||||
|
||||
* **Update Bulma to 0.7.1**
|
||||
* Add ``header`` slot to autocomplete
|
||||
* Add ``type`` prop to checkbox and radio
|
||||
* Add ``on-paste-separators`` and ``before-adding`` props to tagInput
|
||||
* #830 Add ``ellipsis`` prop to tagInput and tag components
|
||||
|
||||
### Fixes and changes
|
||||
|
||||
* #746 Fix default ``dateFormatter`` function to datepicker
|
||||
* #755 Fix arrow centered when table detail (thanks @wanxe)
|
||||
* #787 Fix type in horizontal field when message is empty
|
||||
* #814 Reset scroll to modal before destroy
|
||||
* #481 Fix tagInput height to match other inputs
|
||||
|
||||
## 0.6.5
|
||||
|
||||
* Revert some changes on Checkbox, CheckboxButton, Radio, RadioButton, Select and Switch, working as before now
|
||||
* #711 Fix click event to switch (thanks @adrlen)
|
||||
* #712 Fix SSR support (thanks @anteriovieira)
|
||||
* #719 Fix ``header`` slot to tabItem
|
||||
* #718 Fix ``changeMonth`` and ``changeYear`` events to datepicker in ``change-month`` and ``change-year``
|
||||
* #727 Fix upload check file
|
||||
* #730 Fix field with addons not updating on re-render (tanks @arlen)
|
||||
|
||||
## 0.6.4
|
||||
|
||||
### New features
|
||||
|
||||
* **Add nuxt-buefy on docs**, [see here](https://buefy.org/#/documentation/start) (thanks @anteriovieira)
|
||||
* Add ``indefinite`` prop to snackbar
|
||||
* Add ``header`` slot to datepicker
|
||||
* Add ``header`` slot to tabItem
|
||||
* #485 Add ``custom-class`` prop to field (thanks @docnoe)
|
||||
* #509 Add autocomplete slot support to taginput (thanks @gkinsman)
|
||||
* #581 Add ``is-row-checkable`` prop to table (thanks @jvmonjo)
|
||||
* #602 Add ``changeMonth`` and ``changeYear`` events to datepicker
|
||||
* #604 Add ``remove-on-keys`` prop to taginput, allowing to remove last tag (thanks @adrlen)
|
||||
* #609 Add ``is-full-page`` prop to loading, to limit it to its container (thanks @adrlen)
|
||||
* #610 Add ``visible`` prop to tabItem
|
||||
* #644 Add ``clear-on-select`` prop to autocomplete (thanks @raniesantos)
|
||||
* #645 Add ``selectable-dates`` prop to datepicker (thanks @pip63)
|
||||
* #682 Add ``has-detailed-visible`` prop to table (thanks @wanxe)
|
||||
* #687 Add ``focus-on`` prop to dialog
|
||||
|
||||
### Fixes and changes
|
||||
|
||||
* #576 Fix upload check file type
|
||||
* #586 Fix dropdown change event
|
||||
* #593 Fix timepicker update only time of Date object
|
||||
* #599 Fix ``on-cancel`` prop to dialog, get called when clicking confirm
|
||||
* #648 Fix dropdown emit change event (thanks @adrlen)
|
||||
* #670 Fix tabs emit change event (thanks @adrlen)
|
||||
* #686 Remove 'is-light' color to cancel button of dialog
|
||||
|
||||
## 0.6.3
|
||||
|
||||
### New features
|
||||
|
||||
* **New extension: Sortable.js**, [see here](https://buefy.org/#/extensions/sortablejs)
|
||||
* **Update Bulma to 0.6.2**
|
||||
* **Add Font Awesome 5 support** (http://fontawesome.com/)
|
||||
* Add ``columns`` prop to table, you can now pass an array instead of adding scoped slots (for simple tables)
|
||||
* Add ``rounded`` prop to Input, Select, Autocomplete, Datepicker and Timepicker, Pagination
|
||||
* Add "is-toggle-rounded" type to Tabs
|
||||
* Add ``open`` prop to collapse ``trigger`` slot
|
||||
* Add ``native`` prop to upload
|
||||
* #222 Add ``open-on-focus`` prop to autocomplete (good to simulate a select element)
|
||||
* #482 Add ``allow-new`` prop to taginput
|
||||
* #483 Add ``unselectable-days-of-week`` prop to datepicker
|
||||
* #487 Add ``icon-size`` prop to message
|
||||
* #492 Add isAsc parameter to ``custom-sort`` function of table (thanks @frantic1048)
|
||||
* #494 Add ``unselectable-times`` prop to timepicker
|
||||
* #525 Add ``pagination-size`` prop to table (thanks @nateleavitt)
|
||||
* #531 Add ``confirm-key-codes`` prop to taginput
|
||||
|
||||
### Fixes and changes
|
||||
|
||||
* Remove ``max-results`` prop from autocomplete, it now has a scrollbar with all results
|
||||
* #493 Fix ``keep-first`` autocomplete prop with async data
|
||||
* #498 Fix horizontal field on mobile
|
||||
* #500 Fix message position for horizontal field (thanks @electrolinux)
|
||||
* #543 Fix dropdown toggle programmatic
|
||||
|
||||
## 0.6.2
|
||||
|
||||
### New features
|
||||
|
||||
* **New component: Tag Input**, [see docs](https://buefy.org/#/documentation/taginput) (thanks @jgerbes)
|
||||
* #125 Add ``queue`` prop to toast/snackbar and ``defaultNoticeQueue`` constructor option
|
||||
* Note that the animations aren't perfect right now
|
||||
* #432 **Datepicker improved**: can add event indicators on it (thanks @chasegiunta)
|
||||
* #439 Add support to horizontal field, with the ``horizontal`` prop (thanks @electrolinux)
|
||||
* Add ``mobile-native`` prop to datepicker and timepicker
|
||||
* Add ``defaultDatepickerMobileNative`` and ``defaultTimepickerMobileNative`` constructor options
|
||||
* Add ``events`` prop to modal (to bind events programmatically)
|
||||
* Add ``position`` prop to datepicker and timepicker
|
||||
* Add ``size`` prop to dialog
|
||||
* Add ``tabstop`` and ``disabled`` props to tag
|
||||
* Add ``.sync`` option to table ``current-page``
|
||||
|
||||
### Fixes and changes
|
||||
|
||||
* Maxlength counter for input only shows on focus
|
||||
* Add padding to tab content
|
||||
* Fix autocomplete with ``keep-first`` selecting on blur when nothing is shown
|
||||
* Fix tabs buttons size sometimes flickering
|
||||
* #416 Fix pagination color
|
||||
* #419 Fix input icon size
|
||||
* #428 Fix ``current-page`` from table to be reactive
|
||||
* #440 Fix upload input file width (thanks @frantic1048)
|
||||
|
||||
## 0.6.1
|
||||
|
||||
* #409 Fix notification delete button
|
||||
* #410 Fix alert triggering on upload
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Vue 2.5+ is now the minimum required version
|
||||
* Bulma breaking changes, [see changelog](https://github.com/jgthms/bulma/blob/master/CHANGELOG.md#breaking-changes)
|
||||
* **Removed** the deprecated prompt dialog ``inputPlaceholder``, ``inputName`` and ``inputMaxlength`` props
|
||||
* Buefy now uses [MDI icons from community](https://materialdesignicons.com/) instead, you'll have to change icon names and if you use a CDN you should change:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//cdn.materialdesignicons.com/2.0.46/css/materialdesignicons.min.css">
|
||||
```
|
||||
|
||||
### New features
|
||||
|
||||
* **New component: Timepicker**, [see docs](https://buefy.org/#/documentation/timepicker)
|
||||
* **New component: Checkbox Button**, [see docs](https://buefy.org/#/documentation/checkbox)
|
||||
* **New docs section: Extensions**, [see here](https://buefy.org/#/extensions/cleavejs)
|
||||
* Support for Bulma 0.6.1
|
||||
* Add ``disabled`` prop to tabItem
|
||||
* Add ``focusable`` prop to table
|
||||
* Add ``focus()`` method to table
|
||||
* Add ``hoverable`` prop to table
|
||||
* Add ``custom-size`` prop to icon
|
||||
* Add ``custom-class`` prop to icon
|
||||
* Add ``detail-key`` and ``opened-detailed`` props to table (thanks @wanxe)
|
||||
* Add ``scroll`` prop to modal/dialog (changes what to do with ``<body>`` scrollbar)
|
||||
* Add ``parent`` prop to modal, pass a Vue object to it to open component modal programmatically
|
||||
* #359 Add ``mobile-modal`` prop to dropdown to enable/disable modal on mobile
|
||||
* #365 Add ``src/scss/utils/_all.scss`` for easier modular importing (thanks @gwvt)
|
||||
* #377 Add support to MDI icons from community
|
||||
* #387 Add ``current-page`` prop to table (thanks @frantic1048)
|
||||
* #388 Add ``size`` prop to radio and checkbox
|
||||
* #398 Add ``unselectable-dates`` prop to datepicker to disable an array of dates
|
||||
* #399 Add configurable closing options for dialog (like modal)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Update tooltip font size and padding, it's a bit bigger now
|
||||
* Update table keyboard navigation, now doesn't require pressing enter and only works when ``focusable``
|
||||
* #288 Fix input message from parent field (thanks @yarbshk)
|
||||
* #358 Fix modal/dialog shifting content (``scroll`` prop)
|
||||
* #380 Fix clearing autocomplete input
|
||||
* #395 Fix ref dropdown availability (thanks @frantic1048)
|
||||
|
||||
## 0.5.4
|
||||
|
||||
* **Deprecated** prompt dialog ``inputPlaceholder``, ``inputName`` and ``inputMaxlength`` props, use new ``inputAttrs`` prop, [see docs](https://buefy.org/#/documentation/dialog)
|
||||
* Fix ``focus`` method on select
|
||||
* Table with ``selected`` prop can now be natigated with keyboard
|
||||
* #251, #345 Add ``bottom-left`` slot to table
|
||||
* #334 Add ``defaultDialogConfirmText`` and ``defaultDialogCancelText`` constructor options
|
||||
* #335 Add ``icon`` and ``iconPack`` prop to dialog
|
||||
* #350 Add Function type to ``component`` prop of modal (thanks @ivalkenburg)
|
||||
* #354 Add tab key press to autocomplete (thanks @tmepple)
|
||||
* #356 Fix table header alignment
|
||||
|
||||
## 0.5.3
|
||||
|
||||
* **New component: Collapse**, [see docs](https://buefy.org/#/documentation/collapse)
|
||||
* **Panel deprecated**, use new Collapse component, [old docs here](https://buefy.org/#/documentation/panel)
|
||||
* Update Bulma to v0.5.3
|
||||
* #223 Add ``footer`` slot to table
|
||||
* #246 Remove ``key`` on detailed rows of table component (thanks @Tirke)
|
||||
* #301 Fix Bulma style override for radio and checkbox
|
||||
* #303 Fix dropdown close on custom item when is replaced or changed
|
||||
* #305 Fix datepicker calendar display when disabled and inline
|
||||
* #309 Add ``labelFor`` prop to field component, to set native ``for`` attribute to the label tag (thanks @tmepple)
|
||||
* #314 Set pack prop to next/prev icon buttons for datepicker
|
||||
* #315 Fix escape regexp characters to autocomplete
|
||||
* #316 Fix checkbox shrinking when text is very long (thanks @Tirke)
|
||||
* #317 Add default datepicker constructor options
|
||||
* #324 Fix table broken sort state
|
||||
* #330 Fix table empty and detail disposition
|
||||
* #339 Fix upload warning when is required
|
||||
* #340 Add ``size`` prop to radio button
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* #262 Add ``empty`` slot to autocomplete (empty message)
|
||||
* #264 Add ``has-counter`` prop to input, add it when you want show or hide character counter when maxlength prop is passed
|
||||
* #265 Fix disabled pagination (thanks @YassinOuider)
|
||||
* #272 Add ``readonly`` prop to allow typing a date on datepicker
|
||||
* #273 Fix autocomplete for SSR (thanks @LANSELOT)
|
||||
* #276 Add ``first-day-of-week`` prop to datepicker
|
||||
* #279 Fix table not default sorting async data
|
||||
* #289 Fix dropdown-trigger container html tag
|
||||
* #291 Add configurable closing options for Modal (thanks @jwahdatehagh)
|
||||
* #298 Fix mobile detection datepicker for SSR
|
||||
* #302 Fix datepicker calendar display when disabled
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* **New component: Datepicker**, [see docs](https://buefy.org/#/documentation/datepicker) (thanks @bartboy011)
|
||||
* **New component: Tag**, [see docs](https://buefy.org/#/documentation/tag)
|
||||
* #195 Add ``custom-key`` prop to table column, add it when you want a column without label
|
||||
* #221 Add backend pagination support to table (thanks @cappuc)
|
||||
* #214 Add ``active`` prop to tooltip
|
||||
* #215 Add ``header`` slot to table (custom headers)
|
||||
* #228 Fix table checked rows not working on mobile
|
||||
* #235 Add ``custom-is-checked`` prop to table column, add it when you want a custom compare function when is checkable
|
||||
* #237 Fix emit blur event for input
|
||||
* #239 Fix table columns on v-for loop
|
||||
* #241 Fix remove tabItem when it's bounded to array
|
||||
* #242 Update required Vue.js version (2.4+) (thanks @iwan-wijaya)
|
||||
* #243 Add ``default-sort-direction`` prop to table, add it when you want change default sort direction on the first click
|
||||
* #260 Fix radio/radio button emitting ``input`` multiple times (thanks @frantic1048)
|
||||
* Add ``meta`` prop to table column, useful for custom headers
|
||||
* Add ``type`` prop to switch (thanks @Tirke)
|
||||
* Add ``multiple`` support to select
|
||||
* Add ``inline`` prop to dropdown, items are shown inline and trigger removed
|
||||
* Remove ``has-custom-template`` prop from autocomplete, just use scoped slot to have the same feature
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* **Update Bulma to v0.5.1**, changes on Sass variables naming, [see docs](https://github.com/jgthms/bulma/blob/master/CHANGELOG.md#050)
|
||||
* Buefy Sass variables are also following the new convention
|
||||
* **Removed Menu component**, it was experimental and wasn't good enough, needed too much to work and can easily be replaced with pure HTML
|
||||
* Constructor option ``defaultContentElement`` renamed to ``defaultContainerElement``
|
||||
* ``b-dropdown-option`` renamed to ``b-dropdown-item``
|
||||
* ``subheader`` prop renamed to ``custom``
|
||||
* Any attributes on Input, Select and Autocomplete will be added directly to ``<input>`` or ``<select>`` itself instead of the root element
|
||||
* ``change`` events for all form controls (Input, Select Autocomplete, Checkbox, RadioGroup, Switch) that returned pure value will now return ``$event`` (and require ``.native`` modifier), use ``input`` instead
|
||||
* Checkbox ``custom-value`` prop renamed to ``native-value``
|
||||
* ``checked`` prop removed
|
||||
* **Removed CheckboxGroup**, just add the same ``v-model`` to multiple Checkboxes and set a ``native-value``, [see docs](https://buefy.org/#/documentation/checkbox)
|
||||
* Radio and Radio Button ``value`` prop renamed to ``native-value``
|
||||
* Add ``v-model`` support
|
||||
* Radio Buttons have to be wrapped on a field
|
||||
* **Removed RadioGroup**, just add the same ``v-model`` to multiple Radios/RadioButtons and set a ``native-value`` [see docs](https://buefy.org/#/documentation/radio)
|
||||
* Remove switch ``checked`` prop
|
||||
|
||||
### New stuff
|
||||
|
||||
* **New component: Upload**, [see docs](https://buefy.org/#/documentation/upload) (thanks @jtommy)
|
||||
* Field ``position`` prop works for ``grouped`` fields
|
||||
* Add ``group-multiline`` prop to field
|
||||
* Add ``size`` prop to message
|
||||
* #191 Add detail option (collapse) to table row, [see docs](https://buefy.org/#/documentation/table) (thanks @wanxe)
|
||||
* #201 Add support to array on Field ``message`` prop (thanks @jtommy)
|
||||
* #207 Add ``centered`` prop to table column
|
||||
* Add ``native-value``, ``true-value`` and ``false-value`` props to switch
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* #206 Fix radio and checkbox within ``v-for``
|
||||
|
||||
## 0.4.6
|
||||
|
||||
* **New component: Menu**, [see docs](https://buefy.org/#/documentation/menu) (thanks @tsctao)
|
||||
* **New component: Panel**, [see docs](https://buefy.org/#/documentation/panel) (thanks @jtommy)
|
||||
* **New component: Loading**, [see docs](https://buefy.org/#/documentation/loading) (thanks @jtommy)
|
||||
* **Dropdown improved**: can add any content on it, can be triggered by hover, [see docs](https://buefy.org/#/documentation/dropdown)
|
||||
* Remove ``narrowed`` prop from dropdown
|
||||
* Update Bulma to v0.4.4
|
||||
* Add CDN install method and JSFiddle examples
|
||||
* Add boolean ``addons`` prop to field
|
||||
* Fix message and notification inside ``.media`` element
|
||||
* Fix pagination current page to not be clickable (thanks @jtommy)
|
||||
* #118 Add Nuxt.js installation on docs
|
||||
* #171 Fix modal not taking full width on mobile
|
||||
* #182 Fix table not default sorting async data (thanks @jtommy)
|
||||
* #184 Add ``input`` event on docs (input/autocomplete)
|
||||
* #190 Add Vue.js required version on docs
|
||||
* #197 Fix autocomplete ``expanded`` prop not working correctly
|
||||
|
||||
## 0.4.5
|
||||
|
||||
* Update Bulma to v0.4.3
|
||||
* Page is now clipped when a modal/dialog is active (to avoid weird scroll behavior)
|
||||
* Update modal docs example to not use the ``component`` prop, works better for events and is more common — Old way is not deprecated
|
||||
* Remove programmatic component modal from docs since isn't a good practice and was causing too many issues
|
||||
* Fix autocomplete ``focus()`` method
|
||||
* #106 Fix prompt dialog vue-warning
|
||||
* #144 Add ``rows`` prop to input (textarea)
|
||||
* #145 Fix autocomplete not preventing form from submitting (thanks @jtommy)
|
||||
* #153 Add return for ``checkHtml5Validity()`` method
|
||||
* #155 Fix input/autocomplete ``change`` event (thanks @jtommy)
|
||||
* #157 Fix table redundant level element generating extra padding
|
||||
* #159 Fix modal with ``.modal-card`` responsiveness, added a ``has-modal-card`` prop
|
||||
* #165 Fix safari button alignment on dialog (thanks @jtommy)
|
||||
* #154 Add prop for when table data is empty (thanks @jtommy)
|
||||
* #170 Fix dialogs min-width mobile
|
||||
|
||||
## 0.4.4
|
||||
|
||||
* #139 Fix notices durations and constructor options
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* Update switch animation (it was laggy) and causing weird behavior within ``<keep-alive>`` components, [see updated animation](https://buefy.org/#/documentation/switch)
|
||||
* Add tons of props to Autocomplete, [see here](https://buefy.org/#/documentation/autocomplete)
|
||||
* **Dropdown button as addon now needs a ``.control`` element wrapping**
|
||||
* Add some useful methods on docs for Input, Select, Autocomplete and Table
|
||||
* Fix autocomplete list width
|
||||
* #38 Add ``animation`` prop for dialog and modal, for custom animation (transition name)
|
||||
* #115 Add ``row-class`` property to table to style row status, e.g.:
|
||||
|
||||
```html
|
||||
<b-table :data="tableData" :row-class="row => row.amount < 10 && 'is-warning'">[...]</b-table>
|
||||
```
|
||||
|
||||
* #117 Fix table row loop missing ``key`` prop
|
||||
* #122 Fix async tab-items
|
||||
* #124 Toast, Dialog, Snackbar and Programmatic Modal exposed
|
||||
* #128 Add default notices duration constructor options (thanks @quimarche)
|
||||
* #130 Fix checkbox/switch not emitting change event when using keyboard (thanks @gongzza)
|
||||
* #132 Add dropdown ``active-change`` event to know when it's dropdown list is active/visible (thanks @bartboy011)
|
||||
* #134 Add ``true-value`` and ``false-value`` props to checkbox
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* Fix Buefy installation
|
||||
|
||||
## 0.4.1
|
||||
|
||||
* Fix table sorting null values
|
||||
* Table null values always come last when sorting
|
||||
* Add icon support to select
|
||||
* Fix dropdown to not stay on top of trigger
|
||||
* Fix switch disable state
|
||||
* Add click events for dropdown option
|
||||
* Fix dropdown disable state
|
||||
* Fix table columns not being reactive
|
||||
* #90 Fix tabs with long elements (thanks @mirshko)
|
||||
* #91 Update Bulma to v0.4.2
|
||||
* #96 Add ``visible`` prop to table column
|
||||
* #102 Fix anchor tag / router-link on dropdown
|
||||
* #104 Fix numeric zero values on input's maxlength (thanks @iwan-wijaya)
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### I've broke some stuff...
|
||||
|
||||
* Remove ``label``, ``icon`` and ``icon-pack`` properties from **DropdownOption** thanks to the new syntax, [see docs](https://buefy.org/#/documentation/dropdown)
|
||||
* Remove ``content`` property from **TableColumn**, use ``v-html`` on an element inside TableColumn instead
|
||||
* **Field**, **Snackbar** and **Toast** ``position`` property now needs the ``is-`` prefix (eg. ``is-top-left`` or ``is-centered``) — *Gotta fix these inconsistencies while it's still in beta*
|
||||
* Remove ``on-off`` prop from Switch
|
||||
|
||||
### Additions and fixes
|
||||
|
||||
* **New component: Autocomplete**, [see docs](https://buefy.org/#/documentation/autocomplete)
|
||||
* **Switch design overhaul**, [see new style](https://buefy.org/#/documentation/switch)
|
||||
* Fix Tabs dynamic height
|
||||
* Add one more Sass variable: ``$speed-slower: 250ms !default``
|
||||
* Add ``size`` prop to Switch
|
||||
* Add ``.sync`` modifier to Pagination ``current`` prop
|
||||
* Add ``active`` property and changed animations of Notification and Message
|
||||
* Add Dropdown within nav example
|
||||
* All selections control (Checkbox, Radio, RadioButton and Switch) can now be focused and changed by keyboard
|
||||
* #69 Add loading state to Table
|
||||
* #71 Add background for checked rows on Table (thanks @mikejavier)
|
||||
* #72 Fix Table overflow
|
||||
* #74 Fix DropdownOption slots, can customize with HTML now
|
||||
* #76 Modal close event accepts parameters (thanks @gongzza)
|
||||
* #77 Add index to Table scoped slot (thanks @UrVerySpecial)
|
||||
* #78 Fix Table sorting zero values (thanks @gwvt)
|
||||
* #82 Fix Select with numeric zero value
|
||||
|
||||
## 0.3.2
|
||||
|
||||
* **New component: Tabs**, [see docs](https://buefy.org/#/documentation/tabs)
|
||||
* Add ``content`` prop to TableColumn, use this instead of ``v-html`` or it might break on tables with ``mobile-cards`` (collapsed rows)
|
||||
* Alert Dialog accepts string as well
|
||||
* Dialog open with focus on confirm button (easier to just hit enter)
|
||||
* Modal can be used in template as well (non programmatic)
|
||||
* Table automatically scrolls if overflowed
|
||||
* #62 Add sort direction with Table ``mobile-cards``
|
||||
* #67 Fix Table sort null values
|
||||
|
||||
## 0.3.1
|
||||
|
||||
* Field ``grouped`` now also works on nested Fields
|
||||
* Add Modal props
|
||||
* Fix all animations
|
||||
* Fix row click error
|
||||
* Fix ``.sync`` modifier
|
||||
* #56 Fix selection controls initial state always false
|
||||
* #58 Fix Table ``checked-rows`` prop not updating on Chrome
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Modal
|
||||
|
||||
Show any content you want in a modal programatically, like an image:
|
||||
|
||||
```javascript
|
||||
this.$modal.open(
|
||||
`<p class="image is-4by3">
|
||||
<img src="./static/placeholder-1280x960.png">
|
||||
</p>`
|
||||
)
|
||||
```
|
||||
|
||||
or a component:
|
||||
|
||||
```javascript
|
||||
import CustomComponent from './components/CustomComponent'
|
||||
|
||||
this.$modal.open({
|
||||
component: CustomComponent
|
||||
})
|
||||
```
|
||||
|
||||
### Table
|
||||
|
||||
**Breakable changes on it**, now requires a scoped slot to wrap the columns, and a slot inside the column. You have now full control over the content of cells:
|
||||
|
||||
```html
|
||||
<b-table :data="data">
|
||||
<template scope="props">
|
||||
<b-table-column field="id" label="ID" sortable numeric>
|
||||
{{ props.row.id }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="user.first_name" label="First Name" sortable>
|
||||
{{ props.row.user.first_name }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="date" label="Date" sortable
|
||||
v-html="formatDate(props.row.date)">
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="gender" label="Gender">
|
||||
<b-icon
|
||||
pack="fa"
|
||||
:icon="props.row.gender === 'Male' ? 'mars' : 'venus'">
|
||||
</b-icon>
|
||||
{{ props.row.gender }}
|
||||
</b-table-column>
|
||||
</template>
|
||||
</b-table>
|
||||
```
|
||||
* Prop ``selectable`` renamed to ``selected`` and expects an Object, if you have Vuejs v2.3+ you can use the ``.sync`` modifier to make it two-way binding:
|
||||
|
||||
```html
|
||||
<b-table :data="data" :selected.sync="selectedRow">
|
||||
```
|
||||
|
||||
is the same as:
|
||||
|
||||
```html
|
||||
<b-table :data="data" :selected="selectedRow" @select="row => selectedRow = row">
|
||||
```
|
||||
|
||||
* Table new prop ``checked-rows`` that expects an Array, if you have Vuejs v2.3+ you can use the ``.sync`` modifier to make it two-way binding
|
||||
* Table ``render-html`` prop removed thanks to the new syntax
|
||||
* Column ``component`` prop removed thanks to the new syntax
|
||||
* Column ``field`` prop now accepts nested object keys
|
||||
|
||||
### Other
|
||||
|
||||
* **Breaking:** Select ``b-option`` is now only ``option``
|
||||
* **Breaking:** Dropdown ``b-option`` is now ``b-dropdown-option``
|
||||
* Fix Dropdown background overlay index
|
||||
* #43 Fix Dialog cancel button focus state
|
||||
* #50 Add ``page-change`` event on Table
|
||||
* #52 Fix Select option
|
||||
* #53 Add ``type=button`` to notifications
|
||||
|
||||
## 0.2.2
|
||||
|
||||
* Update Vue to 2.2.6
|
||||
* Update Bulma to 0.4.1
|
||||
* #35 Fix Dropdown TypeError
|
||||
* #29, #39 Fix SSR
|
||||
* #42 Fix Table ``default-sort`` prop
|
||||
* #40 Select now use native select, removed ``searchable`` property
|
||||
|
||||
## 0.2.1
|
||||
|
||||
* Add ``loading`` property to Select
|
||||
* Fix Checkbox disabled style
|
||||
* Fix Input not being validated when v-model is updated
|
||||
* Fix Input ``loading`` overlapping other icons
|
||||
* Fix Input ``password-reveal`` icon being overlapped by Field ``type`` icon
|
||||
* #23 Fix Select with addons overflowing
|
||||
* #30 Fix Table ``backend-sorting`` resetting sorted column
|
||||
* #33 Fix Input and Select on-blur listener removing user-defined Field ``type`` and ``message``
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* **New component: Select**
|
||||
* **New component: Dropdown**
|
||||
* **Breaking:** Rename Table property ``html`` to ``render-html``
|
||||
* Fix Pagination buttons messing up at pages 3 and 4
|
||||
* Fix Dialog keeping keyup event
|
||||
* Fix prompt Dialog not validating before confirming
|
||||
* #6 Fix docs not working on IE. Thanks to [AngelMunoz](https://github.com/AngelMunoz)!
|
||||
* #9 Fix Table ``bordered`` sorted column
|
||||
* #10 Add Table ``backend-sorting`` property and ``sort`` event
|
||||
* #14 Add ``component`` property on Table. Thanks to [korpa](https://github.com/korpa)!
|
||||
|
||||
## 0.1.5
|
||||
|
||||
* Fix #12
|
||||
* Refactored Notification and Message
|
||||
* Add animation when closing Notification and Message
|
||||
|
||||
## 0.1.4
|
||||
|
||||
* Fix #5 — now serving compiled files
|
||||
* Fix #6 (partially) — docs now working on Edge
|
||||
* Add "UI Elements" on docs to specify that the user can use anything from Bulma
|
||||
* Redone the construtor options structure to work with the compiled build
|
||||
|
||||
## 0.1.2
|
||||
|
||||
* Fix Switch two-way data binding not working correctly
|
||||
* Fix Radio animation not working properly
|
||||
* Fix #2 — select arrow misplaced
|
||||
* Fix Input's help message overlapping maxlength's counter
|
||||
* Fix Table column sorting — should start with ASC
|
||||
* Fix Table mobile sorting not working
|
||||
|
||||
## 0.1.1
|
||||
|
||||
* Fix #1 — ``lib`` folder not published
|
||||
|
||||
## 0.1.0
|
||||
|
||||
* **New component: Input**
|
||||
* **New component: Field**
|
||||
* Documentation done
|
||||
|
||||
## 0.0.3
|
||||
|
||||
* **New component: Message**
|
||||
* **New component: Tooltip**
|
||||
* **New component: Dialog**
|
||||
* Add size option to Pagination
|
||||
* Notification slightly modified to keep original Bulma style
|
||||
* Toasts and Snackbars now queue between each other
|
||||
* Toast duration reduced to 2s
|
||||
|
||||
## 0.0.2
|
||||
|
||||
* **New component: Pagination**
|
||||
* **Component rework: Notify is now Snackbar**
|
||||
* Table now uses the Pagination component
|
||||
* Toasts are now queued
|
||||
* Option to load components individually
|
21
node_modules/buefy/LICENSE
generated
vendored
Normal file
21
node_modules/buefy/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2019 Rafael Beraldo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
120
node_modules/buefy/README.md
generated
vendored
Normal file
120
node_modules/buefy/README.md
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
<p align="center">
|
||||
<a href="https://buefy.org">
|
||||
<img src="https://raw.githubusercontent.com/buefy/buefy/master/static/img/buefy-banner.png" />
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/buefy"><img src="https://img.shields.io/npm/v/buefy.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/buefy"><img src="https://img.shields.io/npm/dt/buefy.svg" /></a>
|
||||
<a href="https://circleci.com/gh/buefy/buefy"><img src="https://img.shields.io/circleci/project/github/buefy/buefy.svg?style=flat-square" /></a>
|
||||
<a href="https://codecov.io/gh/buefy/buefy"><img src="https://img.shields.io/codecov/c/github/buefy/buefy.svg?style=flat-square" /></a>
|
||||
<a href="https://www.npmjs.com/package/buefy"><img src="https://img.shields.io/npm/l/buefy.svg" /></a>
|
||||
<a href="https://discordapp.com/invite/ZkdFJMr"><img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" /></a>
|
||||
<a href="https://buefy.org"><img src="https://img.shields.io/badge/code_style-buefy-7957d5.svg?style=flat-square" /></a>
|
||||
</p>
|
||||
|
||||
> Buefy is a lightweight library of responsive UI components for [Vue.js](https://vuejs.org/) based on [Bulma](http://bulma.io/) framework and design.
|
||||
|
||||
## Features
|
||||
|
||||
* Keep your current Bulma theme / variables easily
|
||||
* Supports both [Material Design Icons](https://materialdesignicons.com/) and [FontAwesome](http://fontawesome.io/)
|
||||
* Very lightweight with none internal dependencies aside from Vue & Bulma
|
||||
* About 60KB min+gzip (with Bulma included)
|
||||
* Semantic code output
|
||||
* Follows Bulma design and some of the [Material Design UX](https://material.io/)
|
||||
* Focus on usability and performance without *over-animating* stuff
|
||||
|
||||
## Documentation
|
||||
|
||||
The documentation is in the docs directory, it serves as the demo as well.
|
||||
|
||||
Browse [online documentation here](https://buefy.org/).
|
||||
|
||||
## Quick start
|
||||
|
||||
You need [Vue.js](https://vuejs.org/) **version 2.5+**.
|
||||
|
||||
### 1 Install via npm
|
||||
|
||||
```bash
|
||||
npm install buefy
|
||||
```
|
||||
|
||||
### 2 Import and use Buefy
|
||||
|
||||
Bundle
|
||||
```javascript
|
||||
import Vue from 'vue';
|
||||
import Buefy from 'buefy';
|
||||
import 'buefy/dist/buefy.css';
|
||||
|
||||
Vue.use(Buefy);
|
||||
|
||||
```
|
||||
or Individual Components
|
||||
```javascript
|
||||
|
||||
import Vue from 'vue'
|
||||
import { Field, Input } from 'buefy/dist/components'
|
||||
import 'buefy/dist/buefy.css'
|
||||
|
||||
Vue.use(Field)
|
||||
Vue.use(Input)
|
||||
|
||||
or
|
||||
|
||||
import Vue from 'vue'
|
||||
import Field from 'buefy/dist/components/field'
|
||||
import Input from 'buefy/dist/components/input'
|
||||
import 'buefy/dist/buefy.css'
|
||||
|
||||
Vue.use(Field)
|
||||
Vue.use(Input)
|
||||
```
|
||||
|
||||
### 3 Include Material Design Icons
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//cdn.materialdesignicons.com/2.0.46/css/materialdesignicons.min.css">
|
||||
```
|
||||
|
||||
If you want to customize the icons or the theme, refer to the [customization section on the documentation](https://buefy.org/#/documentation/customization).
|
||||
|
||||
### Alternatively, you can use a CDN or even download
|
||||
|
||||
```html
|
||||
<!-- Buefy CSS -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
|
||||
|
||||
<!-- Buefy JavaScript -->
|
||||
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
|
||||
```
|
||||
|
||||
## Browser support
|
||||
|
||||
Recent versions of Firefox, Chrome, Edge, Opera and Safari. IE10+ is only partially supported.
|
||||
|
||||
## Versioning
|
||||
|
||||
While it's still in beta, version will follow **v0.Y.Z**, where:
|
||||
|
||||
* **Y**: Major (breaking changes)
|
||||
* **Z**: Minor or patch
|
||||
|
||||
## Maintainers
|
||||
|
||||
* [Walter Tommasi](https://twitter.com/walter_tommasi)
|
||||
|
||||
## Supporting through Patreon
|
||||
|
||||
Buefy is an open source MIT project if you are interested in supporting this project, please consider becoming a patron.
|
||||
<p align="center">
|
||||
<a href="https://www.patreon.com/jtommy">
|
||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Become a Patron" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
Code released under [MIT](https://github.com/buefy/buefy/blob/master/LICENSE) license.
|
||||
|
||||
Copyright (c), [Rafael Beraldo](https://twitter.com/rafaelpimpa).
|
9193
node_modules/buefy/dist/buefy.css
generated
vendored
Normal file
9193
node_modules/buefy/dist/buefy.css
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
14166
node_modules/buefy/dist/buefy.js
generated
vendored
Normal file
14166
node_modules/buefy/dist/buefy.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
node_modules/buefy/dist/buefy.min.css
generated
vendored
Normal file
4
node_modules/buefy/dist/buefy.min.css
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/buefy.min.js
generated
vendored
Normal file
2
node_modules/buefy/dist/buefy.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/autocomplete/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/autocomplete/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/button/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/button/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/checkbox/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/checkbox/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/clockpicker/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/clockpicker/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/collapse/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/collapse/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! Buefy v0.7.4 | MIT License | github.com/buefy/buefy */
|
||||
!(function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}})("undefined"!=typeof self?self:this,(function(){return (function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=254)})({0:function(e,t){e.exports=function(e,t,n,o,r){var i,s=e=e||{},a=typeof e.default;"object"!==a&&"function"!==a||(i=e,s=e.default);var u="function"==typeof s?s.options:s;t&&(u.render=t.render,u.staticRenderFns=t.staticRenderFns),o&&(u._scopeId=o);var c;if(r?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},u._ssrRegister=c):n&&(c=n),c){var f=u.functional,p=f?u.render:u.beforeCreate;f?u.render=function(e,t){return c.call(t),p(e,t)}:u.beforeCreate=p?[].concat(p,c):[c]}return{esModule:i,exports:s,options:u}}},12:function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}));var o=function(e){"undefined"!=typeof window&&window.Vue&&window.Vue.use(e)},r=function(e,t){e.component(t.name,t)},i=function(e,t,n){e.prototype[t]=n}},135:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(136),r=n.n(o),i=n(12);n.d(t,"Collapse",(function(){return r.a}));var s={install:function(e){Object(i.a)(e,r.a)}};Object(i.c)(s),t.default=s},136:function(e,t,n){var o=n(0)(n(137),n(138),null,null,null);e.exports=o.exports},137:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"BCollapse",props:{open:{type:Boolean,default:!0},animation:{type:String,default:"fade"},ariaId:{type:String,default:""}},data:function(){return{isOpen:this.open}},watch:{open:function(e){this.isOpen=e}},methods:{toggle:function(){this.isOpen=!this.isOpen,this.$emit("update:open",this.isOpen),this.$emit(this.isOpen?"open":"close")}}}},138:function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"collapse"},[n("div",{staticClass:"collapse-trigger",on:{click:e.toggle}},[e._t("trigger",null,{open:e.isOpen})],2),e._v(" "),n("transition",{attrs:{name:e.animation}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"collapse-content",attrs:{id:e.ariaId,"aria-expanded":e.isOpen}},[e._t("default")],2)])],1)},staticRenderFns:[]}},254:function(e,t,n){e.exports=n(135)}})}));
|
2
node_modules/buefy/dist/components/datepicker/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/datepicker/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/dialog/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/dialog/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/dropdown/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/dropdown/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/field/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/field/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/icon/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/icon/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/input/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/input/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/loading/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/loading/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/message/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/message/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/modal/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/modal/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/notification/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/notification/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/numberinput/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/numberinput/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/pagination/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/pagination/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/radio/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/radio/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/select/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/select/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/snackbar/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/snackbar/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/switch/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/switch/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/table/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/table/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/tabs/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/tabs/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/tag/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/tag/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! Buefy v0.7.4 | MIT License | github.com/buefy/buefy */
|
||||
!(function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}})("undefined"!=typeof self?self:this,(function(){return (function(e){function t(o){if(n[o])return n[o].exports;var s=n[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=273)})({0:function(e,t){e.exports=function(e,t,n,o,s){var r,a=e=e||{},i=typeof e.default;"object"!==i&&"function"!==i||(r=e,a=e.default);var l="function"==typeof a?a.options:a;t&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns),o&&(l._scopeId=o);var u;if(s?(u=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=u):n&&(u=n),u){var c=l.functional,d=c?l.render:l.beforeCreate;c?l.render=function(e,t){return u.call(t),d(e,t)}:l.beforeCreate=d?[].concat(d,u):[u]}return{esModule:r,exports:a,options:l}}},112:function(e,t,n){var o=n(0)(n(124),n(125),null,null,null);e.exports=o.exports},12:function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return r}));var o=function(e){"undefined"!=typeof window&&window.Vue&&window.Vue.use(e)},s=function(e,t){e.component(t.name,t)},r=function(e,t,n){e.prototype[t]=n}},124:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"BTag",props:{attached:Boolean,closable:Boolean,type:String,size:String,rounded:Boolean,disabled:Boolean,ellipsis:Boolean,tabstop:{type:Boolean,default:!0}},methods:{close:function(){this.disabled||this.$emit("close")}}}},125:function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.attached&&e.closable?n("div",{staticClass:"tags has-addons"},[n("span",{staticClass:"tag",class:[e.type,e.size,{"is-rounded":e.rounded}]},[n("span",{class:{"has-ellipsis":e.ellipsis}},[e._t("default")],2)]),e._v(" "),n("a",{staticClass:"tag is-delete",class:[e.size,{"is-rounded":e.rounded}],attrs:{role:"button",tabindex:!!e.tabstop&&0,disabled:e.disabled},on:{click:function(t){e.close()},keyup:function(t){if(!("button"in t)&&e._k(t.keyCode,"delete",[8,46],t.key))return null;t.preventDefault(),e.close()}}})]):n("span",{staticClass:"tag",class:[e.type,e.size,{"is-rounded":e.rounded}]},[n("span",{class:{"has-ellipsis":e.ellipsis}},[e._t("default")],2),e._v(" "),e.closable?n("a",{staticClass:"delete is-small",attrs:{role:"button",disabled:e.disabled,tabindex:!!e.tabstop&&0},on:{click:function(t){e.close()},keyup:function(t){if(!("button"in t)&&e._k(t.keyCode,"delete",[8,46],t.key))return null;t.preventDefault(),e.close()}}}):e._e()])},staticRenderFns:[]}},224:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(112),s=n.n(o),r=n(225),a=n.n(r),i=n(12);n.d(t,"Tag",(function(){return s.a})),n.d(t,"Taglist",(function(){return a.a}));var l={install:function(e){Object(i.a)(e,s.a),Object(i.a)(e,a.a)}};Object(i.c)(l),t.default=l},225:function(e,t,n){var o=n(0)(n(226),n(227),null,null,null);e.exports=o.exports},226:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"BTaglist",props:{attached:Boolean}}},227:function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{staticClass:"tags",class:{"has-addons":e.attached}},[e._t("default")],2)},staticRenderFns:[]}},273:function(e,t,n){e.exports=n(224)}})}));
|
2
node_modules/buefy/dist/components/taginput/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/taginput/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/timepicker/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/timepicker/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/toast/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/toast/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/buefy/dist/components/tooltip/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/tooltip/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! Buefy v0.7.4 | MIT License | github.com/buefy/buefy */
|
||||
!(function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}})("undefined"!=typeof self?self:this,(function(){return (function(e){function t(o){if(n[o])return n[o].exports;var a=n[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=277)})({0:function(e,t){e.exports=function(e,t,n,o,a){var i,l=e=e||{},u=typeof e.default;"object"!==u&&"function"!==u||(i=e,l=e.default);var r="function"==typeof l?l.options:l;t&&(r.render=t.render,r.staticRenderFns=t.staticRenderFns),o&&(r._scopeId=o);var f;if(a?(f=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(a)},r._ssrRegister=f):n&&(f=n),f){var d=r.functional,s=d?r.render:r.beforeCreate;d?r.render=function(e,t){return f.call(t),s(e,t)}:r.beforeCreate=s?[].concat(s,f):[f]}return{esModule:i,exports:l,options:r}}},12:function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return i}));var o=function(e){"undefined"!=typeof window&&window.Vue&&window.Vue.use(e)},a=function(e,t){e.component(t.name,t)},i=function(e,t,n){e.prototype[t]=n}},13:function(e,t,n){"use strict";var o={defaultContainerElement:null,defaultIconPack:"mdi",defaultIconComponent:null,defaultDialogConfirmText:null,defaultDialogCancelText:null,defaultSnackbarDuration:3500,defaultSnackbarPosition:null,defaultToastDuration:2e3,defaultToastPosition:null,detaultNotificationDuration:2e3,defaultNotificationPosition:null,defaultTooltipType:"is-primary",defaultTooltipAnimated:!1,defaultInputAutocomplete:"on",defaultDateFormatter:null,defaultDateParser:null,defaultDateCreator:null,defaultDayNames:null,defaultMonthNames:null,defaultFirstDayOfWeek:null,defaultUnselectableDaysOfWeek:null,defaultTimeFormatter:null,defaultTimeParser:null,defaultModalCanCancel:null,defaultModalScroll:null,defaultDatepickerMobileNative:!0,defaultTimepickerMobileNative:!0,defaultNoticeQueue:!0,defaultInputHasCounter:!0,defaultUseHtml5Validation:!0};t.a=o},240:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(241),a=n.n(o),i=n(12);n.d(t,"Tooltip",(function(){return a.a}));var l={install:function(e){Object(i.a)(e,a.a)}};Object(i.c)(l),t.default=l},241:function(e,t,n){var o=n(0)(n(242),n(243),null,null,null);e.exports=o.exports},242:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(13);t.default={name:"BTooltip",props:{active:{type:Boolean,default:!0},type:String,label:String,position:{type:String,default:"is-top",validator:function(e){return["is-top","is-bottom","is-left","is-right"].indexOf(e)>-1}},always:Boolean,animated:Boolean,square:Boolean,dashed:Boolean,multilined:Boolean,size:{type:String,default:"is-medium"}},computed:{newType:function(){return this.type||o.a.defaultTooltipType},newAnimated:function(){return this.animated||o.a.defaultTooltipAnimated}}}},243:function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("span",{class:[e.newType,e.position,e.size,{"b-tooltip":e.active,"is-square":e.square,"is-animated":e.newAnimated,"is-always":e.always,"is-multiline":e.multilined,"is-dashed":e.dashed}],attrs:{"data-label":e.label}},[e._t("default")],2)},staticRenderFns:[]}},277:function(e,t,n){e.exports=n(240)}})}));
|
2
node_modules/buefy/dist/components/upload/index.js
generated
vendored
Normal file
2
node_modules/buefy/dist/components/upload/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
169
node_modules/buefy/package.json
generated
vendored
Normal file
169
node_modules/buefy/package.json
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
{
|
||||
"_from": "buefy",
|
||||
"_id": "buefy@0.7.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-p6yz4XKbfXZd4f9d5rLHXCZWl9Y+8bN7gTaFQ4VdLXh7bdo4WYkPYyFyUFE+fIXhx/VEzSh2TeCEYqn/e8xY8w==",
|
||||
"_location": "/buefy",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "buefy",
|
||||
"name": "buefy",
|
||||
"escapedName": "buefy",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/buefy/-/buefy-0.7.5.tgz",
|
||||
"_shasum": "d25fcbb69beeb898849b47b52be78dfd2849452f",
|
||||
"_spec": "buefy",
|
||||
"_where": "/home/erik/Documents/workspace_brackets/a1_BME_Project_Ohm/om",
|
||||
"author": {
|
||||
"name": "Rafael Beraldo",
|
||||
"email": "rafael.pimpa@gmail.com"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 8"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/buefy/buefy/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"bulma": "0.7.4"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Lightweight UI components for Vue.js based on Bulma",
|
||||
"devDependencies": {
|
||||
"@fortawesome/fontawesome-free": "5.3.1",
|
||||
"@mdi/font": "2.7.94",
|
||||
"@vue/test-utils": "^1.0.0-beta.25",
|
||||
"autoprefixer": "7.1.1",
|
||||
"axios": "0.16.2",
|
||||
"babel-core": "6.25.0",
|
||||
"babel-eslint": "7.1.1",
|
||||
"babel-jest": "22.1.0",
|
||||
"babel-loader": "7.1.2",
|
||||
"babel-plugin-transform-runtime": "6.22.0",
|
||||
"babel-preset-env": "1.3.2",
|
||||
"babel-preset-stage-2": "6.22.0",
|
||||
"babel-register": "6.22.0",
|
||||
"chalk": "1.1.3",
|
||||
"cleave.js": "1.0.1",
|
||||
"clipboard": "1.7.1",
|
||||
"codecov": "3.0.0",
|
||||
"connect-history-api-fallback": "1.3.0",
|
||||
"copy-webpack-plugin": "4.3.1",
|
||||
"cross-env": "4.0.0",
|
||||
"cross-spawn": "5.0.1",
|
||||
"css-loader": "0.28.0",
|
||||
"eslint": "3.19.0",
|
||||
"eslint-config-buefy": "0.0.1",
|
||||
"eventsource-polyfill": "0.9.6",
|
||||
"express": "4.14.1",
|
||||
"extract-text-webpack-plugin": "3.0.2",
|
||||
"file-loader": "0.11.1",
|
||||
"font-awesome": "4.7.0",
|
||||
"friendly-errors-webpack-plugin": "1.6.1",
|
||||
"highlight.js": "9.12.0",
|
||||
"html-webpack-plugin": "2.30.1",
|
||||
"http-proxy-middleware": "0.17.3",
|
||||
"jest": "23.5.0",
|
||||
"jest-serializer-vue": "0.3.0",
|
||||
"lint-staged": "6.1.1",
|
||||
"node-sass": "4.11.0",
|
||||
"opn": "4.0.2",
|
||||
"optimize-css-assets-webpack-plugin": "3.2.0",
|
||||
"optimize-js-plugin": "0.0.4",
|
||||
"ora": "1.2.0",
|
||||
"pre-commit": "1.2.2",
|
||||
"prerender-spa-plugin": "3.2.1",
|
||||
"raw-loader": "0.5.1",
|
||||
"rimraf": "2.6.0",
|
||||
"sass-loader": "6.0.6",
|
||||
"scrollreveal": "3.3.6",
|
||||
"semver": "5.3.0",
|
||||
"shelljs": "0.7.6",
|
||||
"sortablejs": "1.7.0",
|
||||
"uglifyjs-webpack-plugin": "1.2.5",
|
||||
"url-loader": "0.5.8",
|
||||
"vee-validate": "2.1.0-beta.9",
|
||||
"vue": "2.5.13",
|
||||
"vue-analytics": "4.1.3",
|
||||
"vue-jest": "2.5.0",
|
||||
"vue-loader": "12.1.0",
|
||||
"vue-progressbar": "0.7.2",
|
||||
"vue-router": "2.3.1",
|
||||
"vue-style-loader": "3.0.1",
|
||||
"vue-template-compiler": "2.5.13",
|
||||
"webpack": "3.10.0",
|
||||
"webpack-bundle-analyzer": "2.9.2",
|
||||
"webpack-dev-server": "2.11.1",
|
||||
"webpack-hot-middleware": "2.21.0",
|
||||
"webpack-merge": "4.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.0.0",
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"types/*.d.ts"
|
||||
],
|
||||
"homepage": "https://buefy.org",
|
||||
"keywords": [
|
||||
"bulma",
|
||||
"vue",
|
||||
"vuejs",
|
||||
"vue-bulma",
|
||||
"components"
|
||||
],
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"*.{vue,js}": [
|
||||
"lint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "dist/buefy.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Walter Tommasi",
|
||||
"email": "tommsi20@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "buefy",
|
||||
"peerDependencies": {
|
||||
"vue": "^2.5.13"
|
||||
},
|
||||
"pre-commit": "lint:staged",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/buefy/buefy.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:lib && npm run build:docs",
|
||||
"build:docs": "node build/build.js",
|
||||
"build:lib": "node build/build-lib.js",
|
||||
"cov": "./node_modules/codcov/bin/codcov",
|
||||
"dev": "node build/dev-server.js",
|
||||
"lint": "eslint --ext .js,.vue src docs",
|
||||
"lint:fix": "eslint --ext .js,.vue src docs --fix",
|
||||
"lint:staged": "lint-staged",
|
||||
"start": "node build/dev-server.js",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"test:watch": "npm run unit -- --watchAll",
|
||||
"unit": "jest"
|
||||
},
|
||||
"typings": "types/index.d.ts",
|
||||
"unpkg": "dist/buefy.min.js",
|
||||
"version": "0.7.5"
|
||||
}
|
152
node_modules/buefy/src/components/autocomplete/Autocomplete.spec.js
generated
vendored
Normal file
152
node_modules/buefy/src/components/autocomplete/Autocomplete.spec.js
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import BAutocomplete from '@components/autocomplete/Autocomplete'
|
||||
|
||||
const findStringsStartingWith = (array, value) =>
|
||||
array.filter((x) => x.startsWith(value))
|
||||
|
||||
const DATA_LIST = [
|
||||
'Angular',
|
||||
'Angular 2',
|
||||
'Aurelia',
|
||||
'Backbone',
|
||||
'Ember',
|
||||
'jQuery',
|
||||
'Meteor',
|
||||
'Node.js',
|
||||
'Polymer',
|
||||
'React',
|
||||
'RxJS',
|
||||
'Vue.js'
|
||||
]
|
||||
const dropdownMenu = '.dropdown-menu'
|
||||
let wrapper, $input, $dropdown
|
||||
|
||||
describe('BAutocomplete', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = mount(BAutocomplete)
|
||||
|
||||
$input = wrapper.find('input')
|
||||
$dropdown = wrapper.find(dropdownMenu)
|
||||
})
|
||||
|
||||
it('is called', () => {
|
||||
expect(wrapper.name()).toBe('BAutocomplete')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has an input type', () => {
|
||||
expect(wrapper.contains('.control .input[type=text]')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has a dropdown menu hidden by default', () => {
|
||||
expect(wrapper.contains(dropdownMenu)).toBeTruthy()
|
||||
expect($dropdown.isVisible()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('can emit input, focus and blur events', async () => {
|
||||
const VALUE_TYPED = 'test'
|
||||
wrapper.setProps({ data: DATA_LIST })
|
||||
|
||||
$input.trigger('focus')
|
||||
expect(wrapper.emitted()['focus']).toBeTruthy()
|
||||
$input.setValue(VALUE_TYPED)
|
||||
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
const valueEmitted = wrapper.emitted()['input'][0]
|
||||
expect(valueEmitted).toContainEqual(VALUE_TYPED)
|
||||
|
||||
$input.trigger('blur')
|
||||
expect(wrapper.emitted()['blur']).toBeTruthy()
|
||||
})
|
||||
|
||||
it('can autocomplete with keydown', async () => {
|
||||
const VALUE_TYPED = 'Ang'
|
||||
wrapper.setProps({ data: DATA_LIST })
|
||||
|
||||
$input.trigger('focus')
|
||||
$input.setValue(VALUE_TYPED)
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
expect($dropdown.isVisible()).toBeTruthy()
|
||||
|
||||
const itemsInDropdowm = findStringsStartingWith(DATA_LIST, VALUE_TYPED)
|
||||
|
||||
$input.trigger('keydown.down')
|
||||
$input.trigger('keydown.enter')
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
expect($input.element.value).toBe(itemsInDropdowm[0])
|
||||
expect($dropdown.isVisible()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('check validity when value change', () => {
|
||||
wrapper.setProps({ data: DATA_LIST })
|
||||
wrapper.vm.$refs.input.checkHtml5Validity = jest.fn()
|
||||
|
||||
wrapper.vm.isValid = false
|
||||
wrapper.setProps({ value: 'test' })
|
||||
|
||||
expect(wrapper.vm.$refs.input.checkHtml5Validity).toBeCalled()
|
||||
})
|
||||
|
||||
it('close dropdown on esc', () => {
|
||||
wrapper.setProps({ data: DATA_LIST })
|
||||
|
||||
wrapper.vm.isActive = true
|
||||
expect($dropdown.isVisible()).toBeTruthy()
|
||||
|
||||
$input.trigger('keyup.esc')
|
||||
|
||||
expect($dropdown.isVisible()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('close dropdown on click outside', () => {
|
||||
wrapper.setProps({ data: DATA_LIST })
|
||||
|
||||
wrapper.vm.isActive = true
|
||||
expect($dropdown.isVisible()).toBeTruthy()
|
||||
|
||||
window.document.body.click()
|
||||
|
||||
expect($dropdown.isVisible()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('open dropdown on down key click', () => {
|
||||
wrapper.setProps({ data: DATA_LIST })
|
||||
|
||||
expect($dropdown.isVisible()).toBeFalsy()
|
||||
|
||||
$input.trigger('focus')
|
||||
$input.trigger('keydown.down')
|
||||
|
||||
expect($dropdown.isVisible()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('can openOnFocus and keepFirst', async () => {
|
||||
wrapper.setProps({
|
||||
data: DATA_LIST,
|
||||
openOnFocus: true,
|
||||
keepFirst: true
|
||||
})
|
||||
|
||||
expect($dropdown.isVisible()).toBeFalsy()
|
||||
|
||||
$input.trigger('focus')
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
expect($dropdown.isVisible()).toBeTruthy()
|
||||
|
||||
expect(wrapper.vm.hovered).toBe(DATA_LIST[0])
|
||||
})
|
||||
|
||||
it('reset events before destroy', () => {
|
||||
document.removeEventListener = jest.fn()
|
||||
window.removeEventListener = jest.fn()
|
||||
|
||||
wrapper.destroy()
|
||||
|
||||
expect(document.removeEventListener).toBeCalledWith('click', expect.any(Function))
|
||||
expect(window.removeEventListener).toBeCalledWith('resize', expect.any(Function))
|
||||
})
|
||||
})
|
387
node_modules/buefy/src/components/autocomplete/Autocomplete.vue
generated
vendored
Normal file
387
node_modules/buefy/src/components/autocomplete/Autocomplete.vue
generated
vendored
Normal file
@ -0,0 +1,387 @@
|
||||
<template>
|
||||
<div class="autocomplete control" :class="{'is-expanded': expanded}">
|
||||
<b-input
|
||||
v-model="newValue"
|
||||
ref="input"
|
||||
type="text"
|
||||
:size="size"
|
||||
:loading="loading"
|
||||
:rounded="rounded"
|
||||
:icon="icon"
|
||||
:icon-pack="iconPack"
|
||||
:maxlength="maxlength"
|
||||
:autocomplete="newAutocomplete"
|
||||
v-bind="$attrs"
|
||||
@input="onInput"
|
||||
@focus="focused"
|
||||
@blur="onBlur"
|
||||
@keyup.native.esc.prevent="isActive = false"
|
||||
@keydown.native.tab="tabPressed"
|
||||
@keydown.native.enter.prevent="enterPressed"
|
||||
@keydown.native.up.prevent="keyArrows('up')"
|
||||
@keydown.native.down.prevent="keyArrows('down')"
|
||||
/>
|
||||
|
||||
<transition name="fade">
|
||||
<div
|
||||
class="dropdown-menu"
|
||||
:class="{ 'is-opened-top': !isListInViewportVertically }"
|
||||
v-show="isActive && (data.length > 0 || hasEmptySlot || hasHeaderSlot)"
|
||||
ref="dropdown">
|
||||
<div class="dropdown-content" v-show="isActive">
|
||||
<div
|
||||
v-if="hasHeaderSlot"
|
||||
class="dropdown-item">
|
||||
<slot name="header"/>
|
||||
</div>
|
||||
<a
|
||||
v-for="(option, index) in data"
|
||||
:key="index"
|
||||
class="dropdown-item"
|
||||
:class="{ 'is-hovered': option === hovered }"
|
||||
@click="setSelected(option)">
|
||||
|
||||
<slot
|
||||
v-if="hasDefaultSlot"
|
||||
:option="option"
|
||||
:index="index"
|
||||
/>
|
||||
<span v-else>
|
||||
{{ getValue(option, true) }}
|
||||
</span>
|
||||
</a>
|
||||
<div
|
||||
v-if="data.length === 0 && hasEmptySlot"
|
||||
class="dropdown-item is-disabled">
|
||||
<slot name="empty"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getValueByPath } from '../../utils/helpers'
|
||||
import FormElementMixin from '../../utils/FormElementMixin'
|
||||
import Input from '../input/Input'
|
||||
|
||||
export default {
|
||||
name: 'BAutocomplete',
|
||||
components: {
|
||||
[Input.name]: Input
|
||||
},
|
||||
mixins: [FormElementMixin],
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: [Number, String],
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
field: {
|
||||
type: String,
|
||||
default: 'value'
|
||||
},
|
||||
keepFirst: Boolean,
|
||||
clearOnSelect: Boolean,
|
||||
openOnFocus: Boolean,
|
||||
customFormatter: Function
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selected: null,
|
||||
hovered: null,
|
||||
isActive: false,
|
||||
newValue: this.value,
|
||||
newAutocomplete: this.autocomplete || 'off',
|
||||
isListInViewportVertically: true,
|
||||
hasFocus: false,
|
||||
_isAutocomplete: true,
|
||||
_elementRef: 'input'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* White-listed items to not close when clicked.
|
||||
* Add input, dropdown and all children.
|
||||
*/
|
||||
whiteList() {
|
||||
const whiteList = []
|
||||
whiteList.push(this.$refs.input.$el.querySelector('input'))
|
||||
whiteList.push(this.$refs.dropdown)
|
||||
// Add all chidren from dropdown
|
||||
if (this.$refs.dropdown !== undefined) {
|
||||
const children = this.$refs.dropdown.querySelectorAll('*')
|
||||
for (const child of children) {
|
||||
whiteList.push(child)
|
||||
}
|
||||
}
|
||||
|
||||
return whiteList
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if exists default slot
|
||||
*/
|
||||
hasDefaultSlot() {
|
||||
return !!this.$scopedSlots.default
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if exists "empty" slot
|
||||
*/
|
||||
hasEmptySlot() {
|
||||
return !!this.$slots.empty
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if exists "header" slot
|
||||
*/
|
||||
hasHeaderSlot() {
|
||||
return !!this.$slots.header
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
/**
|
||||
* When dropdown is toggled, check the visibility to know when
|
||||
* to open upwards.
|
||||
*/
|
||||
isActive(active) {
|
||||
if (active) {
|
||||
this.calcDropdownInViewportVertical()
|
||||
} else {
|
||||
this.$nextTick(() => this.setHovered(null))
|
||||
// Timeout to wait for the animation to finish before recalculating
|
||||
setTimeout(() => {
|
||||
this.calcDropdownInViewportVertical()
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* When updating input's value
|
||||
* 1. Emit changes
|
||||
* 2. If value isn't the same as selected, set null
|
||||
* 3. Close dropdown if value is clear or else open it
|
||||
*/
|
||||
newValue(value) {
|
||||
this.$emit('input', value)
|
||||
// Check if selected is invalid
|
||||
const currentValue = this.getValue(this.selected)
|
||||
if (currentValue && currentValue !== value) {
|
||||
this.setSelected(null, false)
|
||||
}
|
||||
// Close dropdown if input is clear or else open it
|
||||
if (this.hasFocus && (!this.openOnFocus || value)) {
|
||||
this.isActive = !!value
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* When v-model is changed:
|
||||
* 1. Update internal value.
|
||||
* 2. If it's invalid, validate again.
|
||||
*/
|
||||
value(value) {
|
||||
this.newValue = value
|
||||
!this.isValid && this.$refs.input.checkHtml5Validity()
|
||||
},
|
||||
|
||||
/**
|
||||
* Select first option if "keep-first
|
||||
*/
|
||||
data(value) {
|
||||
// Keep first option always pre-selected
|
||||
if (this.keepFirst) {
|
||||
this.selectFirstOption(value)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* Set which option is currently hovered.
|
||||
*/
|
||||
setHovered(option) {
|
||||
if (option === undefined) return
|
||||
|
||||
this.hovered = option
|
||||
},
|
||||
|
||||
/**
|
||||
* Set which option is currently selected, update v-model,
|
||||
* update input value and close dropdown.
|
||||
*/
|
||||
setSelected(option, closeDropdown = true) {
|
||||
if (option === undefined) return
|
||||
|
||||
this.selected = option
|
||||
this.$emit('select', this.selected)
|
||||
if (this.selected !== null) {
|
||||
this.newValue = this.clearOnSelect ? '' : this.getValue(this.selected)
|
||||
}
|
||||
closeDropdown && this.$nextTick(() => { this.isActive = false })
|
||||
},
|
||||
|
||||
/**
|
||||
* Select first option
|
||||
*/
|
||||
selectFirstOption(options) {
|
||||
this.$nextTick(() => {
|
||||
if (options.length) {
|
||||
// If has visible data or open on focus, keep updating the hovered
|
||||
if (this.openOnFocus || (this.newValue !== '' && this.hovered !== options[0])) {
|
||||
this.setHovered(options[0])
|
||||
}
|
||||
} else {
|
||||
this.setHovered(null)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Enter key listener.
|
||||
* Select the hovered option.
|
||||
*/
|
||||
enterPressed() {
|
||||
if (this.hovered === null) return
|
||||
this.setSelected(this.hovered)
|
||||
},
|
||||
|
||||
/**
|
||||
* Tab key listener.
|
||||
* Select hovered option if it exists, close dropdown, then allow
|
||||
* native handling to move to next tabbable element.
|
||||
*/
|
||||
tabPressed() {
|
||||
if (this.hovered === null) {
|
||||
this.isActive = false
|
||||
return
|
||||
}
|
||||
this.setSelected(this.hovered)
|
||||
},
|
||||
|
||||
/**
|
||||
* Close dropdown if clicked outside.
|
||||
*/
|
||||
clickedOutside(event) {
|
||||
if (this.whiteList.indexOf(event.target) < 0) this.isActive = false
|
||||
},
|
||||
|
||||
/**
|
||||
* Return display text for the input.
|
||||
* If object, get value from path, or else just the value.
|
||||
*/
|
||||
getValue(option) {
|
||||
if (!option) return
|
||||
|
||||
if (typeof this.customFormatter !== 'undefined') {
|
||||
return this.customFormatter(option)
|
||||
}
|
||||
return typeof option === 'object'
|
||||
? getValueByPath(option, this.field)
|
||||
: option
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculate if the dropdown is vertically visible when activated,
|
||||
* otherwise it is openened upwards.
|
||||
*/
|
||||
calcDropdownInViewportVertical() {
|
||||
this.$nextTick(() => {
|
||||
/**
|
||||
* this.$refs.dropdown may be undefined
|
||||
* when Autocomplete is conditional rendered
|
||||
*/
|
||||
if (this.$refs.dropdown === undefined) return
|
||||
|
||||
const rect = this.$refs.dropdown.getBoundingClientRect()
|
||||
|
||||
this.isListInViewportVertically = (
|
||||
rect.top >= 0 &&
|
||||
rect.bottom <= (window.innerHeight ||
|
||||
document.documentElement.clientHeight)
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Arrows keys listener.
|
||||
* If dropdown is active, set hovered option, or else just open.
|
||||
*/
|
||||
keyArrows(direction) {
|
||||
const sum = direction === 'down' ? 1 : -1
|
||||
if (this.isActive) {
|
||||
let index = this.data.indexOf(this.hovered) + sum
|
||||
index = index > this.data.length - 1 ? this.data.length : index
|
||||
index = index < 0 ? 0 : index
|
||||
|
||||
this.setHovered(this.data[index])
|
||||
|
||||
const list = this.$refs.dropdown.querySelector('.dropdown-content')
|
||||
const element = list.querySelectorAll('a.dropdown-item:not(.is-disabled)')[index]
|
||||
|
||||
if (!element) return
|
||||
|
||||
const visMin = list.scrollTop
|
||||
const visMax = list.scrollTop + list.clientHeight - element.clientHeight
|
||||
|
||||
if (element.offsetTop < visMin) {
|
||||
list.scrollTop = element.offsetTop
|
||||
} else if (element.offsetTop >= visMax) {
|
||||
list.scrollTop = (
|
||||
element.offsetTop -
|
||||
list.clientHeight +
|
||||
element.clientHeight
|
||||
)
|
||||
}
|
||||
} else {
|
||||
this.isActive = true
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Focus listener.
|
||||
* If value is the same as selected, select all text.
|
||||
*/
|
||||
focused(event) {
|
||||
if (this.getValue(this.selected) === this.newValue) {
|
||||
this.$el.querySelector('input').select()
|
||||
}
|
||||
if (this.openOnFocus) {
|
||||
this.isActive = true
|
||||
if (this.keepFirst) {
|
||||
this.selectFirstOption(this.data)
|
||||
}
|
||||
}
|
||||
this.hasFocus = true
|
||||
this.$emit('focus', event)
|
||||
},
|
||||
|
||||
/**
|
||||
* Blur listener.
|
||||
*/
|
||||
onBlur(event) {
|
||||
this.hasFocus = false
|
||||
this.$emit('blur', event)
|
||||
},
|
||||
onInput(event) {
|
||||
const currentValue = this.getValue(this.selected)
|
||||
if (currentValue && currentValue === this.newValue) return
|
||||
this.$emit('typing', this.newValue)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (typeof window !== 'undefined') {
|
||||
document.addEventListener('click', this.clickedOutside)
|
||||
window.addEventListener('resize', this.calcDropdownInViewportVertical)
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (typeof window !== 'undefined') {
|
||||
document.removeEventListener('click', this.clickedOutside)
|
||||
window.removeEventListener('resize', this.calcDropdownInViewportVertical)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
17
node_modules/buefy/src/components/autocomplete/index.js
generated
vendored
Normal file
17
node_modules/buefy/src/components/autocomplete/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import Autocomplete from './Autocomplete'
|
||||
|
||||
import { use, registerComponent } from '../../utils/plugins'
|
||||
|
||||
const Plugin = {
|
||||
install(Vue) {
|
||||
registerComponent(Vue, Autocomplete)
|
||||
}
|
||||
}
|
||||
|
||||
use(Plugin)
|
||||
|
||||
export default Plugin
|
||||
|
||||
export {
|
||||
Autocomplete
|
||||
}
|
58
node_modules/buefy/src/components/button/Button.spec.js
generated
vendored
Normal file
58
node_modules/buefy/src/components/button/Button.spec.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
import { shallowMount, mount } from '@vue/test-utils'
|
||||
import BButton from '@components/button/Button'
|
||||
|
||||
describe('BButton', () => {
|
||||
it('is called', () => {
|
||||
const wrapper = shallowMount(BButton)
|
||||
expect(wrapper.name()).toBe('BButton')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('emit a click event', () => {
|
||||
const wrapper = shallowMount(BButton)
|
||||
const click = jest.fn()
|
||||
wrapper.vm.$on('click', click)
|
||||
wrapper.find('.button').trigger('click')
|
||||
expect(click).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should show icon', () => {
|
||||
const wrapper = mount(BButton, {
|
||||
propsData: {
|
||||
iconLeft: 'plus'
|
||||
}
|
||||
})
|
||||
expect(wrapper.contains('.icon')).toBe(true)
|
||||
})
|
||||
|
||||
it('should be medium', () => {
|
||||
const wrapper = shallowMount(BButton, {
|
||||
propsData: {
|
||||
size: 'is-medium'
|
||||
}
|
||||
})
|
||||
expect(wrapper.classes()).toContain('is-medium')
|
||||
})
|
||||
|
||||
it('should be small + icon', () => {
|
||||
const wrapper = mount(BButton, {
|
||||
propsData: {
|
||||
size: 'is-small',
|
||||
iconLeft: 'plus'
|
||||
}
|
||||
})
|
||||
expect(wrapper.classes()).toContain('is-small')
|
||||
expect(wrapper.contains('.icon')).toBe(true)
|
||||
})
|
||||
|
||||
it('should be large + icon', () => {
|
||||
const wrapper = mount(BButton, {
|
||||
propsData: {
|
||||
size: 'is-large',
|
||||
iconLeft: 'plus'
|
||||
}
|
||||
})
|
||||
expect(wrapper.classes()).toContain('is-large')
|
||||
expect(wrapper.contains('.icon')).toBe(true)
|
||||
})
|
||||
})
|
94
node_modules/buefy/src/components/button/Button.vue
generated
vendored
Normal file
94
node_modules/buefy/src/components/button/Button.vue
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<component
|
||||
:is="tag"
|
||||
class="button"
|
||||
:type="nativeType"
|
||||
:class="[size, type, {
|
||||
'is-rounded': rounded,
|
||||
'is-loading': loading,
|
||||
'is-outlined': outlined,
|
||||
'is-inverted': inverted,
|
||||
'is-focused': focused,
|
||||
'is-active': active,
|
||||
'is-hovered': hovered,
|
||||
'is-selected': selected
|
||||
}]"
|
||||
@click="$emit('click', $event)"
|
||||
>
|
||||
<b-icon
|
||||
v-if="iconLeft"
|
||||
:pack="iconPack"
|
||||
:icon="iconLeft"
|
||||
:size="iconSize"
|
||||
/>
|
||||
<span v-if="label">{{ label }}</span>
|
||||
<span v-else-if="$slots.default">
|
||||
<slot />
|
||||
</span>
|
||||
<b-icon
|
||||
v-if="iconRight"
|
||||
:pack="iconPack"
|
||||
:icon="iconRight"
|
||||
:size="iconSize"
|
||||
/>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Icon from '../icon/Icon'
|
||||
|
||||
export default {
|
||||
name: 'BButton',
|
||||
components: {
|
||||
[Icon.name]: Icon
|
||||
},
|
||||
props: {
|
||||
type: [String, Object],
|
||||
size: String,
|
||||
label: String,
|
||||
iconPack: String,
|
||||
iconLeft: String,
|
||||
iconRight: String,
|
||||
rounded: Boolean,
|
||||
loading: Boolean,
|
||||
outlined: Boolean,
|
||||
inverted: Boolean,
|
||||
focused: Boolean,
|
||||
active: Boolean,
|
||||
hovered: Boolean,
|
||||
selected: Boolean,
|
||||
nativeType: {
|
||||
type: String,
|
||||
default: 'button',
|
||||
validator: (value) => {
|
||||
return [
|
||||
'button',
|
||||
'submit',
|
||||
'reset'
|
||||
].indexOf(value) >= 0
|
||||
}
|
||||
},
|
||||
tag: {
|
||||
type: String,
|
||||
default: 'button',
|
||||
validator: (value) => {
|
||||
return [
|
||||
'button',
|
||||
'a',
|
||||
'input'
|
||||
].indexOf(value) >= 0
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iconSize() {
|
||||
if (!this.size || this.size === 'is-medium') {
|
||||
return 'is-small'
|
||||
} else if (this.size === 'is-large') {
|
||||
return 'is-medium'
|
||||
}
|
||||
return this.size
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
17
node_modules/buefy/src/components/button/index.js
generated
vendored
Normal file
17
node_modules/buefy/src/components/button/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import Button from './Button'
|
||||
|
||||
import { use, registerComponent } from '../../utils/plugins'
|
||||
|
||||
const Plugin = {
|
||||
install(Vue) {
|
||||
registerComponent(Vue, Button)
|
||||
}
|
||||
}
|
||||
|
||||
use(Plugin)
|
||||
|
||||
export default Plugin
|
||||
|
||||
export {
|
||||
Button
|
||||
}
|
27
node_modules/buefy/src/components/checkbox/Checkbox.spec.js
generated
vendored
Normal file
27
node_modules/buefy/src/components/checkbox/Checkbox.spec.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BCheckbox from '@components/checkbox/Checkbox'
|
||||
|
||||
let wrapper
|
||||
|
||||
describe('BCheckbox', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallowMount(BCheckbox)
|
||||
})
|
||||
|
||||
it('is called', () => {
|
||||
expect(wrapper.name()).toBe('BCheckbox')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has an input checkbox', () => {
|
||||
expect(wrapper.contains('label input[type=checkbox]')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('emit input event with value when value change', () => {
|
||||
wrapper.setProps({ value: true })
|
||||
expect(wrapper.vm.computedValue).toBeTruthy()
|
||||
wrapper.vm.computedValue = false
|
||||
const valueEmitted = wrapper.emitted()['input'][0]
|
||||
expect(valueEmitted).toContainEqual(false)
|
||||
})
|
||||
})
|
70
node_modules/buefy/src/components/checkbox/Checkbox.vue
generated
vendored
Normal file
70
node_modules/buefy/src/components/checkbox/Checkbox.vue
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<label
|
||||
class="b-checkbox checkbox"
|
||||
:class="[size, { 'is-disabled': disabled }]"
|
||||
ref="label"
|
||||
:disabled="disabled"
|
||||
@keydown.prevent.enter="$refs.label.click()">
|
||||
<input
|
||||
v-model="computedValue"
|
||||
:indeterminate.prop="indeterminate"
|
||||
type="checkbox"
|
||||
@click.stop
|
||||
:disabled="disabled"
|
||||
:required="required"
|
||||
:name="name"
|
||||
:value="nativeValue"
|
||||
:true-value="trueValue"
|
||||
:false-value="falseValue">
|
||||
<span class="check" :class="type" />
|
||||
<span class="control-label"><slot/></span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'BCheckbox',
|
||||
props: {
|
||||
value: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
nativeValue: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
indeterminate: Boolean,
|
||||
type: String,
|
||||
disabled: Boolean,
|
||||
required: Boolean,
|
||||
name: String,
|
||||
size: String,
|
||||
trueValue: {
|
||||
type: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
default: true
|
||||
},
|
||||
falseValue: {
|
||||
type: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
newValue: this.value
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
computedValue: {
|
||||
get() {
|
||||
return this.newValue
|
||||
},
|
||||
set(value) {
|
||||
this.newValue = value
|
||||
this.$emit('input', value)
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
/**
|
||||
* When v-model change, set internal value.
|
||||
*/
|
||||
value(value) {
|
||||
this.newValue = value
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
27
node_modules/buefy/src/components/checkbox/CheckboxButton.spec.js
generated
vendored
Normal file
27
node_modules/buefy/src/components/checkbox/CheckboxButton.spec.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BCheckboxButton from '@components/checkbox/CheckboxButton'
|
||||
|
||||
let wrapper
|
||||
|
||||
describe('BCheckboxButton', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallowMount(BCheckboxButton)
|
||||
})
|
||||
|
||||
it('is called', () => {
|
||||
expect(wrapper.name()).toBe('BCheckboxButton')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has an input checkbox', () => {
|
||||
expect(wrapper.contains('label input[type=checkbox]')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('emit input event with value when value change', () => {
|
||||
wrapper.setProps({ value: true })
|
||||
expect(wrapper.vm.computedValue).toBeTruthy()
|
||||
wrapper.vm.computedValue = false
|
||||
const valueEmitted = wrapper.emitted()['input'][0]
|
||||
expect(valueEmitted).toContainEqual(false)
|
||||
})
|
||||
})
|
74
node_modules/buefy/src/components/checkbox/CheckboxButton.vue
generated
vendored
Normal file
74
node_modules/buefy/src/components/checkbox/CheckboxButton.vue
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div class="control">
|
||||
<label
|
||||
class="b-checkbox checkbox button"
|
||||
ref="label"
|
||||
:class="[checked ? type : null, size, {
|
||||
'is-disabled': disabled,
|
||||
'is-focused': isFocused
|
||||
}]"
|
||||
:disabled="disabled"
|
||||
@keydown.prevent.enter="$refs.label.click()">
|
||||
<slot/>
|
||||
<input
|
||||
v-model="computedValue"
|
||||
type="checkbox"
|
||||
@click.stop
|
||||
:disabled="disabled"
|
||||
:required="required"
|
||||
:name="name"
|
||||
:value="nativeValue"
|
||||
@focus="isFocused = true"
|
||||
@blur="isFocused = false">
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'BCheckboxButton',
|
||||
props: {
|
||||
value: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
nativeValue: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
disabled: Boolean,
|
||||
required: Boolean,
|
||||
name: String,
|
||||
size: String,
|
||||
type: {
|
||||
type: String,
|
||||
default: 'is-primary'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
newValue: this.value,
|
||||
isFocused: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
computedValue: {
|
||||
get() {
|
||||
return this.newValue
|
||||
},
|
||||
set(value) {
|
||||
this.newValue = value
|
||||
this.$emit('input', value)
|
||||
}
|
||||
},
|
||||
checked() {
|
||||
if (Array.isArray(this.newValue)) {
|
||||
return this.newValue.indexOf(this.nativeValue) >= 0
|
||||
}
|
||||
return this.newValue === this.nativeValue
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
/**
|
||||
* When v-model change, set internal value.
|
||||
*/
|
||||
value(value) {
|
||||
this.newValue = value
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
20
node_modules/buefy/src/components/checkbox/index.js
generated
vendored
Normal file
20
node_modules/buefy/src/components/checkbox/index.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import Checkbox from './Checkbox'
|
||||
import CheckboxButton from './CheckboxButton'
|
||||
|
||||
import { use, registerComponent } from '../../utils/plugins'
|
||||
|
||||
const Plugin = {
|
||||
install(Vue) {
|
||||
registerComponent(Vue, Checkbox)
|
||||
registerComponent(Vue, CheckboxButton)
|
||||
}
|
||||
}
|
||||
|
||||
use(Plugin)
|
||||
|
||||
export default Plugin
|
||||
|
||||
export {
|
||||
Checkbox,
|
||||
CheckboxButton
|
||||
}
|
10
node_modules/buefy/src/components/clockpicker/Clockpicker.spec.js
generated
vendored
Normal file
10
node_modules/buefy/src/components/clockpicker/Clockpicker.spec.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BClockpicker from '@components/clockpicker/Clockpicker'
|
||||
|
||||
describe('BClockpicker', () => {
|
||||
it('is called', () => {
|
||||
const wrapper = shallowMount(BClockpicker)
|
||||
expect(wrapper.name()).toBe('BClockpicker')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
})
|
239
node_modules/buefy/src/components/clockpicker/Clockpicker.vue
generated
vendored
Normal file
239
node_modules/buefy/src/components/clockpicker/Clockpicker.vue
generated
vendored
Normal file
@ -0,0 +1,239 @@
|
||||
<template>
|
||||
<div class="b-clockpicker control" :class="[size, type, {'is-expanded': expanded}]">
|
||||
<b-dropdown
|
||||
v-if="!isMobile || inline"
|
||||
ref="dropdown"
|
||||
:position="position"
|
||||
:disabled="disabled"
|
||||
:inline="inline">
|
||||
<b-input
|
||||
v-if="!inline"
|
||||
ref="input"
|
||||
slot="trigger"
|
||||
autocomplete="off"
|
||||
:value="formatValue(dateSelected)"
|
||||
:placeholder="placeholder"
|
||||
:size="size"
|
||||
:icon="icon"
|
||||
:icon-pack="iconPack"
|
||||
:loading="loading"
|
||||
:disabled="disabled"
|
||||
:readonly="!editable"
|
||||
:rounded="rounded"
|
||||
v-bind="$attrs"
|
||||
@change.native="onChange($event.target.value)"
|
||||
@focus="$emit('focus', $event)"
|
||||
@blur="$emit('blur', $event) && checkHtml5Validity()"/>
|
||||
|
||||
<div
|
||||
class="card"
|
||||
:disabled="disabled"
|
||||
custom>
|
||||
<header v-if="inline" class="card-header">
|
||||
<div class="b-clockpicker-header card-header-title">
|
||||
<div class="b-clockpicker-time">
|
||||
<span
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: isSelectingHour }"
|
||||
@click="isSelectingHour = true">{{ hoursDisplay }}</span>
|
||||
<span>:</span>
|
||||
<span
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: !isSelectingHour }"
|
||||
@click="isSelectingHour = false">{{ minutesDisplay }}</span>
|
||||
</div>
|
||||
<div v-if="!isHourFormat24" class="b-clockpicker-period">
|
||||
<div
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: meridienSelected == AM }"
|
||||
@click="onMeridienClick(AM)">am</div>
|
||||
<div
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: meridienSelected == PM }"
|
||||
@click="onMeridienClick(PM)">pm</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div
|
||||
class="b-clockpicker-body"
|
||||
:style="{ width: faceSize + 'px', height: faceSize + 'px' }">
|
||||
<div v-if="!inline" class="b-clockpicker-time">
|
||||
<div
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: isSelectingHour }"
|
||||
@click="isSelectingHour = true">Hours</div>
|
||||
<span
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: !isSelectingHour }"
|
||||
@click="isSelectingHour = false">Min</span>
|
||||
</div>
|
||||
<div v-if="!isHourFormat24 && !inline" class="b-clockpicker-period">
|
||||
<div
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: meridienSelected == AM }"
|
||||
@click="onMeridienClick(AM)">{{ AM }}</div>
|
||||
<div
|
||||
class="b-clockpicker-btn"
|
||||
:class="{ active: meridienSelected == PM }"
|
||||
@click="onMeridienClick(PM)">{{ PM }}</div>
|
||||
</div>
|
||||
<b-clockpicker-face
|
||||
:picker-size="faceSize"
|
||||
:min="minFaceValue"
|
||||
:max="maxFaceValue"
|
||||
:face-numbers="isSelectingHour ? hours : minutes"
|
||||
:disabled-values="faceDisabledValues()"
|
||||
:double="isSelectingHour && isHourFormat24"
|
||||
:value="isSelectingHour ? hoursSelected : minutesSelected"
|
||||
@input="onClockInput"
|
||||
@change="onClockChange" />
|
||||
</div>
|
||||
</div>
|
||||
<footer
|
||||
v-if="$slots.default !== undefined && $slots.default.length"
|
||||
class="b-clockpicker-footer card-footer">
|
||||
<slot/>
|
||||
</footer>
|
||||
</div>
|
||||
</b-dropdown>
|
||||
<b-input
|
||||
v-else
|
||||
ref="input"
|
||||
type="time"
|
||||
autocomplete="off"
|
||||
:value="formatHHMMSS(value)"
|
||||
:placeholder="placeholder"
|
||||
:size="size"
|
||||
:icon="icon"
|
||||
:icon-pack="iconPack"
|
||||
:loading="loading"
|
||||
:max="formatHHMMSS(maxTime)"
|
||||
:min="formatHHMMSS(minTime)"
|
||||
:disabled="disabled"
|
||||
:readonly="false"
|
||||
v-bind="$attrs"
|
||||
@change.native="onChangeNativePicker"
|
||||
@focus="$emit('focus', $event)"
|
||||
@blur="$emit('blur', $event) && checkHtml5Validity()"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TimepickerMixin from '../../utils/TimepickerMixin'
|
||||
|
||||
import Dropdown from '../dropdown/Dropdown'
|
||||
import DropdownItem from '../dropdown/DropdownItem'
|
||||
import Input from '../input/Input'
|
||||
import Field from '../field/Field'
|
||||
import Icon from '../icon/Icon'
|
||||
import ClockpickerFace from './ClockpickerFace'
|
||||
|
||||
const outerPadding = 12
|
||||
|
||||
export default {
|
||||
name: 'BClockpicker',
|
||||
components: {
|
||||
[ClockpickerFace.name]: ClockpickerFace,
|
||||
[Input.name]: Input,
|
||||
[Field.name]: Field,
|
||||
[Icon.name]: Icon,
|
||||
[Dropdown.name]: Dropdown,
|
||||
[DropdownItem.name]: DropdownItem
|
||||
},
|
||||
mixins: [TimepickerMixin],
|
||||
props: {
|
||||
pickerSize: {
|
||||
type: Number,
|
||||
default: 290
|
||||
},
|
||||
hourFormat: {
|
||||
type: String,
|
||||
default: '12',
|
||||
validator: (value) => {
|
||||
return value === '24' || value === '12'
|
||||
}
|
||||
},
|
||||
incrementMinutes: {
|
||||
type: Number,
|
||||
default: 5
|
||||
},
|
||||
autoSwitch: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'is-primary'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isSelectingHour: true,
|
||||
isDragging: false,
|
||||
_isClockpicker: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hoursDisplay() {
|
||||
if (this.hoursSelected == null) return '--'
|
||||
if (this.isHourFormat24) return this.pad(this.hoursSelected)
|
||||
|
||||
let display = this.hoursSelected
|
||||
if (this.meridienSelected === this.PM) display -= 12
|
||||
if (display === 0) display = 12
|
||||
return display
|
||||
},
|
||||
minutesDisplay() {
|
||||
return this.minutesSelected == null ? '--' : this.pad(this.minutesSelected)
|
||||
},
|
||||
minFaceValue() {
|
||||
return this.isSelectingHour &&
|
||||
!this.isHourFormat24 &&
|
||||
this.meridienSelected === this.PM ? 12 : 0
|
||||
},
|
||||
maxFaceValue() {
|
||||
return this.isSelectingHour
|
||||
? (!this.isHourFormat24 && this.meridienSelected === this.AM ? 11 : 23)
|
||||
: 59
|
||||
},
|
||||
faceFormatter() {
|
||||
return this.isSelectingHour && !this.isHourFormat24
|
||||
? (val) => val
|
||||
: this.formatNumber
|
||||
},
|
||||
faceSize() {
|
||||
return this.pickerSize - (outerPadding * 2)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClockInput(value) {
|
||||
if (this.isSelectingHour) {
|
||||
this.hoursSelected = value
|
||||
this.onHoursChange(value)
|
||||
} else {
|
||||
this.minutesSelected = value
|
||||
this.onMinutesChange(value)
|
||||
}
|
||||
},
|
||||
onClockChange(value) {
|
||||
if (this.autoSwitch && this.isSelectingHour) {
|
||||
this.isSelectingHour = !this.isSelectingHour
|
||||
}
|
||||
},
|
||||
onMeridienClick(value) {
|
||||
if (this.meridienSelected !== value) {
|
||||
this.meridienSelected = value
|
||||
this.onMeridienChange(value)
|
||||
}
|
||||
},
|
||||
faceDisabledValues() {
|
||||
return this.isSelectingHour ? this.isHourDisabled : this.isMinuteDisabled
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.incrementMinutes = 5
|
||||
}
|
||||
}
|
||||
</script>
|
11
node_modules/buefy/src/components/clockpicker/ClockpickerFace.spec.js
generated
vendored
Normal file
11
node_modules/buefy/src/components/clockpicker/ClockpickerFace.spec.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BClockpickerFace from '@components/clockpicker/ClockpickerFace'
|
||||
|
||||
describe('BClockpickerFace', () => {
|
||||
it('is called', () => {
|
||||
const wrapper = shallowMount(BClockpickerFace)
|
||||
|
||||
expect(wrapper.name()).toBe('BClockpickerFace')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
})
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user