Skip to content
Open
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
6 changes: 3 additions & 3 deletions lib/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
}
Expand Down