Skip to content

use new to instantiate all buffers #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2016
Merged
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
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function stringConcat (parts) {
} else if (Buffer.isBuffer(p)) {
strings.push(p)
} else {
strings.push(Buffer(p))
strings.push(new Buffer(p))
}
}
if (Buffer.isBuffer(parts[0])) {
Expand All @@ -103,8 +103,8 @@ function bufferConcat (parts) {
bufs.push(p)
} else if (typeof p === 'string' || isArrayish(p)
|| (p && typeof p.subarray === 'function')) {
bufs.push(Buffer(p))
} else bufs.push(Buffer(String(p)))
bufs.push(new Buffer(p))
} else bufs.push(new Buffer(String(p)))
}
return Buffer.concat(bufs)
}
Expand All @@ -121,7 +121,7 @@ function u8Concat (parts) {
var len = 0
for (var i = 0; i < parts.length; i++) {
if (typeof parts[i] === 'string') {
parts[i] = Buffer(parts[i])
parts[i] = new Buffer(parts[i])
}
len += parts[i].length
}
Expand Down
2 changes: 1 addition & 1 deletion test/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('string from mixed write encodings', function (t) {
t.equal(out, 'nacho dogs')
})
strings.write('na')
strings.write(Buffer('cho'))
strings.write(new Buffer('cho'))
strings.write([ 32, 100 ])
var u8 = new U8(3)
u8[0] = 111; u8[1] = 103; u8[2] = 115;
Expand Down
6 changes: 3 additions & 3 deletions test/typedarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('typed array stream', function (t) {

var arrays = concat({ encoding: 'Uint8Array' }, function(out) {
t.equal(typeof out.subarray, 'function')
t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz')
t.deepEqual(new Buffer(out).toString('utf8'), 'abcde fg xyz')
})
arrays.write(a)
arrays.write(b)
Expand All @@ -25,9 +25,9 @@ test('typed array from strings, buffers, and arrays', function (t) {
t.plan(2)
var arrays = concat({ encoding: 'Uint8Array' }, function(out) {
t.equal(typeof out.subarray, 'function')
t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz')
t.deepEqual(new Buffer(out).toString('utf8'), 'abcde fg xyz')
})
arrays.write('abcde')
arrays.write(Buffer(' fg '))
arrays.write(new Buffer(' fg '))
arrays.end([ 120, 121, 122 ])
})