}
if (obj) {
- if (ArrayBuffer.isView(obj) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
+ if (isArrayBufferView(obj) || 'length' in obj) {
return createBuffer(0)
}
return fromArrayLike(obj)
if (Buffer.isBuffer(string)) {
return string.length
}
- if (ArrayBuffer.isView(string) || string instanceof ArrayBuffer) {
+ if (isArrayBufferView(string) || string instanceof ArrayBuffer) {
return string.byteLength
}
if (typeof string !== 'string') {
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
+
+// Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
+function isArrayBufferView (obj) {
+ return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
+}