diff --git a/index.js b/index.js index c543498..cf756a3 100644 --- a/index.js +++ b/index.js @@ -7,8 +7,10 @@ var isArray = require('isarray'); var toString = Object.prototype.toString; -var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]'; -var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]'; +var withNativeBlob = typeof Blob === 'function' || + typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]'; +var withNativeFile = typeof File === 'function' || + typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]'; /** * Module exports. @@ -39,11 +41,11 @@ function hasBinary (obj) { return false; } - if ((typeof global.Buffer === 'function' && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || - (typeof global.ArrayBuffer === 'function' && obj instanceof ArrayBuffer) || - (withNativeBlob && obj instanceof Blob) || - (withNativeFile && obj instanceof File) - ) { + if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) || + (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) || + (withNativeBlob && obj instanceof Blob) || + (withNativeFile && obj instanceof File) + ) { return true; }