@loaders.gl/loader-utils 3.0.12 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/index.js +46 -48
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/json-loader.js +5 -33
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +25 -62
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/binary-copy-utils.js +7 -7
- package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/buffer-utils.js +3 -9
- package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/encode-utils.js +7 -7
- package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/get-first-characters.js +5 -7
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/es5/lib/binary-utils/memory-copy-utils.js +6 -7
- package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
- package/dist/es5/lib/env-utils/globals.js +9 -14
- package/dist/es5/lib/env-utils/globals.js.map +1 -1
- package/dist/es5/lib/filesystems/node-filesystem.js +50 -243
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/es5/lib/iterators/async-iteration.js +27 -242
- package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
- package/dist/es5/lib/iterators/text-iterators.js +35 -410
- package/dist/es5/lib/iterators/text-iterators.js.map +1 -1
- package/dist/es5/lib/node/buffer.js +4 -4
- package/dist/es5/lib/node/buffer.js.map +1 -1
- package/dist/es5/lib/node/fs.js +20 -51
- package/dist/es5/lib/node/fs.js.map +1 -1
- package/dist/es5/lib/node/util.js +3 -5
- package/dist/es5/lib/node/util.js.map +1 -1
- package/dist/es5/lib/path-utils/file-aliases.js +4 -4
- package/dist/es5/lib/path-utils/file-aliases.js.map +1 -1
- package/dist/es5/lib/path-utils/path.js +4 -8
- package/dist/es5/lib/path-utils/path.js.map +1 -1
- package/dist/es5/lib/request-utils/request-scheduler.js +96 -124
- package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +63 -132
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +51 -111
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/lib/parser-utils/parse-json.js +1 -1
- package/dist/esm/lib/parser-utils/parse-json.js.map +1 -1
- package/dist/esm/lib/path-utils/file-aliases.js +1 -1
- package/dist/esm/lib/path-utils/file-aliases.js.map +1 -1
- package/dist/esm/lib/path-utils/path.js +2 -2
- package/dist/esm/lib/path-utils/path.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +1 -1
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +1 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -10,425 +8,52 @@ exports.makeTextEncoderIterator = makeTextEncoderIterator;
|
|
|
10
8
|
exports.makeLineIterator = makeLineIterator;
|
|
11
9
|
exports.makeNumberedLineIterator = makeNumberedLineIterator;
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
|
|
16
|
-
|
|
17
|
-
var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
|
|
11
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
12
|
+
const textDecoder = new TextDecoder(undefined, options);
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
15
|
+
yield typeof arrayBuffer === 'string' ? arrayBuffer : textDecoder.decode(arrayBuffer, {
|
|
16
|
+
stream: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
var options,
|
|
28
|
-
textDecoder,
|
|
29
|
-
_iteratorNormalCompletion,
|
|
30
|
-
_didIteratorError,
|
|
31
|
-
_iteratorError,
|
|
32
|
-
_iterator,
|
|
33
|
-
_step,
|
|
34
|
-
_value,
|
|
35
|
-
arrayBuffer,
|
|
36
|
-
_args = arguments;
|
|
37
|
-
|
|
38
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
39
|
-
while (1) {
|
|
40
|
-
switch (_context.prev = _context.next) {
|
|
41
|
-
case 0:
|
|
42
|
-
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
43
|
-
textDecoder = new TextDecoder(undefined, options);
|
|
44
|
-
_iteratorNormalCompletion = true;
|
|
45
|
-
_didIteratorError = false;
|
|
46
|
-
_context.prev = 4;
|
|
47
|
-
_iterator = (0, _asyncIterator2.default)(arrayBufferIterator);
|
|
48
|
-
|
|
49
|
-
case 6:
|
|
50
|
-
_context.next = 8;
|
|
51
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator.next());
|
|
52
|
-
|
|
53
|
-
case 8:
|
|
54
|
-
_step = _context.sent;
|
|
55
|
-
_iteratorNormalCompletion = _step.done;
|
|
56
|
-
_context.next = 12;
|
|
57
|
-
return (0, _awaitAsyncGenerator2.default)(_step.value);
|
|
58
|
-
|
|
59
|
-
case 12:
|
|
60
|
-
_value = _context.sent;
|
|
61
|
-
|
|
62
|
-
if (_iteratorNormalCompletion) {
|
|
63
|
-
_context.next = 20;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
arrayBuffer = _value;
|
|
68
|
-
_context.next = 17;
|
|
69
|
-
return typeof arrayBuffer === 'string' ? arrayBuffer : textDecoder.decode(arrayBuffer, {
|
|
70
|
-
stream: true
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
case 17:
|
|
74
|
-
_iteratorNormalCompletion = true;
|
|
75
|
-
_context.next = 6;
|
|
76
|
-
break;
|
|
21
|
+
async function* makeTextEncoderIterator(textIterator) {
|
|
22
|
+
const textEncoder = new TextEncoder();
|
|
77
23
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
case 22:
|
|
83
|
-
_context.prev = 22;
|
|
84
|
-
_context.t0 = _context["catch"](4);
|
|
85
|
-
_didIteratorError = true;
|
|
86
|
-
_iteratorError = _context.t0;
|
|
87
|
-
|
|
88
|
-
case 26:
|
|
89
|
-
_context.prev = 26;
|
|
90
|
-
_context.prev = 27;
|
|
91
|
-
|
|
92
|
-
if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
|
|
93
|
-
_context.next = 31;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
_context.next = 31;
|
|
98
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator.return());
|
|
99
|
-
|
|
100
|
-
case 31:
|
|
101
|
-
_context.prev = 31;
|
|
102
|
-
|
|
103
|
-
if (!_didIteratorError) {
|
|
104
|
-
_context.next = 34;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
throw _iteratorError;
|
|
109
|
-
|
|
110
|
-
case 34:
|
|
111
|
-
return _context.finish(31);
|
|
112
|
-
|
|
113
|
-
case 35:
|
|
114
|
-
return _context.finish(26);
|
|
115
|
-
|
|
116
|
-
case 36:
|
|
117
|
-
case "end":
|
|
118
|
-
return _context.stop();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}, _callee, null, [[4, 22, 26, 36], [27,, 31, 35]]);
|
|
122
|
-
}));
|
|
123
|
-
return _makeTextDecoderIterator.apply(this, arguments);
|
|
24
|
+
for await (const text of textIterator) {
|
|
25
|
+
yield typeof text === 'string' ? textEncoder.encode(text) : text;
|
|
26
|
+
}
|
|
124
27
|
}
|
|
125
28
|
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
}
|
|
29
|
+
async function* makeLineIterator(textIterator) {
|
|
30
|
+
let previous = '';
|
|
129
31
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
32
|
+
for await (const textChunk of textIterator) {
|
|
33
|
+
previous += textChunk;
|
|
34
|
+
let eolIndex;
|
|
133
35
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
_didIteratorError2 = false;
|
|
141
|
-
_context2.prev = 3;
|
|
142
|
-
_iterator2 = (0, _asyncIterator2.default)(textIterator);
|
|
36
|
+
while ((eolIndex = previous.indexOf('\n')) >= 0) {
|
|
37
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
38
|
+
previous = previous.slice(eolIndex + 1);
|
|
39
|
+
yield line;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
143
42
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
case 7:
|
|
149
|
-
_step2 = _context2.sent;
|
|
150
|
-
_iteratorNormalCompletion2 = _step2.done;
|
|
151
|
-
_context2.next = 11;
|
|
152
|
-
return (0, _awaitAsyncGenerator2.default)(_step2.value);
|
|
153
|
-
|
|
154
|
-
case 11:
|
|
155
|
-
_value2 = _context2.sent;
|
|
156
|
-
|
|
157
|
-
if (_iteratorNormalCompletion2) {
|
|
158
|
-
_context2.next = 19;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
text = _value2;
|
|
163
|
-
_context2.next = 16;
|
|
164
|
-
return typeof text === 'string' ? textEncoder.encode(text) : text;
|
|
165
|
-
|
|
166
|
-
case 16:
|
|
167
|
-
_iteratorNormalCompletion2 = true;
|
|
168
|
-
_context2.next = 5;
|
|
169
|
-
break;
|
|
170
|
-
|
|
171
|
-
case 19:
|
|
172
|
-
_context2.next = 25;
|
|
173
|
-
break;
|
|
174
|
-
|
|
175
|
-
case 21:
|
|
176
|
-
_context2.prev = 21;
|
|
177
|
-
_context2.t0 = _context2["catch"](3);
|
|
178
|
-
_didIteratorError2 = true;
|
|
179
|
-
_iteratorError2 = _context2.t0;
|
|
180
|
-
|
|
181
|
-
case 25:
|
|
182
|
-
_context2.prev = 25;
|
|
183
|
-
_context2.prev = 26;
|
|
184
|
-
|
|
185
|
-
if (!(!_iteratorNormalCompletion2 && _iterator2.return != null)) {
|
|
186
|
-
_context2.next = 30;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
_context2.next = 30;
|
|
191
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator2.return());
|
|
192
|
-
|
|
193
|
-
case 30:
|
|
194
|
-
_context2.prev = 30;
|
|
195
|
-
|
|
196
|
-
if (!_didIteratorError2) {
|
|
197
|
-
_context2.next = 33;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
throw _iteratorError2;
|
|
202
|
-
|
|
203
|
-
case 33:
|
|
204
|
-
return _context2.finish(30);
|
|
205
|
-
|
|
206
|
-
case 34:
|
|
207
|
-
return _context2.finish(25);
|
|
208
|
-
|
|
209
|
-
case 35:
|
|
210
|
-
case "end":
|
|
211
|
-
return _context2.stop();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}, _callee2, null, [[3, 21, 25, 35], [26,, 30, 34]]);
|
|
215
|
-
}));
|
|
216
|
-
return _makeTextEncoderIterator.apply(this, arguments);
|
|
43
|
+
if (previous.length > 0) {
|
|
44
|
+
yield previous;
|
|
45
|
+
}
|
|
217
46
|
}
|
|
218
47
|
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function _makeLineIterator() {
|
|
224
|
-
_makeLineIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee3(textIterator) {
|
|
225
|
-
var previous, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, textChunk, eolIndex, line;
|
|
226
|
-
|
|
227
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
228
|
-
while (1) {
|
|
229
|
-
switch (_context3.prev = _context3.next) {
|
|
230
|
-
case 0:
|
|
231
|
-
previous = '';
|
|
232
|
-
_iteratorNormalCompletion3 = true;
|
|
233
|
-
_didIteratorError3 = false;
|
|
234
|
-
_context3.prev = 3;
|
|
235
|
-
_iterator3 = (0, _asyncIterator2.default)(textIterator);
|
|
236
|
-
|
|
237
|
-
case 5:
|
|
238
|
-
_context3.next = 7;
|
|
239
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator3.next());
|
|
240
|
-
|
|
241
|
-
case 7:
|
|
242
|
-
_step3 = _context3.sent;
|
|
243
|
-
_iteratorNormalCompletion3 = _step3.done;
|
|
244
|
-
_context3.next = 11;
|
|
245
|
-
return (0, _awaitAsyncGenerator2.default)(_step3.value);
|
|
246
|
-
|
|
247
|
-
case 11:
|
|
248
|
-
_value3 = _context3.sent;
|
|
249
|
-
|
|
250
|
-
if (_iteratorNormalCompletion3) {
|
|
251
|
-
_context3.next = 26;
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
textChunk = _value3;
|
|
256
|
-
previous += textChunk;
|
|
257
|
-
eolIndex = void 0;
|
|
258
|
-
|
|
259
|
-
case 16:
|
|
260
|
-
if (!((eolIndex = previous.indexOf('\n')) >= 0)) {
|
|
261
|
-
_context3.next = 23;
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
line = previous.slice(0, eolIndex + 1);
|
|
266
|
-
previous = previous.slice(eolIndex + 1);
|
|
267
|
-
_context3.next = 21;
|
|
268
|
-
return line;
|
|
269
|
-
|
|
270
|
-
case 21:
|
|
271
|
-
_context3.next = 16;
|
|
272
|
-
break;
|
|
273
|
-
|
|
274
|
-
case 23:
|
|
275
|
-
_iteratorNormalCompletion3 = true;
|
|
276
|
-
_context3.next = 5;
|
|
277
|
-
break;
|
|
278
|
-
|
|
279
|
-
case 26:
|
|
280
|
-
_context3.next = 32;
|
|
281
|
-
break;
|
|
282
|
-
|
|
283
|
-
case 28:
|
|
284
|
-
_context3.prev = 28;
|
|
285
|
-
_context3.t0 = _context3["catch"](3);
|
|
286
|
-
_didIteratorError3 = true;
|
|
287
|
-
_iteratorError3 = _context3.t0;
|
|
288
|
-
|
|
289
|
-
case 32:
|
|
290
|
-
_context3.prev = 32;
|
|
291
|
-
_context3.prev = 33;
|
|
292
|
-
|
|
293
|
-
if (!(!_iteratorNormalCompletion3 && _iterator3.return != null)) {
|
|
294
|
-
_context3.next = 37;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
_context3.next = 37;
|
|
299
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator3.return());
|
|
300
|
-
|
|
301
|
-
case 37:
|
|
302
|
-
_context3.prev = 37;
|
|
303
|
-
|
|
304
|
-
if (!_didIteratorError3) {
|
|
305
|
-
_context3.next = 40;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
throw _iteratorError3;
|
|
310
|
-
|
|
311
|
-
case 40:
|
|
312
|
-
return _context3.finish(37);
|
|
313
|
-
|
|
314
|
-
case 41:
|
|
315
|
-
return _context3.finish(32);
|
|
316
|
-
|
|
317
|
-
case 42:
|
|
318
|
-
if (!(previous.length > 0)) {
|
|
319
|
-
_context3.next = 45;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
_context3.next = 45;
|
|
324
|
-
return previous;
|
|
325
|
-
|
|
326
|
-
case 45:
|
|
327
|
-
case "end":
|
|
328
|
-
return _context3.stop();
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}, _callee3, null, [[3, 28, 32, 42], [33,, 37, 41]]);
|
|
332
|
-
}));
|
|
333
|
-
return _makeLineIterator.apply(this, arguments);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function makeNumberedLineIterator(_x4) {
|
|
337
|
-
return _makeNumberedLineIterator.apply(this, arguments);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function _makeNumberedLineIterator() {
|
|
341
|
-
_makeNumberedLineIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee4(lineIterator) {
|
|
342
|
-
var counter, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _value4, line;
|
|
343
|
-
|
|
344
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
345
|
-
while (1) {
|
|
346
|
-
switch (_context4.prev = _context4.next) {
|
|
347
|
-
case 0:
|
|
348
|
-
counter = 1;
|
|
349
|
-
_iteratorNormalCompletion4 = true;
|
|
350
|
-
_didIteratorError4 = false;
|
|
351
|
-
_context4.prev = 3;
|
|
352
|
-
_iterator4 = (0, _asyncIterator2.default)(lineIterator);
|
|
353
|
-
|
|
354
|
-
case 5:
|
|
355
|
-
_context4.next = 7;
|
|
356
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator4.next());
|
|
357
|
-
|
|
358
|
-
case 7:
|
|
359
|
-
_step4 = _context4.sent;
|
|
360
|
-
_iteratorNormalCompletion4 = _step4.done;
|
|
361
|
-
_context4.next = 11;
|
|
362
|
-
return (0, _awaitAsyncGenerator2.default)(_step4.value);
|
|
363
|
-
|
|
364
|
-
case 11:
|
|
365
|
-
_value4 = _context4.sent;
|
|
366
|
-
|
|
367
|
-
if (_iteratorNormalCompletion4) {
|
|
368
|
-
_context4.next = 20;
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
line = _value4;
|
|
373
|
-
_context4.next = 16;
|
|
374
|
-
return {
|
|
375
|
-
counter: counter,
|
|
376
|
-
line: line
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
case 16:
|
|
380
|
-
counter++;
|
|
381
|
-
|
|
382
|
-
case 17:
|
|
383
|
-
_iteratorNormalCompletion4 = true;
|
|
384
|
-
_context4.next = 5;
|
|
385
|
-
break;
|
|
386
|
-
|
|
387
|
-
case 20:
|
|
388
|
-
_context4.next = 26;
|
|
389
|
-
break;
|
|
390
|
-
|
|
391
|
-
case 22:
|
|
392
|
-
_context4.prev = 22;
|
|
393
|
-
_context4.t0 = _context4["catch"](3);
|
|
394
|
-
_didIteratorError4 = true;
|
|
395
|
-
_iteratorError4 = _context4.t0;
|
|
396
|
-
|
|
397
|
-
case 26:
|
|
398
|
-
_context4.prev = 26;
|
|
399
|
-
_context4.prev = 27;
|
|
400
|
-
|
|
401
|
-
if (!(!_iteratorNormalCompletion4 && _iterator4.return != null)) {
|
|
402
|
-
_context4.next = 31;
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
_context4.next = 31;
|
|
407
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator4.return());
|
|
408
|
-
|
|
409
|
-
case 31:
|
|
410
|
-
_context4.prev = 31;
|
|
411
|
-
|
|
412
|
-
if (!_didIteratorError4) {
|
|
413
|
-
_context4.next = 34;
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
throw _iteratorError4;
|
|
418
|
-
|
|
419
|
-
case 34:
|
|
420
|
-
return _context4.finish(31);
|
|
421
|
-
|
|
422
|
-
case 35:
|
|
423
|
-
return _context4.finish(26);
|
|
48
|
+
async function* makeNumberedLineIterator(lineIterator) {
|
|
49
|
+
let counter = 1;
|
|
424
50
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
return _makeNumberedLineIterator.apply(this, arguments);
|
|
51
|
+
for await (const line of lineIterator) {
|
|
52
|
+
yield {
|
|
53
|
+
counter,
|
|
54
|
+
line
|
|
55
|
+
};
|
|
56
|
+
counter++;
|
|
57
|
+
}
|
|
433
58
|
}
|
|
434
59
|
//# sourceMappingURL=text-iterators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/iterators/text-iterators.ts"],"names":["makeTextDecoderIterator","arrayBufferIterator","options","textDecoder","TextDecoder","undefined","arrayBuffer","decode","stream","makeTextEncoderIterator","textIterator","textEncoder","TextEncoder","text","encode","makeLineIterator","previous","textChunk","eolIndex","indexOf","line","slice","length","makeNumberedLineIterator","lineIterator","counter"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/iterators/text-iterators.ts"],"names":["makeTextDecoderIterator","arrayBufferIterator","options","textDecoder","TextDecoder","undefined","arrayBuffer","decode","stream","makeTextEncoderIterator","textIterator","textEncoder","TextEncoder","text","encode","makeLineIterator","previous","textChunk","eolIndex","indexOf","line","slice","length","makeNumberedLineIterator","lineIterator","counter"],"mappings":";;;;;;;;;;AAGO,gBAAgBA,uBAAhB,CACLC,mBADK,EAELC,OAA2B,GAAG,EAFzB,EAGkB;AACvB,QAAMC,WAAW,GAAG,IAAIC,WAAJ,CAAgBC,SAAhB,EAA2BH,OAA3B,CAApB;;AACA,aAAW,MAAMI,WAAjB,IAAgCL,mBAAhC,EAAqD;AACnD,UAAM,OAAOK,WAAP,KAAuB,QAAvB,GACFA,WADE,GAEFH,WAAW,CAACI,MAAZ,CAAmBD,WAAnB,EAAgC;AAACE,MAAAA,MAAM,EAAE;AAAT,KAAhC,CAFJ;AAGD;AACF;;AAOM,gBAAgBC,uBAAhB,CACLC,YADK,EAEuB;AAC5B,QAAMC,WAAW,GAAG,IAAIC,WAAJ,EAApB;;AACA,aAAW,MAAMC,IAAjB,IAAyBH,YAAzB,EAAuC;AACrC,UAAM,OAAOG,IAAP,KAAgB,QAAhB,GAA2BF,WAAW,CAACG,MAAZ,CAAmBD,IAAnB,CAA3B,GAAsDA,IAA5D;AACD;AACF;;AAQM,gBAAgBE,gBAAhB,CACLL,YADK,EAEkB;AACvB,MAAIM,QAAQ,GAAG,EAAf;;AACA,aAAW,MAAMC,SAAjB,IAA8BP,YAA9B,EAA4C;AAC1CM,IAAAA,QAAQ,IAAIC,SAAZ;AACA,QAAIC,QAAJ;;AACA,WAAO,CAACA,QAAQ,GAAGF,QAAQ,CAACG,OAAT,CAAiB,IAAjB,CAAZ,KAAuC,CAA9C,EAAiD;AAE/C,YAAMC,IAAI,GAAGJ,QAAQ,CAACK,KAAT,CAAe,CAAf,EAAkBH,QAAQ,GAAG,CAA7B,CAAb;AACAF,MAAAA,QAAQ,GAAGA,QAAQ,CAACK,KAAT,CAAeH,QAAQ,GAAG,CAA1B,CAAX;AACA,YAAME,IAAN;AACD;AACF;;AAED,MAAIJ,QAAQ,CAACM,MAAT,GAAkB,CAAtB,EAAyB;AACvB,UAAMN,QAAN;AACD;AACF;;AAQM,gBAAgBO,wBAAhB,CACLC,YADK,EAE2C;AAChD,MAAIC,OAAO,GAAG,CAAd;;AACA,aAAW,MAAML,IAAjB,IAAyBI,YAAzB,EAAuC;AACrC,UAAM;AAACC,MAAAA,OAAD;AAAUL,MAAAA;AAAV,KAAN;AACAK,IAAAA,OAAO;AACR;AACF","sourcesContent":["// TextDecoder iterators\n// TextDecoder will keep any partial undecoded bytes between calls to `decode`\n\nexport async function* makeTextDecoderIterator(\n arrayBufferIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options: TextDecoderOptions = {}\n): AsyncIterable<string> {\n const textDecoder = new TextDecoder(undefined, options);\n for await (const arrayBuffer of arrayBufferIterator) {\n yield typeof arrayBuffer === 'string'\n ? arrayBuffer\n : textDecoder.decode(arrayBuffer, {stream: true});\n }\n}\n\n// TextEncoder iterator\n// TODO - this is not useful unless min chunk size is given\n// TextEncoder will keep any partial undecoded bytes between calls to `encode`\n// If iterator does not yield strings, assume arrayBuffer and return unencoded\n\nexport async function* makeTextEncoderIterator(\n textIterator: AsyncIterable<string> | Iterable<ArrayBuffer>\n): AsyncIterable<ArrayBuffer> {\n const textEncoder = new TextEncoder();\n for await (const text of textIterator) {\n yield typeof text === 'string' ? textEncoder.encode(text) : text;\n }\n}\n\n/**\n * @param textIterator async iterable yielding strings\n * @returns an async iterable over lines\n * See http://2ality.com/2018/04/async-iter-nodejs.html\n */\n\nexport async function* makeLineIterator(\n textIterator: AsyncIterable<string>\n): AsyncIterable<string> {\n let previous = '';\n for await (const textChunk of textIterator) {\n previous += textChunk;\n let eolIndex;\n while ((eolIndex = previous.indexOf('\\n')) >= 0) {\n // line includes the EOL\n const line = previous.slice(0, eolIndex + 1);\n previous = previous.slice(eolIndex + 1);\n yield line;\n }\n }\n\n if (previous.length > 0) {\n yield previous;\n }\n}\n\n/**\n * @param lineIterator async iterable yielding lines\n * @returns async iterable yielding numbered lines\n *\n * See http://2ality.com/2018/04/async-iter-nodejs.html\n */\nexport async function* makeNumberedLineIterator(\n lineIterator: AsyncIterable<string>\n): AsyncIterable<{counter: number; line: string}> {\n let counter = 1;\n for await (const line of lineIterator) {\n yield {counter, line};\n counter++;\n }\n}\n"],"file":"text-iterators.js"}
|
|
@@ -10,7 +10,7 @@ var _assert = require("../env-utils/assert");
|
|
|
10
10
|
|
|
11
11
|
function toArrayBuffer(buffer) {
|
|
12
12
|
if (Buffer.isBuffer(buffer)) {
|
|
13
|
-
|
|
13
|
+
const typedArray = new Uint8Array(buffer);
|
|
14
14
|
return typedArray.buffer;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -23,10 +23,10 @@ function toBuffer(binaryData) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const buffer = new Buffer(binaryData.byteLength);
|
|
27
|
+
const view = new Uint8Array(binaryData);
|
|
28
28
|
|
|
29
|
-
for (
|
|
29
|
+
for (let i = 0; i < buffer.length; ++i) {
|
|
30
30
|
buffer[i] = view[i];
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/node/buffer.ts"],"names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i","length"],"mappings":";;;;;;;;AAGA;;AAKO,SAASA,aAAT,CAAuBC,MAAvB,EAA+B;AAEpC,MAAIC,MAAM,CAACC,QAAP,CAAgBF,MAAhB,CAAJ,EAA6B;AAC3B,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/node/buffer.ts"],"names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i","length"],"mappings":";;;;;;;;AAGA;;AAKO,SAASA,aAAT,CAAuBC,MAAvB,EAA+B;AAEpC,MAAIC,MAAM,CAACC,QAAP,CAAgBF,MAAhB,CAAJ,EAA6B;AAC3B,UAAMG,UAAU,GAAG,IAAIC,UAAJ,CAAeJ,MAAf,CAAnB;AACA,WAAOG,UAAU,CAACH,MAAlB;AACD;;AACD,SAAOA,MAAP;AACD;;AAKM,SAASK,QAAT,CAAkBC,UAAlB,EAA8B;AACnC,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,UAAnB,CAAJ,EAAoC;AAClCA,IAAAA,UAAU,GAAGA,UAAU,CAACN,MAAxB;AACD;;AAED,MAAI,OAAOC,MAAP,KAAkB,WAAlB,IAAiCK,UAAU,YAAYC,WAA3D,EAAwE;AACtE,UAAMP,MAAM,GAAG,IAAIC,MAAJ,CAAWK,UAAU,CAACG,UAAtB,CAAf;AACA,UAAMC,IAAI,GAAG,IAAIN,UAAJ,CAAeE,UAAf,CAAb;;AACA,SAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGX,MAAM,CAACY,MAA3B,EAAmC,EAAED,CAArC,EAAwC;AACtCX,MAAAA,MAAM,CAACW,CAAD,CAAN,GAAYD,IAAI,CAACC,CAAD,CAAhB;AACD;;AACD,WAAOX,MAAP;AACD;;AAED,SAAO,oBAAO,KAAP,CAAP;AACD","sourcesContent":["// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is not visible to webpack (it is excluded in the package.json \"browser\" field).\n\nimport {assert} from '../env-utils/assert';\n\n/**\n * Convert Buffer to ArrayBuffer\n */\nexport function toArrayBuffer(buffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n if (Buffer.isBuffer(buffer)) {\n const typedArray = new Uint8Array(buffer);\n return typedArray.buffer;\n }\n return buffer;\n}\n\n/**\n * Convert (copy) ArrayBuffer to Buffer\n */\nexport function toBuffer(binaryData) {\n if (ArrayBuffer.isView(binaryData)) {\n binaryData = binaryData.buffer;\n }\n\n if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {\n const buffer = new Buffer(binaryData.byteLength);\n const view = new Uint8Array(binaryData);\n for (let i = 0; i < buffer.length; ++i) {\n buffer[i] = view[i];\n }\n return buffer;\n }\n\n return assert(false);\n}\n"],"file":"buffer.js"}
|
package/dist/es5/lib/node/fs.js
CHANGED
|
@@ -8,76 +8,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports._readToArrayBuffer = _readToArrayBuffer;
|
|
9
9
|
exports.isSupported = exports.fstat = exports.read = exports.close = exports.open = exports.writeFileSync = exports.writeFile = exports.readFileSync = exports.readFile = exports.stat = exports.readdir = void 0;
|
|
10
10
|
|
|
11
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
-
|
|
15
11
|
var _fs = _interopRequireDefault(require("fs"));
|
|
16
12
|
|
|
17
13
|
var _buffer = require("./buffer");
|
|
18
14
|
|
|
19
15
|
var _util = require("./util");
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
const readdir = (0, _util.promisify)(_fs.default.readdir);
|
|
22
18
|
exports.readdir = readdir;
|
|
23
|
-
|
|
19
|
+
const stat = (0, _util.promisify)(_fs.default.stat);
|
|
24
20
|
exports.stat = stat;
|
|
25
|
-
|
|
21
|
+
const readFile = (0, _util.promisify)(_fs.default.readFile);
|
|
26
22
|
exports.readFile = readFile;
|
|
27
|
-
|
|
23
|
+
const readFileSync = _fs.default.readFileSync;
|
|
28
24
|
exports.readFileSync = readFileSync;
|
|
29
|
-
|
|
25
|
+
const writeFile = (0, _util.promisify)(_fs.default.writeFile);
|
|
30
26
|
exports.writeFile = writeFile;
|
|
31
|
-
|
|
27
|
+
const writeFileSync = _fs.default.writeFileSync;
|
|
32
28
|
exports.writeFileSync = writeFileSync;
|
|
33
|
-
|
|
29
|
+
const open = (0, _util.promisify)(_fs.default.open);
|
|
34
30
|
exports.open = open;
|
|
35
|
-
|
|
31
|
+
const close = (0, _util.promisify)(_fs.default.close);
|
|
36
32
|
exports.close = close;
|
|
37
|
-
|
|
33
|
+
const read = (0, _util.promisify)(_fs.default.read);
|
|
38
34
|
exports.read = read;
|
|
39
|
-
|
|
35
|
+
const fstat = (0, _util.promisify)(_fs.default.fstat);
|
|
40
36
|
exports.fstat = fstat;
|
|
41
|
-
|
|
37
|
+
const isSupported = Boolean(_fs.default);
|
|
42
38
|
exports.isSupported = isSupported;
|
|
43
39
|
|
|
44
|
-
function _readToArrayBuffer(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_readToArrayBuffer2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(fd, start, length) {
|
|
50
|
-
var buffer, _yield$read, bytesRead;
|
|
51
|
-
|
|
52
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
53
|
-
while (1) {
|
|
54
|
-
switch (_context.prev = _context.next) {
|
|
55
|
-
case 0:
|
|
56
|
-
buffer = Buffer.alloc(length);
|
|
57
|
-
_context.next = 3;
|
|
58
|
-
return read(fd, buffer, 0, length, start);
|
|
59
|
-
|
|
60
|
-
case 3:
|
|
61
|
-
_yield$read = _context.sent;
|
|
62
|
-
bytesRead = _yield$read.bytesRead;
|
|
63
|
-
|
|
64
|
-
if (!(bytesRead !== length)) {
|
|
65
|
-
_context.next = 7;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
throw new Error('fs.read failed');
|
|
40
|
+
async function _readToArrayBuffer(fd, start, length) {
|
|
41
|
+
const buffer = Buffer.alloc(length);
|
|
42
|
+
const {
|
|
43
|
+
bytesRead
|
|
44
|
+
} = await read(fd, buffer, 0, length, start);
|
|
70
45
|
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
if (bytesRead !== length) {
|
|
47
|
+
throw new Error('fs.read failed');
|
|
48
|
+
}
|
|
73
49
|
|
|
74
|
-
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, _callee);
|
|
80
|
-
}));
|
|
81
|
-
return _readToArrayBuffer2.apply(this, arguments);
|
|
50
|
+
return (0, _buffer.toArrayBuffer)(buffer);
|
|
82
51
|
}
|
|
83
52
|
//# sourceMappingURL=fs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/node/fs.ts"],"names":["readdir","fs","stat","readFile","readFileSync","writeFile","writeFileSync","open","close","read","fstat","isSupported","Boolean","_readToArrayBuffer","fd","start","length","buffer","Buffer","alloc","bytesRead","Error"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/node/fs.ts"],"names":["readdir","fs","stat","readFile","readFileSync","writeFile","writeFileSync","open","close","read","fstat","isSupported","Boolean","_readToArrayBuffer","fd","start","length","buffer","Buffer","alloc","bytesRead","Error"],"mappings":";;;;;;;;;;AACA;;AACA;;AACA;;AAOO,MAAMA,OAAO,GAAG,qBAAUC,YAAGD,OAAb,CAAhB;;AAEA,MAAME,IAAI,GAAG,qBAAUD,YAAGC,IAAb,CAAb;;AAGA,MAAMC,QAAQ,GAAG,qBAAUF,YAAGE,QAAb,CAAjB;;AAEA,MAAMC,YAAY,GAAGH,YAAGG,YAAxB;;AAEA,MAAMC,SAAS,GAAG,qBAAUJ,YAAGI,SAAb,CAAlB;;AAEA,MAAMC,aAAa,GAAGL,YAAGK,aAAzB;;AAKA,MAAMC,IAAI,GAAG,qBAAUN,YAAGM,IAAb,CAAb;;AAEA,MAAMC,KAAK,GAAG,qBAAUP,YAAGO,KAAb,CAAd;;AAEA,MAAMC,IAAI,GAAG,qBAAUR,YAAGQ,IAAb,CAAb;;AAEA,MAAMC,KAAK,GAAG,qBAAUT,YAAGS,KAAb,CAAd;;AAEA,MAAMC,WAAW,GAAGC,OAAO,CAACX,WAAD,CAA3B;;;AAEA,eAAeY,kBAAf,CAAkCC,EAAlC,EAA8CC,KAA9C,EAA6DC,MAA7D,EAA6E;AAClF,QAAMC,MAAM,GAAGC,MAAM,CAACC,KAAP,CAAaH,MAAb,CAAf;AACA,QAAM;AAACI,IAAAA;AAAD,MAAc,MAAMX,IAAI,CAACK,EAAD,EAAKG,MAAL,EAAa,CAAb,EAAgBD,MAAhB,EAAwBD,KAAxB,CAA9B;;AACA,MAAIK,SAAS,KAAKJ,MAAlB,EAA0B;AACxB,UAAM,IAAIK,KAAJ,CAAU,gBAAV,CAAN;AACD;;AACD,SAAO,2BAAcJ,MAAd,CAAP;AACD","sourcesContent":["// fs wrapper (promisified fs + avoids bundling fs in browsers)\nimport fs from 'fs';\nimport {toArrayBuffer} from './buffer';\nimport {promisify} from './util';\n\nexport type {Stats} from 'fs';\n\n// paths\n\n/** Wrapper for Node.js fs method */\nexport const readdir = promisify(fs.readdir);\n/** Wrapper for Node.js fs method */\nexport const stat = promisify(fs.stat);\n\n/** Wrapper for Node.js fs method */\nexport const readFile = promisify(fs.readFile);\n/** Wrapper for Node.js fs method */\nexport const readFileSync = fs.readFileSync;\n/** Wrapper for Node.js fs method */\nexport const writeFile = promisify(fs.writeFile);\n/** Wrapper for Node.js fs method */\nexport const writeFileSync = fs.writeFileSync;\n\n// file descriptors\n\n/** Wrapper for Node.js fs method */\nexport const open = promisify(fs.open);\n/** Wrapper for Node.js fs method */\nexport const close = promisify(fs.close);\n/** Wrapper for Node.js fs method */\nexport const read = promisify(fs.read);\n/** Wrapper for Node.js fs method */\nexport const fstat = promisify(fs.fstat);\n\nexport const isSupported = Boolean(fs);\n\nexport async function _readToArrayBuffer(fd: number, start: number, length: number) {\n const buffer = Buffer.alloc(length);\n const {bytesRead} = await read(fd, buffer, 0, length, start);\n if (bytesRead !== length) {\n throw new Error('fs.read failed');\n }\n return toArrayBuffer(buffer);\n}\n"],"file":"fs.js"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,10 +7,10 @@ exports.promisify = void 0;
|
|
|
9
7
|
|
|
10
8
|
var util = _interopRequireWildcard(require("util"));
|
|
11
9
|
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
11
|
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
const promisify = util.promisify;
|
|
17
15
|
exports.promisify = promisify;
|
|
18
16
|
//# sourceMappingURL=util.js.map
|