if (obj) {
if (isArrayBufferView(obj) || 'length' in obj) {
- if (typeof obj.length !== 'number' || Number.isNaN(obj.length)) {
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
return createBuffer(0)
}
return fromArrayLike(obj)
byteOffset = -0x80000000
}
byteOffset = +byteOffset // Coerce to Number.
- if (Number.isNaN(byteOffset)) {
+ if (numberIsNaN(byteOffset)) {
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset = dir ? 0 : (buffer.length - 1)
}
}
for (var i = 0; i < length; ++i) {
var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (Number.isNaN(parsed)) return i
+ if (numberIsNaN(parsed)) return i
buf[offset + i] = parsed
}
return i
function isArrayBufferView (obj) {
return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
}
+
+function numberIsNaN (obj) {
+ return obj !== obj // eslint-disable-line no-self-compare
+}