// Find the length
var length
if (type === 'number')
- length = subject > 0 ? subject >>> 0 : 0
+ length = +subject
else if (type === 'string') {
length = Buffer.byteLength(subject, encoding)
} else if (type === 'object' && subject !== null) { // assume object is array-like
if (subject.type === 'Buffer' && isArray(subject.data))
subject = subject.data
- length = +subject.length > 0 ? Math.floor(+subject.length) : 0
+ length = +subject.length
} else {
throw new TypeError('must start with number, buffer, array or string')
}
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength.toString(16) + ' bytes')
+ if (length < 0)
+ length = 0
+ else
+ length >>>= 0 // Coerce to uint32.
+
var self = this
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Preferred: Return an augmented `Uint8Array` instance for best performance