Content-Length: 851376 | pFad | http://github.com/SheetJS/js-codepage/commit/58ebd1ff6c8610e12f37b755e8cf5e75e80b6f76

41 version bump 1.13.0: node 10 deprecation · SheetJS/js-codepage@58ebd1f · GitHub
Skip to content

Commit 58ebd1f

Browse files
committed
version bump 1.13.0: node 10 deprecation
1 parent 122f01a commit 58ebd1f

38 files changed

+260
-207
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
language: node_js
22
node_js:
3+
- "10"
4+
- "9"
35
- "8"
46
- "7"
57
- "6"

codepage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ describe('entry conditions', function() {
565565
var arr = cptable.utils.encode(cp,i.split(""),e);
566566
assert.deepEqual(str,arr);
567567
if(typeof Buffer === 'undefined') return;
568-
var buf = cptable.utils.encode(cp,new Buffer(i),e);
568+
var buf = cptable.utils.encode(cp,Buffer.from(i),e);
569569
assert.deepEqual(str,buf);
570570
};
571571
cptable.utils.cache.encache();
@@ -593,7 +593,7 @@ describe('entry conditions', function() {
593593
var arr = cptable.utils.decode(cp,s.join?s.join(""):s);
594594
assert.deepEqual(str,arr);
595595
if(typeof Buffer === 'undefined') return;
596-
var buf = cptable.utils.decode(cp,new Buffer(i));
596+
var buf = cptable.utils.decode(cp,Buffer.from(i));
597597
assert.deepEqual(str,buf);
598598
};
599599
cptable.utils.cache.encache();
@@ -603,7 +603,7 @@ describe('entry conditions', function() {
603603
};
604604
describe('decode', function() {
605605
it('CP 1252 : sbcs', function() { chkde(1252,[0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]); }); /* "foobar" */
606-
if(typeof Buffer !== 'undefined') it('CP 708 : sbcs', function() { chkde(708, new Buffer([0xca, 0x20, 0x61, 0x6e, 0x64, 0x20, 0xcb, 0x20, 0x73, 0x6d, 0x69, 0x6c, 0x65, 0x79, 0x20, 0x66, 0x61, 0x63, 0x65, 0x73])); }); /* ("ت and ث smiley faces") */
606+
if(typeof Buffer !== 'undefined') it('CP 708 : sbcs', function() { chkde(708, Buffer.from([0xca, 0x20, 0x61, 0x6e, 0x64, 0x20, 0xcb, 0x20, 0x73, 0x6d, 0x69, 0x6c, 0x65, 0x79, 0x20, 0x66, 0x61, 0x63, 0x65, 0x73])); }); /* ("ت and ث smiley faces") */
607607
it('CP 936 : dbcs', function() { chkde(936, [0xd5, 0xe2, 0xca, 0xc7, 0xd6, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xb7, 0xfb, 0xb2, 0xe2, 0xca, 0xd4]);}); /* "这是中文字符测试" */
608608
});
609609
});
@@ -754,7 +754,7 @@ describe('failures', function() {
754754
```json>package.json
755755
{
756756
"name": "codepage",
757-
"version": "1.12.1",
757+
"version": "1.13.0",
758758
"author": "SheetJS",
759759
"description": "pure-JS library to handle codepages",
760760
"keywords": [ "codepage", "iconv", "convert", "strings" ],
@@ -767,7 +767,7 @@ describe('failures', function() {
767767
"buffer": "false"
768768
},
769769
"dependencies": {
770-
"commander": "~2.13.1",
770+
"commander": "~2.14.1",
771771
"exit-on-epipe": "~1.0.1"
772772
},
773773
"devDependencies": {
@@ -776,7 +776,7 @@ describe('failures', function() {
776776
"blanket": "~1.2.3",
777777
"@sheetjs/uglify-js": "~2.7.3",
778778
"@types/node": "^8.0.7",
779-
"@types/commander": "^2.9.0",
779+
"@types/commander": "^2.12.0",
780780
"dtslint": "^0.1.2",
781781
"typescript": "2.2.0"
782782
},

cpexcel.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.

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.flow.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ type DecoderMap = {[id:CPIndex]:Decoder};
4848

4949
var has_buf/*:boolean*/ = (typeof Buffer !== 'undefined');
5050
if(has_buf) {
51-
var mdl = 1024, mdb = new Buffer(mdl);
51+
// $FlowIgnore
52+
if(!Buffer.from) Buffer.from = function(buf, enc) { return (enc) ? new Buffer(buf, enc) : new Buffer(buf); };
53+
// $FlowIgnore
54+
if(!Buffer.allocUnsafe) Buffer.allocUnsafe = function(n) { return new Buffer(n); };
55+
56+
var mdl = 1024, mdb = Buffer.allocUnsafe(mdl);
5257
var make_EE = function make_EE(E/*:EMap*/)/*:Buffer*/{
53-
var EE = new Buffer(65536);
58+
var EE = Buffer.allocUnsafe(65536);
5459
for(var i = 0; i < 65536;++i) EE[i] = 0;
5560
var keys/*:Array<string>*/ = Object.keys(E), len = keys.length;
5661
for(var ee = 0, e = keys[ee]; ee < len; ++ee) {
@@ -65,10 +70,10 @@ type DecoderMap = {[id:CPIndex]:Decoder};
6570
var len = data.length;
6671
var out/*:Buffer*/, i=0, j=0, D=0, w=0;
6772
if(typeof data === 'string') {
68-
out = new Buffer(len);
73+
out = Buffer.allocUnsafe(len);
6974
for(i = 0; i < len; ++i) out[i] = EE[data.charCodeAt(i)];
7075
} else if(/*:: data instanceof Buffer && */Buffer.isBuffer(data)) {
71-
out = new Buffer(2*len);
76+
out = Buffer.allocUnsafe(2*len);
7277
j = 0;
7378
for(i = 0; i < len; ++i) {
7479
D = data[i];
@@ -83,7 +88,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
8388
}
8489
out = out.slice(0,j);
8590
} else {
86-
out = new Buffer(len);
91+
out = Buffer.allocUnsafe(len);
8792
for(i = 0; i < len; ++i) out[i] = EE[/*::(*/data[i]/*:: :any)*/.charCodeAt(0)];
8893
}
8994
if(!ofmt || ofmt === 'buf') return out;
@@ -93,15 +98,15 @@ type DecoderMap = {[id:CPIndex]:Decoder};
9398
};
9499
var sbcs_decode = function make_sbcs_decode(cp/*:CPIndex*/)/*:Decoder*/ {
95100
var D/*:DMap*/ = cpt[cp].dec;
96-
var DD = new Buffer(131072), d=0, c="";
101+
var DD = Buffer.allocUnsafe(131072), d=0, c="";
97102
for(d=0;d<D.length;++d) {
98103
if(!(c=D[d])) continue;
99104
var w = c.charCodeAt(0);
100105
DD[2*d] = w&255; DD[2*d+1] = w>>8;
101106
}
102107
return function sbcs_d(data/*:Data*/)/*:string*/ {
103108
var len = data.length, i=0, j=0;
104-
if(2 * len > mdl) { mdl = 2 * len; mdb = new Buffer(mdl); }
109+
if(2 * len > mdl) { mdl = 2 * len; mdb = Buffer.allocUnsafe(mdl); }
105110
if(/*::data instanceof Buffer && */Buffer.isBuffer(data)) {
106111
for(i = 0; i < len; i++) {
107112
j = 2*data[i];
@@ -123,7 +128,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
123128
};
124129
var dbcs_encode = function make_dbcs_encode(cp/*:CPIndex*/)/*:Encoder*/ {
125130
var E/*:EMap*/ = cpt[cp].enc;
126-
var EE = new Buffer(131072);
131+
var EE = Buffer.allocUnsafe(131072);
127132
for(var i = 0; i < 131072; ++i) EE[i] = 0;
128133
var keys = Object.keys(E);
129134
for(var ee = 0, e = keys[ee]; ee < keys.length; ++ee) {
@@ -132,7 +137,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
132137
EE[2*f] = E[e] & 255; EE[2*f+1] = E[e]>>8;
133138
}
134139
return function dbcs_e(data/*:StrData*/, ofmt/*:?string*/)/*:any*/ {
135-
var len = data.length, out = new Buffer(2*len), i=0, j=0, jj=0, k=0, D=0;
140+
var len = data.length, out = Buffer.allocUnsafe(2*len), i=0, j=0, jj=0, k=0, D=0;
136141
if(typeof data === 'string') {
137142
for(i = k = 0; i < len; ++i) {
138143
j = data.charCodeAt(i)*2;
@@ -166,7 +171,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
166171
};
167172
var dbcs_decode = function make_dbcs_decode(cp/*:CPIndex*/)/*:Decoder*/ {
168173
var D/*:DMap*/ = cpt[cp].dec;
169-
var DD = new Buffer(131072), d=0, c, w=0, j=0, i=0;
174+
var DD = Buffer.allocUnsafe(131072), d=0, c, w=0, j=0, i=0;
170175
for(i = 0; i < 65536; ++i) { DD[2*i] = 0xFF; DD[2*i+1] = 0xFD;}
171176
for(d = 0; d < D.length; ++d) {
172177
if(!(c=D[d])) continue;
@@ -175,7 +180,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
175180
DD[j] = w&255; DD[j+1] = w>>8;
176181
}
177182
return function dbcs_d(data/*:Data*/)/*:string*/ {
178-
var len = data.length, out = new Buffer(2*len), i=0, j=0, k=0;
183+
var len = data.length, out = Buffer.allocUnsafe(2*len), i=0, j=0, k=0;
179184
if(/*::data instanceof Buffer && */Buffer.isBuffer(data)) {
180185
for(i = 0; i < len; i++) {
181186
j = 2*data[i];
@@ -201,7 +206,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
201206
magic_decode[65001] = function utf8_d(data/*:Data*/)/*:string*/ {
202207
if(typeof data === "string") return utf8_d(data.split("").map(cca));
203208
var len = data.length, w = 0, ww = 0;
204-
if(4 * len > mdl) { mdl = 4 * len; mdb = new Buffer(mdl); }
209+
if(4 * len > mdl) { mdl = 4 * len; mdb = Buffer.allocUnsafe(mdl); }
205210
var i = 0;
206211
if(len >= 3 && data[0] == 0xEF) if(data[1] == 0xBB && data[2] == 0xBF) i = 3;
207212
for(var j = 1, k = 0, D = 0; i < len; i+=j) {
@@ -230,7 +235,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
230235
*/
231236
var len = data.length, w = 0, ww = 0, j = 0;
232237
var direct = typeof data === "string";
233-
if(4 * len > mdl) { mdl = 4 * len; mdb = new Buffer(mdl); }
238+
if(4 * len > mdl) { mdl = 4 * len; mdb = Buffer.allocUnsafe(mdl); }
234239
for(var i = 0; i < len; ++i) {
235240
w = direct /*::&& typeof data === "string" */? data.charCodeAt(i) : data[i].charCodeAt(0);
236241
if(w <= 0x007F) mdb[j++] = w;
@@ -313,7 +318,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
313318
if(data instanceof Buffer) throw "";
314319
*/
315320
var len = data.length;
316-
var out = has_buf ? new Buffer(4*len) : [], w=0, i=0, j = 0, ww=0;
321+
var out = has_buf ? Buffer.allocUnsafe(4*len) : [], w=0, i=0, j = 0, ww=0;
317322
var C/*:CPEntry*/ = cpt[cp], E/*:EMap*/, M/*:string*/ = "";
318323
var isstr = typeof data === 'string';
319324
if(C && (E=C.enc)) for(i = 0; i < len; ++i, ++j) {
@@ -325,7 +330,7 @@ type DecoderMap = {[id:CPIndex]:Decoder};
325330
}
326331
else if((M=magic[cp])) switch(M) {
327332
case "utf8":
328-
if(has_buf && isstr/*:: && typeof data == 'string' */) { out = new Buffer(data, M); j = out.length; break; }
333+
if(has_buf && isstr/*:: && typeof data == 'string' */) { out = Buffer.from(data, M); j = out.length; break; }
329334
for(i = 0; i < len; ++i, ++j) {
330335
w = isstr/*:: && typeof data == 'string' */ ? data.charCodeAt(i) : data[i].charCodeAt(0);
331336
if(w <= 0x007F) out[j] = w;
@@ -347,15 +352,15 @@ type DecoderMap = {[id:CPIndex]:Decoder};
347352
}
348353
break;
349354
case "ascii":
350-
if(has_buf && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
355+
if(has_buf && typeof data === "string") { out = Buffer.from(data, M); j = out.length; break; }
351356
for(i = 0; i < len; ++i, ++j) {
352357
w = isstr/*:: && typeof data == 'string' */ ? data.charCodeAt(i) : data[i].charCodeAt(0);
353358
if(w <= 0x007F) out[j] = w;
354359
else throw new Error("bad ascii " + w);
355360
}
356361
break;
357362
case "utf16le":
358-
if(has_buf && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
363+
if(has_buf && typeof data === "string") { out = Buffer.from(data, M); j = out.length; break; }
359364
for(i = 0; i < len; ++i) {
360365
w = isstr/*:: && typeof data == 'string' */ ? data.charCodeAt(i) : data[i].charCodeAt(0);
361366
out[j++] = w&255;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/SheetJS/js-codepage/commit/58ebd1ff6c8610e12f37b755e8cf5e75e80b6f76

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy