Skip to content

Commit 422560f

Browse files
committed
Merge pull request #2 from xch89820/master
Fix the function of judging the commonJS environment
2 parents 871c25a + f2ffe97 commit 422560f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

cptable.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cputils.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
if(typeof cptable === "undefined" && typeof require !== "undefined") var cptable = require('./cptable');
2-
3-
(function(cpt){
1+
(function(root, factory){
2+
"use strict";
3+
if(typeof cptable === "undefined" && typeof require !== "undefined"){
4+
var cpt = require('./cptable');
5+
if (typeof module !== 'undefined' && module.exports){
6+
module.exports = factory(cpt);
7+
}else{
8+
root.cptable = factory(cpt);
9+
}
10+
}else{
11+
throw "cptable not found";
12+
}
13+
}(this, function(cpt){
414
var magic = {
515
"1200":"utf16le",
616
"1201":"utf16be",
@@ -72,6 +82,6 @@ if(typeof cptable === "undefined" && typeof require !== "undefined") var cptable
7282
return cpt[cp] || magic[cp];
7383
};
7484
cpt.utils = { decode: decode, encode: encode, hascp: hascp, magic: magic };
75-
})(cptable);
85+
return cpt;
86+
}));
7687

77-
if(typeof module !== "undefined") module.exports = cptable;

sbcs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)