@@ -0,0 +1 @@ | |||
../bunyan/bin/bunyan |
@@ -0,0 +1 @@ | |||
../ldapjs/bin/ldapjs-add |
@@ -0,0 +1 @@ | |||
../ldapjs/bin/ldapjs-compare |
@@ -0,0 +1 @@ | |||
../ldapjs/bin/ldapjs-delete |
@@ -0,0 +1 @@ | |||
../ldapjs/bin/ldapjs-modify |
@@ -0,0 +1 @@ | |||
../ldapjs/bin/ldapjs-search |
@@ -0,0 +1 @@ | |||
../ncp/bin/ncp |
@@ -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) => { |
@@ -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" | |||
} |
@@ -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 | |||
@@ -0,0 +1,2 @@ | |||
node_modules | |||
*.log |
@@ -0,0 +1,4 @@ | |||
language: node_js | |||
node_js: | |||
- 0.8 | |||
- 0.10 |
@@ -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 |
@@ -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>. |
@@ -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; | |||
} | |||
}; |
@@ -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]; | |||
} |
@@ -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; |
@@ -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 | |||
}; |
@@ -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; |
@@ -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 | |||
}; |
@@ -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" | |||
} |
@@ -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(); | |||
}); |
@@ -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(); | |||
}); |
@@ -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> |
@@ -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 |
@@ -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>. |
@@ -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); |
@@ -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" | |||
} |
@@ -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) |
@@ -47,4 +47,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -39,4 +39,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* depending on the values of the async tests. Invoked with (err, result). | |||
*/ | |||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_notId2.default, _notId2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* depending on the values of the async tests. Invoked with (err, result). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -49,4 +49,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(Boolean, _identity2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -40,4 +40,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* tests. Invoked with (err, result). | |||
*/ | |||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(Boolean, _identity2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -35,4 +35,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* tests. Invoked with (err, result). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_someLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -65,4 +65,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* two | |||
* three | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -48,4 +48,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* ); | |||
*/ | |||
exports.default = (0, _applyEach2.default)(_map2.default); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* function call. | |||
*/ | |||
exports.default = (0, _applyEach2.default)(_mapSeries2.default); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -107,4 +107,4 @@ function invokeCallback(callback, error, value) { | |||
function rethrow(error) { | |||
throw error; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -286,4 +286,4 @@ module.exports = exports['default']; | |||
* console.log('err = ', err); | |||
* console.log('results = ', results); | |||
* }); | |||
*/ | |||
*/ |
@@ -167,4 +167,4 @@ function autoInject(tasks, callback) { | |||
(0, _auto2.default)(newTasks, callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -91,4 +91,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function cargo(worker, payload) { | |||
return (0, _queue2.default)(worker, 1, payload); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -55,4 +55,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* // result now equals 15 | |||
* }); | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -40,4 +40,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_concatLimit2.default, Infinity); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -62,4 +62,4 @@ var _concat = Array.prototype.concat; | |||
* containing the concatenated results of the `iteratee` function. Invoked with | |||
* (err, results). | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -33,4 +33,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* (err, results). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_concatLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -63,4 +63,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* //... | |||
* }, callback); | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -58,4 +58,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -45,4 +45,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* (err, result). | |||
*/ | |||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -35,4 +35,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* (err, result). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_detectLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -40,4 +40,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* {hello: 'world'} | |||
*/ | |||
exports.default = (0, _consoleFunc2.default)('dir'); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -63,4 +63,4 @@ function doDuring(fn, test, callback) { | |||
check(null, true); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -36,4 +36,4 @@ function doUntil(iteratee, test, callback) { | |||
return !test.apply(this, arguments); | |||
}, callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -56,4 +56,4 @@ function doWhilst(iteratee, test, callback) { | |||
}; | |||
_iteratee(next); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -73,4 +73,4 @@ function during(test, fn, callback) { | |||
_test(check); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -79,4 +79,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function eachLimit(coll, iteratee, callback) { | |||
(0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -42,4 +42,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function eachLimit(coll, limit, iteratee, callback) { | |||
(0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -108,4 +108,4 @@ var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity); | |||
* doSomethingWith(configs); | |||
* }); | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -38,4 +38,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function eachOfLimit(coll, limit, iteratee, callback) { | |||
(0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -32,4 +32,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* functions have finished, or an error occurs. Invoked with (err). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* `iteratee` functions have finished, or an error occurs. Invoked with (err). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -70,4 +70,4 @@ function ensureAsync(fn) { | |||
sync = false; | |||
}); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -47,4 +47,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -39,4 +39,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* depending on the values of the async tests. Invoked with (err, result). | |||
*/ | |||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_notId2.default, _notId2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* depending on the values of the async tests. Invoked with (err, result). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -42,4 +42,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doParallel2.default)(_filter2.default); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* `iteratee` functions have finished. Invoked with (err, results). | |||
*/ | |||
exports.default = (0, _doParallelLimit2.default)(_filter2.default); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -32,4 +32,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* `iteratee` functions have finished. Invoked with (err, results) | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_filterLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -58,4 +58,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -45,4 +45,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* (err, result). | |||
*/ | |||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default)); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -35,4 +35,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* (err, result). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_detectLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -75,4 +75,4 @@ function reduce(coll, memo, iteratee, callback) { | |||
callback(err, memo); | |||
}); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -41,4 +41,4 @@ function reduceRight(array, memo, iteratee, callback) { | |||
var reversed = (0, _slice2.default)(array).reverse(); | |||
(0, _reduce2.default)(reversed, memo, iteratee, callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -79,4 +79,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function eachLimit(coll, iteratee, callback) { | |||
(0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -42,4 +42,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function eachLimit(coll, limit, iteratee, callback) { | |||
(0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -108,4 +108,4 @@ var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity); | |||
* doSomethingWith(configs); | |||
* }); | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -38,4 +38,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
function eachOfLimit(coll, limit, iteratee, callback) { | |||
(0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -32,4 +32,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* functions have finished, or an error occurs. Invoked with (err). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* `iteratee` functions have finished, or an error occurs. Invoked with (err). | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -62,4 +62,4 @@ function forever(fn, errback) { | |||
} | |||
next(); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -51,4 +51,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* }); | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_groupByLimit2.default, Infinity); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -68,4 +68,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* functions have finished, or an error occurs. Result is an `Object` whoses | |||
* properties are arrays of values which returned the corresponding key. | |||
*/ | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -34,4 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
* properties are arrays of values which returned the corresponding key. | |||
*/ | |||
exports.default = (0, _doLimit2.default)(_groupByLimit2.default, 1); | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -579,4 +579,4 @@ exports.foldr = _reduceRight2.default; | |||
exports.select = _filter2.default; | |||
exports.selectLimit = _filterLimit2.default; | |||
exports.selectSeries = _filterSeries2.default; | |||
exports.wrapSync = _asyncify2.default; | |||
exports.wrapSync = _asyncify2.default; |
@@ -75,4 +75,4 @@ function reduce(coll, memo, iteratee, callback) { | |||
callback(err, memo); | |||
}); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -85,4 +85,4 @@ DLL.prototype.remove = function (testFn) { | |||
} | |||
return this; | |||
}; | |||
module.exports = exports["default"]; | |||
module.exports = exports["default"]; |
@@ -35,4 +35,4 @@ function applyEach(eachfn) { | |||
} | |||
}; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", { | |||
// A temporary value used to identify if the loop should be broken. | |||
// See #1064, #1293 | |||
exports.default = {}; | |||
module.exports = exports["default"]; | |||
module.exports = exports["default"]; |
@@ -39,4 +39,4 @@ function consoleFunc(name) { | |||
(0, _wrapAsync2.default)(fn).apply(null, args); | |||
}; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -41,4 +41,4 @@ function _createTester(check, getResult) { | |||
}); | |||
}; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -9,4 +9,4 @@ function doLimit(fn, limit) { | |||
return fn(iterable, limit, iteratee, callback); | |||
}; | |||
} | |||
module.exports = exports["default"]; | |||
module.exports = exports["default"]; |
@@ -20,4 +20,4 @@ function doParallel(fn) { | |||
return fn(_eachOf2.default, obj, (0, _wrapAsync2.default)(iteratee), callback); | |||
}; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -20,4 +20,4 @@ function doParallelLimit(fn) { | |||
return fn((0, _eachOfLimit2.default)(limit), obj, (0, _wrapAsync2.default)(iteratee), callback); | |||
}; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -71,4 +71,4 @@ function _eachOfLimit(limit) { | |||
replenish(); | |||
}; | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -72,4 +72,4 @@ function _filter(eachfn, coll, iteratee, callback) { | |||
var filter = (0, _isArrayLike2.default)(coll) ? filterArray : filterGeneric; | |||
filter(eachfn, coll, (0, _wrapAsync2.default)(iteratee), callback || _noop2.default); | |||
} | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -7,4 +7,4 @@ exports.default = _findGetResult; | |||
function _findGetResult(v, x) { | |||
return x; | |||
} | |||
module.exports = exports["default"]; | |||
module.exports = exports["default"]; |
@@ -10,4 +10,4 @@ exports.default = function (coll) { | |||
var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |
@@ -18,4 +18,4 @@ var _slice2 = _interopRequireDefault(_slice); | |||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |||
module.exports = exports['default']; | |||
module.exports = exports['default']; |