Fixed Buffer deprecated warnings when using node >= v10
This commit is contained in:
parent
78677ba53e
commit
67dab18d53
33
package-lock.json
generated
33
package-lock.json
generated
|
@ -1984,7 +1984,8 @@
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
@ -2005,12 +2006,14 @@
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
@ -2031,7 +2034,8 @@
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
|
@ -2182,6 +2186,7 @@
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
@ -2189,12 +2194,14 @@
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
|
@ -2213,6 +2220,7 @@
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
|
@ -2306,6 +2314,7 @@
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
|
@ -2391,7 +2400,8 @@
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -2447,6 +2457,7 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -2490,12 +2501,14 @@
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -4181,9 +4194,9 @@
|
||||||
"integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q=="
|
"integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q=="
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "10.14.14",
|
"version": "10.17.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.3.tgz",
|
||||||
"integrity": "sha512-xXD08vZsvpv4xptQXj1+ky22f7ZoKu5ZNI/4l+/BXG3X+XaeZsmaFbbTKuhSE3NjjvRuZFxFf9sQBMXIcZNFMQ=="
|
"integrity": "sha512-QZ9CjUB3QoA3f2afw3utKlfRPhpmufB7jC2+oDhLWnXqoyx333fhKSQDLQu2EK7OE0a15X67eYiRAaJsHXrpMA=="
|
||||||
},
|
},
|
||||||
"long": {
|
"long": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0"
|
"node": ">=5.10"
|
||||||
},
|
},
|
||||||
"engineStrict": true,
|
"engineStrict": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm lib/dist.js",
|
"clean": "rm lib/dist.js",
|
||||||
|
"prebuild": "npm run clean",
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"pretest": "npm run build",
|
"pretest": "npm run build",
|
||||||
"test": "nodeunit",
|
"test": "nodeunit",
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/nicdex/node-eventstore-client#readme",
|
"homepage": "https://github.com/nicdex/node-eventstore-client#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"long": "^3.2",
|
"long": "^3.2.0",
|
||||||
"protobufjs": "^6.8.8",
|
"protobufjs": "^6.8.8",
|
||||||
"strict-event-emitter-types": "^1.2.0",
|
"strict-event-emitter-types": "^1.2.0",
|
||||||
"uuid": "^3.0.1"
|
"uuid": "^3.0.1"
|
||||||
|
|
|
@ -33,8 +33,8 @@ Object.freeze(streamPosition);
|
||||||
function createJsonEventData(eventId, event, metadata, type) {
|
function createJsonEventData(eventId, event, metadata, type) {
|
||||||
if (!event || typeof event !== 'object') throw new TypeError("data must be an object.");
|
if (!event || typeof event !== 'object') throw new TypeError("data must be an object.");
|
||||||
|
|
||||||
var eventBuf = new Buffer(JSON.stringify(event));
|
var eventBuf = Buffer.from(JSON.stringify(event));
|
||||||
var metaBuf = metadata ? new Buffer(JSON.stringify(metadata)) : null;
|
var metaBuf = metadata ? Buffer.from(JSON.stringify(metadata)) : null;
|
||||||
return new EventData(eventId, type || event.constructor.name, true, eventBuf, metaBuf);
|
return new EventData(eventId, type || event.constructor.name, true, eventBuf, metaBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@ function parse(s, buf, offset) {
|
||||||
var ii = 0;
|
var ii = 0;
|
||||||
|
|
||||||
if (buf) buf.fill(0, i, i + 16);
|
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) {
|
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
|
||||||
if (ii < 16) { // Don't overflow!
|
if (ii < 16) { // Don't overflow!
|
||||||
buf[i + ii++] = _hexToByte[oct];
|
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 + 0] = buf2[3];
|
||||||
buf[i + 1] = buf2[2];
|
buf[i + 1] = buf2[2];
|
||||||
buf[i + 2] = buf2[1];
|
buf[i + 2] = buf2[1];
|
||||||
|
@ -44,4 +44,4 @@ function unparse(buf, offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.parse = parse;
|
exports.parse = parse;
|
||||||
exports.unparse = unparse;
|
exports.unparse = unparse;
|
||||||
|
|
|
@ -24,8 +24,8 @@ function EventData(eventId, type, isJson, data, metadata) {
|
||||||
this.eventId = eventId;
|
this.eventId = eventId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.isJson = isJson || false;
|
this.isJson = isJson || false;
|
||||||
this.data = data || new Buffer(0);
|
this.data = data || Buffer.alloc(0);
|
||||||
this.metadata = metadata || new Buffer(0);
|
this.metadata = metadata || Buffer.alloc(0);
|
||||||
Object.freeze(this);
|
Object.freeze(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,7 @@ EventStoreNodeConnection.prototype.setStreamMetadataRaw = function(
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
var data = metadata ? new Buffer(JSON.stringify(metadata)) : null;
|
var data = metadata ? Buffer.from(JSON.stringify(metadata)) : null;
|
||||||
var metaevent = new EventData(uuid.v4(), systemEventTypes.StreamMetadata, true, data, null);
|
var metaevent = new EventData(uuid.v4(), systemEventTypes.StreamMetadata, true, data, null);
|
||||||
self._enqueueOperation(
|
self._enqueueOperation(
|
||||||
new AppendToStreamOperation(self._settings.log, cb, self._settings.requireMaster,
|
new AppendToStreamOperation(self._settings.log, cb, self._settings.requireMaster,
|
||||||
|
@ -720,4 +720,4 @@ EventStoreNodeConnection.prototype._enqueueOperation = function(operation) {
|
||||||
setImmediate(tryEnqueue)
|
setImmediate(tryEnqueue)
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = EventStoreNodeConnection;
|
module.exports = EventStoreNodeConnection;
|
||||||
|
|
|
@ -50,12 +50,12 @@ TcpPackage.fromBufferSegment = function(data) {
|
||||||
|
|
||||||
TcpPackage.prototype.asBuffer = function() {
|
TcpPackage.prototype.asBuffer = function() {
|
||||||
if ((this.flags & TcpFlags.Authenticated) !== 0) {
|
if ((this.flags & TcpFlags.Authenticated) !== 0) {
|
||||||
var loginBytes = new Buffer(this.login);
|
var loginBytes = Buffer.from(this.login);
|
||||||
if (loginBytes.length > 255) throw new Error("Login serialized length should be less than 256 bytes.");
|
if (loginBytes.length > 255) throw new Error("Login serialized length should be less than 256 bytes.");
|
||||||
var passwordBytes = new Buffer(this.password);
|
var passwordBytes = Buffer.from(this.password);
|
||||||
if (passwordBytes.length > 255) throw new Error("Password serialized length should be less than 256 bytes.");
|
if (passwordBytes.length > 255) throw new Error("Password serialized length should be less than 256 bytes.");
|
||||||
|
|
||||||
var res = new Buffer(MandatorySize + 2 + loginBytes.length + passwordBytes.length + (this.data ? this.data.count : 0));
|
var res = Buffer.alloc(MandatorySize + 2 + loginBytes.length + passwordBytes.length + (this.data ? this.data.count : 0));
|
||||||
res[CommandOffset] = this.command;
|
res[CommandOffset] = this.command;
|
||||||
res[FlagsOffset] = this.flags;
|
res[FlagsOffset] = this.flags;
|
||||||
guidParse.parse(this.correlationId, res, CorrelationOffset);
|
guidParse.parse(this.correlationId, res, CorrelationOffset);
|
||||||
|
@ -69,7 +69,7 @@ TcpPackage.prototype.asBuffer = function() {
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
var res = new Buffer(MandatorySize + (this.data ? this.data.count : 0));
|
var res = Buffer.alloc(MandatorySize + (this.data ? this.data.count : 0));
|
||||||
res[CommandOffset] = this.command;
|
res[CommandOffset] = this.command;
|
||||||
res[FlagsOffset] = this.flags;
|
res[FlagsOffset] = this.flags;
|
||||||
guidParse.parse(this.correlationId, res, CorrelationOffset);
|
guidParse.parse(this.correlationId, res, CorrelationOffset);
|
||||||
|
@ -82,4 +82,4 @@ TcpPackage.prototype.asBufferSegment = function() {
|
||||||
return createBufferSegment(this.asBuffer());
|
return createBufferSegment(this.asBuffer());
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = TcpPackage;
|
module.exports = TcpPackage;
|
||||||
|
|
|
@ -35,7 +35,7 @@ LengthPrefixMessageFramer.prototype._parse = function(bytes) {
|
||||||
throw new Error(["Package size is out of bounds: ", this._packageLength, "(max: ", this._maxPackageSize, "."].join(''));
|
throw new Error(["Package size is out of bounds: ", this._packageLength, "(max: ", this._maxPackageSize, "."].join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._messageBuffer = new Buffer(this._packageLength);
|
this._messageBuffer = Buffer.alloc(this._packageLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -58,7 +58,7 @@ LengthPrefixMessageFramer.prototype._parse = function(bytes) {
|
||||||
|
|
||||||
LengthPrefixMessageFramer.prototype.frameData = function(data) {
|
LengthPrefixMessageFramer.prototype.frameData = function(data) {
|
||||||
var length = data.count;
|
var length = data.count;
|
||||||
var lengthBuffer = new Buffer(HeaderLength);
|
var lengthBuffer = Buffer.alloc(HeaderLength);
|
||||||
lengthBuffer.writeInt32LE(length, 0);
|
lengthBuffer.writeInt32LE(length, 0);
|
||||||
return [
|
return [
|
||||||
createBufferSegment(lengthBuffer, 0, HeaderLength),
|
createBufferSegment(lengthBuffer, 0, HeaderLength),
|
||||||
|
@ -71,4 +71,4 @@ LengthPrefixMessageFramer.prototype.registerMessageArrivedCallback = function(ha
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = LengthPrefixMessageFramer;
|
module.exports = LengthPrefixMessageFramer;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user