@ldapjs/asn1
Advanced tools
Comparing version 1.0.1 to 1.2.0-rc.1
@@ -58,2 +58,20 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
/** | ||
* Append a raw buffer to the current writer instance. No validation to | ||
* determine if the buffer represents a valid BER encoding is performed. | ||
* | ||
* @param {Buffer} buffer The buffer to append. If this is not a valid BER | ||
* sequence of data, it will invalidate the BER represented by the `BerWriter`. | ||
* | ||
* @throws If the input is not an instance of Buffer. | ||
*/ | ||
Writer.prototype.appendBuffer = function appendBuffer (buffer) { | ||
if (Buffer.isBuffer(buffer) === false) { | ||
throw Error('buffer must be an instance of Buffer') | ||
} | ||
for (const b of buffer.values()) { | ||
this.writeByte(b) | ||
} | ||
} | ||
Writer.prototype.writeByte = function (b) { | ||
@@ -60,0 +78,0 @@ if (typeof (b) !== 'number') { throw new TypeError('argument must be a Number') } |
@@ -337,1 +337,9 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
}) | ||
test('appendBuffer appends a buffer', async t => { | ||
const expected = Buffer.from([0x04, 0x03, 0x66, 0x6f, 0x6f, 0x66, 0x6f, 0x6f]) | ||
const writer = new BerWriter() | ||
writer.writeString('foo') | ||
writer.appendBuffer(Buffer.from('foo')) | ||
t.equal(Buffer.compare(writer.buffer, expected), 0) | ||
}) |
@@ -11,3 +11,3 @@ { | ||
"description": "Contains parsers and serializers for ASN.1 (currently BER only)", | ||
"version": "1.0.1", | ||
"version": "1.2.0-rc.1", | ||
"repository": { | ||
@@ -14,0 +14,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33265
909
2