Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function Data(capacity) {
* @member {Buffer}
* @private
*/
this._buffer = new Buffer(capacity || 128)
this._buffer = Buffer.alloc(capacity || 128)

/**
* Number of used bytes
Expand Down Expand Up @@ -91,7 +91,7 @@ Data.prototype._alloc = function (bytes) {
buffLen *= 2
} while (this._length + bytes > buffLen)

newBuffer = new Buffer(buffLen)
newBuffer = Buffer.alloc(buffLen)
this._buffer.copy(newBuffer, 0, 0, this._length)
this._buffer = newBuffer
}
Expand Down
4 changes: 2 additions & 2 deletions lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports.string = {
throw new TypeError('Expected a string at ' + path + ', got ' + s)
}

exports.Buffer.write(new Buffer(s), data, path)
exports.Buffer.write(Buffer.from(s), data, path)
},
read: function (state) {
return exports.Buffer.read(state).toString()
Expand Down Expand Up @@ -189,7 +189,7 @@ module.exports.json = {
*/
module.exports.oid = {
write: function (o, data, path) {
var buffer = new Buffer(String(o), 'hex')
var buffer = Buffer.from(String(o), 'hex')
if (buffer.length !== 12) {
throw new TypeError('Expected an object id (12 bytes) at ' + path + ', got ' + o)
}
Expand Down
6 changes: 3 additions & 3 deletions test/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe('types', function () {
})

it('should be sound for Buffer', function () {
check(types.Buffer, new Buffer([]))
check(types.Buffer, new Buffer([3, 14, 15, 92, 65, 35]))
check(types.Buffer, Buffer.from([]))
check(types.Buffer, Buffer.from([3, 14, 15, 92, 65, 35]))
})

it('should be sound for boolean', function () {
Expand Down Expand Up @@ -99,7 +99,7 @@ function write(type, value) {
* @return {*}
*/
function read(hexStr, type) {
var state = new ReadState(new Buffer(hexStr, 'hex')),
var state = new ReadState(Buffer.from(hexStr, 'hex')),
r = type.read(state)
state.hasEnded().should.be.true()
return r
Expand Down