Skip to content

Commit

Permalink
fix: avoid use of global (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitport authored and darrachequesne committed May 14, 2018
1 parent 02266c0 commit 91aa21e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 91aa21e

Please sign in to comment.