Fixed Buffer deprecated warnings when using node >= v10

This commit is contained in:
Nicolas Dextraze
2019-11-01 12:53:24 -07:00
parent 78677ba53e
commit 67dab18d53
8 changed files with 43 additions and 29 deletions

View File

@ -14,14 +14,14 @@ function parse(s, buf, offset) {
var ii = 0;
if (buf) buf.fill(0, i, i + 16);
buf = buf || new Buffer(16);
buf = buf || Buffer.alloc(16);
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
if (ii < 16) { // Don't overflow!
buf[i + ii++] = _hexToByte[oct];
}
});
var buf2 = new Buffer(buf.slice(i, i + 16));
var buf2 = Buffer.from(buf.slice(i, i + 16));
buf[i + 0] = buf2[3];
buf[i + 1] = buf2[2];
buf[i + 2] = buf2[1];
@ -44,4 +44,4 @@ function unparse(buf, offset) {
}
exports.parse = parse;
exports.unparse = unparse;
exports.unparse = unparse;