Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb47efb2

Browse files
[fix] Remove any reference to theglobal variable
Related:socketio/socket.io-client#1166
1 parentd95e38f commitb47efb2

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

‎binary.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
varisArray=require('isarray');
88
varisBuf=require('./is-buffer');
99
vartoString=Object.prototype.toString;
10-
varwithNativeBlob=typeofglobal.Blob==='function'||toString.call(global.Blob)==='[object BlobConstructor]';
11-
varwithNativeFile=typeofglobal.File==='function'||toString.call(global.File)==='[object FileConstructor]';
10+
varwithNativeBlob=typeofBlob==='function'||(typeofBlob!=='undefined'&&toString.call(Blob)==='[object BlobConstructor]');
11+
varwithNativeFile=typeofFile==='function'||(typeofFile!=='undefined'&&toString.call(File)==='[object FileConstructor]');
1212

1313
/**
1414
* Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.

‎is-buffer.js‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11

22
module.exports=isBuf;
33

4-
varwithNativeBuffer=typeofglobal.Buffer==='function'&&typeofglobal.Buffer.isBuffer==='function';
5-
varwithNativeArrayBuffer=typeofglobal.ArrayBuffer==='function';
4+
varwithNativeBuffer=typeofBuffer==='function'&&typeofBuffer.isBuffer==='function';
5+
varwithNativeArrayBuffer=typeofArrayBuffer==='function';
66

7-
varisView=(function(){
8-
if(withNativeArrayBuffer&&typeofglobal.ArrayBuffer.isView==='function'){
9-
returnglobal.ArrayBuffer.isView;
10-
}else{
11-
returnfunction(obj){returnobj.bufferinstanceofglobal.ArrayBuffer;};
12-
}
13-
})();
7+
varisView=function(obj){
8+
returntypeofArrayBuffer.isView==='function' ?ArrayBuffer.isView(obj) :(obj.bufferinstanceofArrayBuffer);
9+
};
1410

1511
/**
1612
* Returns true if obj is a buffer or an arraybuffer.
@@ -19,6 +15,6 @@ var isView = (function () {
1915
*/
2016

2117
functionisBuf(obj){
22-
return(withNativeBuffer&&global.Buffer.isBuffer(obj))||
23-
(withNativeArrayBuffer&&(objinstanceofglobal.ArrayBuffer||isView(obj)));
18+
return(withNativeBuffer&&Buffer.isBuffer(obj))||
19+
(withNativeArrayBuffer&&(objinstanceofArrayBuffer||isView(obj)));
2420
}

‎test/blob.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
varparser=require('../index.js');
2-
varexpect=require('expect.js');
32
varhelpers=require('./helpers.js');
4-
varencode=parser.encode;
5-
vardecode=parser.decode;
63

7-
varBlobBuilder=global.BlobBuilder||global.WebKitBlobBuilder||global.MSBlobBuilder||global.MozBlobBuilder;
4+
varBlobBuilder=typeofBlobBuilder!=='undefined' ?BlobBuilder :
5+
typeofWebKitBlobBuilder!=='undefined' ?WebKitBlobBuilder :
6+
typeofMSBlobBuilder!=='undefined' ?MSBlobBuilder :
7+
typeofMozBlobBuilder!=='undefined' ?MozBlobBuilder :false;
88

99
describe('parser',function(){
1010
it('encodes a Blob',function(){

‎test/index.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ var blobSupported = (function() {
1212
* Create a blob builder even when vendor prefixes exist
1313
*/
1414

15-
varBlobBuilder=global.BlobBuilder||global.WebKitBlobBuilder||global.MSBlobBuilder||global.MozBlobBuilder;
15+
varBlobBuilder=typeofBlobBuilder!=='undefined' ?BlobBuilder :
16+
typeofWebKitBlobBuilder!=='undefined' ?WebKitBlobBuilder :
17+
typeofMSBlobBuilder!=='undefined' ?MSBlobBuilder :
18+
typeofMozBlobBuilder!=='undefined' ?MozBlobBuilder :false;
1619
varblobBuilderSupported=!!BlobBuilder&&!!BlobBuilder.prototype.append&&!!BlobBuilder.prototype.getBlob;
1720

1821
require('./parser.js');
@@ -21,7 +24,7 @@ if (!env.browser) {
2124
require('./buffer.js');
2225
}
2326

24-
if(global.ArrayBuffer){
27+
if(typeofArrayBuffer!=='undefined'){
2528
require('./arraybuffer.js');
2629
}
2730

‎test/support/env.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// we only do this in our tests because we need to test engine.io-client
33
// support in browsers and in node.js
44
// some tests do not yet work in both
5-
module.exports.browser=!!global.window;
5+
module.exports.browser=typeofwindow!=='undefined';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp