10000 Improve CommonJS compatibility · adon-at-work/bytebuffer.js@4e78477 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e78477

Browse files
committed
Improve CommonJS compatibility
1 parent 9882b63 commit 4e78477

File tree

9 files changed

+22
-14
lines changed

9 files changed

+22
-14
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bytebuffer",
3-
"version": "3.4.0",
3+
"version": "3.5.0",
44
"author": "Daniel Wirtz <dcode@dcode.io>",
55
"description": "A full-featured ByteBuffer implementation using typed arrays.",
66
"main": "dist/ByteBufferAB.js",

dist/ByteBufferAB.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
* @const
117117
* @expose
118118
*/
119-
ByteBuffer.VERSION = "3.4.0";
119+
ByteBuffer.VERSION = "3.5.0";
120120

121121
/**
122122
* Little endian constant that can be used instead of its boolean value. Evaluates to `true`.
@@ -3263,8 +3263,11 @@
32633263
return ByteBuffer;
32643264
}
32653265

3266-
/* CommonJS */ if (typeof module !== 'undefined' && module["exports"])
3267-
module["exports"] = loadByteBuffer(require("long"));
3266+
/* CommonJS */ if (typeof require === 'function' && typeof module === 'object' && module && module.id && typeof exports === 'object' && exports)
3267+
module['exports'] = (function() {
3268+
var Long; try { Long = require("long"); } catch (e) {}
3269+
return loadByteBuffer(Long);
3270+
})();
32683271
/* AMD */ else if (typeof define === 'function' && define["amd"])
32693272
define("ByteBuffer", ["Long"], function(Long) { return loadByteBuffer(Long); });
32703273
/* Global */ else

dist/ByteBufferAB.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ByteBufferAB.min.js.gz

30 Bytes
Binary file not shown.

dist/ByteBufferAB.min.map

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/ByteBufferNB.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module.exports = (function() {
108108
* @const
109109
* @expose
110110
*/
111-
ByteBuffer.VERSION = "3.4.0";
111+
ByteBuffer.VERSION = "3.5.0";
112112

113113
/**
114114
* Little endian constant that can be used instead of its boolean value. Evaluates to `true`.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bytebuffer",
3-
"version": "3.4.0",
3+
"version": "3.5.0",
44
"author": "Daniel Wirtz <dcode@dcode.io>",
55
"description": "The swiss army knife for binary data in JavaScript.",
66
"main": "index.js",
@@ -14,7 +14,7 @@
1414
},
1515
"keywords": ["net", "array", "buffer", "arraybuffer", "typed array", "bytebuffer", "json", "websocket", "webrtc"],
1616
"dependencies": {
17-
"long": "~2",
17+
"long": "~2 >=2.2",
1818
"bufferview": "~1"
1919
},
2020
"devDependencies": {

src/ByteBufferAB.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@
3636
return ByteBuffer;
3737
}
3838

39-
/* CommonJS */ if (typeof module !== 'undefined' && module["exports"])
40-
module["exports"] = loadByteBuffer(require("long"));
39+
/* CommonJS */ if (typeof require === 'function' && typeof module === 'object' && module && module.id && typeof exports === 'object' && exports)
40+
module['exports'] = (function() {
41+
var Long; try { Long = require("long"); } catch (e) {}
42+
return loadByteBuffer(Long);
43+
})();
4144
/* AMD */ else if (typeof define === 'function' && define["amd"])
4245
define("ByteBuffer", ["Long"], function(Long) { return loadByteBuffer(Long); });
4346
/* Global */ else

tests/suite.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,10 @@ function makeSuite(ByteBuffer) {
941941
}
942942
},
943943
module: {
944-
exports: {}
944+
exports: {},
945+
id: "bytebuffer"
945946
},
947+
exports: {},
946948
ArrayBuffer: ArrayBuffer,
947949
DataView: DataView
948950
});

0 commit comments

Comments
 (0)
0