Skip to content

Commit 69bb1e7

Browse files
committed
"side-effect free"
1 parent 90a7b4e commit 69bb1e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1089
-1295
lines changed

.github/workflows/deno.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
# full test
2525
full:
2626
runs-on: ubuntu-latest
27-
env:
28-
FMTS: misc # TODO: remove this
2927
steps:
3028
- uses: actions/checkout@v2
3129
- uses: denoland/setup-deno@main

.spelling

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ FileReader
8383
JS
8484
NoSQL
8585
README
86+
UTF-8
8687
UTF-16
8788
VBScript
8889
XHR

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
191191

192192
.PHONY: old-lint
193193
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
194+
@./node_modules/.bin/jscs $(TARGET) $(AUXTARGETS) test.js
194195
@./node_modules/.bin/jshint --show-non-errors $(TARGET) $(AUXTARGETS)
195196
@./node_modules/.bin/jshint --show-non-errors $(CMDS)
196197
@./node_modules/.bin/jshint --show-non-errors package.json bower.json test.js
197198
@./node_modules/.bin/jshint --show-non-errors --extract=always $(HTMLLINT)
198-
@./node_modules/.bin/jscs $(TARGET) $(AUXTARGETS) test.js
199199
@if [ -x "$(CLOSURE)" ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
200200

201201
.PHONY: tslint

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,9 @@ The `type` argument for `write` mirrors the `type` argument for `read`:
34163416
| `"array"` | ArrayBuffer, fallback array of 8-bit unsigned int |
34173417
| `"file"` | string: path of file that will be created (nodejs only) |
34183418
3419+
- For compatibility with Excel, `csv` output will always include the UTF-8 byte
3420+
order mark.
3421+
34193422
## Utility Functions
34203423
34213424
The `sheet_to_*` functions accept a worksheet and an optional options object.
@@ -3759,6 +3762,10 @@ produces CSV output. The function takes an options argument:
37593762
- `blankrows` must be set to `false` to skip blank lines.
37603763
- Fields containing the record or field separator will automatically be wrapped
37613764
in double quotes; `forceQuotes` forces all cells to be wrapped in quotes.
3765+
- `XLSX.write` with `csv` type will always prepend the UTF-8 byte-order mark for
3766+
Excel compatibility. `sheet_to_csv` returns a JS string and omits the mark.
3767+
Using `XLSX.write` with type `string` will also skip the mark.
3768+
37623769
37633770
<details>
37643771
<summary><b>Examples</b> (click to show)</summary>

bits/05_buf.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
var has_buf = (typeof Buffer !== 'undefined' && typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.node);
1+
var has_buf = /*#__PURE__*/(function() { return typeof Buffer !== 'undefined' && typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.node; })();
22

3-
var Buffer_from = /*::(*/function(){}/*:: :any)*/;
3+
var Buffer_from = /*#__PURE__*/(function() {
4+
if(typeof Buffer !== 'undefined') {
5+
var nbfs = !Buffer.from;
6+
if(!nbfs) try { Buffer.from("foo", "utf8"); } catch(e) { nbfs = true; }
7+
return nbfs ? function(buf, enc) { return (enc) ? new Buffer(buf, enc) : new Buffer(buf); } : Buffer.from.bind(Buffer);
8+
}
9+
return function() {};
10+
})();
411

5-
if(typeof Buffer !== 'undefined') {
6-
var nbfs = !Buffer.from;
7-
if(!nbfs) try { Buffer.from("foo", "utf8"); } catch(e) { nbfs = true; }
8-
Buffer_from = nbfs ? function(buf, enc) { return (enc) ? new Buffer(buf, enc) : new Buffer(buf); } : Buffer.from.bind(Buffer);
9-
// $FlowIgnore
10-
if(!Buffer.alloc) Buffer.alloc = function(n) { return new Buffer(n); };
11-
// $FlowIgnore
12-
if(!Buffer.allocUnsafe) Buffer.allocUnsafe = function(n) { return new Buffer(n); };
13-
}
1412

1513
function new_raw_buf(len/*:number*/) {
1614
/* jshint -W056 */
17-
return has_buf ? Buffer.alloc(len) : typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
15+
if(has_buf) return Buffer.alloc ? Buffer.alloc(len) : new Buffer(len);
16+
return typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
1817
/* jshint +W056 */
1918
}
2019

2120
function new_unsafe_buf(len/*:number*/) {
2221
/* jshint -W056 */
23-
return has_buf ? Buffer.allocUnsafe(len) : typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
22+
if(has_buf) return Buffer.allocUnsafe ? Buffer.allocUnsafe(len) : new Buffer(len);
23+
return typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
2424
/* jshint +W056 */
2525
}
2626

@@ -55,6 +55,23 @@ function ab2a(data/*:ArrayBuffer|Uint8Array*/)/*:Array<number>*/ {
5555
return o;
5656
}
5757

58+
var bconcat = has_buf ? function(bufs) { return Buffer.concat(bufs.map(function(buf) { return Buffer.isBuffer(buf) ? buf : Buffer_from(buf); })); } : function(bufs) {
59+
if(typeof Uint8Array !== "undefined") {
60+
var i = 0, maxlen = 0;
61+
for(i = 0; i < bufs.length; ++i) maxlen += bufs[i].length;
62+
var o = new Uint8Array(maxlen);
63+
var len = 0;
64+
for(i = 0, maxlen = 0; i < bufs.length; maxlen += len, ++i) {
65+
len = bufs[i].length;
66+
if(bufs[i] instanceof Uint8Array) o.set(bufs[i], maxlen);
67+
else if(typeof bufs[i] == "string") { throw "wtf"; }
68+
else o.set(new Uint8Array(bufs[i]), maxlen);
69+
}
70+
return o;
71+
}
72+
return [].concat.apply([], bufs.map(function(buf) { return Array.isArray(buf) ? buf : [].slice.call(buf); }));
73+
};
74+
5875
function utf8decode(content/*:string*/) {
5976
var out = [], widx = 0, L = content.length + 250;
6077
var o = new_raw_buf(content.length + 255);
@@ -87,21 +104,4 @@ function utf8decode(content/*:string*/) {
87104
return bconcat(out);
88105
}
89106

90-
var bconcat = function(bufs) {
91-
if(typeof Uint8Array !== "undefined") {
92-
var i = 0, maxlen = 0;
93-
for(i = 0; i < bufs.length; ++i) maxlen += bufs[i].length;
94-
var o = new Uint8Array(maxlen);
95-
var len = 0;
96-
for(i = 0, maxlen = 0; i < bufs.length; maxlen += len, ++i) {
97-
len = bufs[i].length;
98-
if(bufs[i] instanceof Uint8Array) o.set(bufs[i], maxlen);
99-
else if(typeof bufs[i] == "string") { throw "wtf"; }
100-
else o.set(new Uint8Array(bufs[i]), maxlen);
101-
}
102-
return o;
103-
}
104-
return [].concat.apply([], bufs.map(function(buf) { return Array.isArray(buf) ? buf : [].slice.call(buf); }));
105-
};
106-
107107
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;

bits/09_types.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ type EvertArrType = {[string]:Array<string>};
1515
1616
type StringConv = {(string):string};
1717
18-
type WriteObjStrFactory = {from_sheet(ws:Worksheet, o:any, wb:?Workbook):string};
1918
*/

0 commit comments

Comments
 (0)