Skip to content

Commit cc78f49

Browse files
authored
avoid using global
global is not standard in the browser (yet?), using it blocks using this lib with some build tools (e.g., angular-cli with socket.io imports)
1 parent ffafc3e commit cc78f49

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
* Create a blob builder even when vendor prefixes exist
33
*/
44

5-
var BlobBuilder = global.BlobBuilder
6-
|| global.WebKitBlobBuilder
7-
|| global.MSBlobBuilder
8-
|| global.MozBlobBuilder;
5+
var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
6+
typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
7+
typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
8+
typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
9+
false;
910

1011
/**
1112
* Check if Blob constructor is supported
@@ -83,14 +84,14 @@ function BlobConstructor(ary, options) {
8384
return new Blob(mapArrayBufferViews(ary), options || {});
8485
};
8586

86-
if (global.Blob) {
87+
if (typeof Blob !== 'undefined') {
8788
BlobBuilderConstructor.prototype = Blob.prototype;
8889
BlobConstructor.prototype = Blob.prototype;
8990
}
9091

9192
module.exports = (function() {
9293
if (blobSupported) {
93-
return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
94+
return blobSupportsArrayBufferView ? Blob : BlobConstructor;
9495
} else if (blobBuilderSupported) {
9596
return BlobBuilderConstructor;
9697
} else {

0 commit comments

Comments
 (0)