smart-buffer
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -279,3 +279,18 @@ var SmartBuffer = (function () { | ||
/** | ||
* Writes a null terminated Buffer to the underlying buffer. | ||
* @param value {Buffer} The buffer to write. | ||
* @param offset {Number} The offset to write the Buffer to. | ||
* @returns {*} | ||
*/ | ||
SmartBuffer.prototype.writeBufferNT = function (value, offset) { | ||
var len = value.length; | ||
this._ensureWritable(len, offset); | ||
value.copy(this.buff, offset || this._writeOffset); | ||
this.buff[this._writeOffset + len] = 0x00; | ||
this._writeOffset += len + 1; | ||
return this; | ||
}; | ||
/** | ||
@@ -282,0 +297,0 @@ * Resets the Endless Buffer. |
{ | ||
"name": "smart-buffer", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A smarter Buffer that keeps track of its own read and write positions while growing endlessly.", | ||
@@ -37,2 +37,3 @@ "main": "lib/smart-buffer.js", | ||
}, | ||
"typings": "typings/index", | ||
"dependencies": {}, | ||
@@ -39,0 +40,0 @@ "scripts": { |
@@ -246,3 +246,10 @@ smart-buffer [![Build Status](https://travis-ci.org/JoshGlazebrook/smart-buffer.svg?branch=master)](https://travis-ci.org/JoshGlazebrook/smart-buffer) [![Coverage Status](https://coveralls.io/repos/github/JoshGlazebrook/smart-buffer/badge.svg?branch=master)](https://coveralls.io/github/JoshGlazebrook/smart-buffer?branch=master) | ||
### SmartBuffer.writeBufferNT( value, [offset] ) | ||
> `Buffer` **Buffer value to write** | ||
> `Number` **The position to insert this Buffer's content at** | ||
returns this | ||
## Utility Functions | ||
@@ -249,0 +256,0 @@ |
@@ -230,2 +230,14 @@ var SmartBuffer = require('../lib/smart-buffer.js'); | ||
}); | ||
}); | ||
describe('Null Terminated Buffer Writing', function () { | ||
var buff = new SmartBuffer(); | ||
buff.writeBufferNT(new Buffer([0x01, 0x02, 0x03, 0x04])); | ||
var read1 = buff.readBufferNT(); | ||
it('Should read the correct null terminated buffer data.', function () { | ||
assert.equal(read1.length, 4); | ||
}); | ||
}) | ||
@@ -232,0 +244,0 @@ |
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
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
51851
8
922
307