From dfd6372b46cded296943818fd9b28d2d45d2756d Mon Sep 17 00:00:00 2001 From: lijiadong <664320100@qq.com> Date: Fri, 29 Nov 2019 19:36:01 +0800 Subject: [PATCH 1/2] ref dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3422913..0306fd4 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "array-index": "1", "debug": "2", - "ref": "1" + "ref": "git+https://github.com/lijiadong-git/ref.git" }, "devDependencies": { "bindings": "1", From e2027f018e75374e43fff95c361b1cc3a4e1bf2e Mon Sep 17 00:00:00 2001 From: lijiadong <664320100@qq.com> Date: Sat, 30 Nov 2019 16:05:30 +0800 Subject: [PATCH 2/2] use Buffer.alloc replace new Buffer --- lib/array.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/array.js b/lib/array.js index b86ae13..1cf3a27 100644 --- a/lib/array.js +++ b/lib/array.js @@ -36,14 +36,14 @@ module.exports = function Array (_type, _length) { // use the "fixedLength" if provided, otherwise throw an Error if (fixedLength > 0) { this.length = fixedLength - this.buffer = new Buffer(this.length * item_size) + this.buffer = Buffer.alloc(this.length * item_size) } else { throw new Error('A "length", "array" or "buffer" must be passed as the first argument') } } else if ('number' == typeof data) { // new IntArray(69) this.length = data - this.buffer = new Buffer(this.length * item_size) + this.buffer = Buffer.alloc(this.length * item_size) } else if (isArray(data)) { // new IntArray([ 1, 2, 3, 4, 5 ], {len}) // use optional "length" if provided, otherwise use "fixedLength, otherwise @@ -60,7 +60,7 @@ module.exports = function Array (_type, _length) { throw new Error('array length must be at least ' + len + ', got ' + data.length) } this.length = len - this.buffer = new Buffer(len * item_size) + this.buffer = Buffer.alloc(len * item_size) for (var i = 0; i < len; i++) { this[i] = data[i] }