@loaders.gl/loader-utils 3.3.0-alpha.4 → 3.3.0-alpha.6
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 +93 -119
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/json-loader.js +2 -9
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +6 -26
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/binary-copy-utils.js +0 -4
- package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/buffer-utils.js +1 -9
- package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/encode-utils.js +2 -8
- package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/get-first-characters.js +0 -7
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/es5/lib/binary-utils/memory-copy-utils.js +1 -4
- package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
- package/dist/es5/lib/env-utils/assert.js +0 -1
- package/dist/es5/lib/env-utils/assert.js.map +1 -1
- package/dist/es5/lib/env-utils/globals.js +5 -4
- package/dist/es5/lib/env-utils/globals.js.map +1 -1
- package/dist/es5/lib/filesystems/node-filesystem.js +2 -45
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/es5/lib/iterators/async-iteration.js +57 -127
- package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
- package/dist/es5/lib/iterators/text-iterators.js +127 -242
- package/dist/es5/lib/iterators/text-iterators.js.map +1 -1
- package/dist/es5/lib/node/buffer.js +0 -6
- package/dist/es5/lib/node/buffer.js.map +1 -1
- package/dist/es5/lib/node/fs.js +9 -16
- package/dist/es5/lib/node/fs.js.map +1 -1
- package/dist/es5/lib/node/util.js +0 -5
- package/dist/es5/lib/node/util.js.map +1 -1
- package/dist/es5/lib/parser-utils/parse-json.js +0 -2
- package/dist/es5/lib/parser-utils/parse-json.js.map +1 -1
- package/dist/es5/lib/path-utils/file-aliases.js +3 -4
- package/dist/es5/lib/path-utils/file-aliases.js.map +1 -1
- package/dist/es5/lib/path-utils/path.js +1 -4
- package/dist/es5/lib/path-utils/path.js.map +1 -1
- package/dist/es5/lib/request-utils/request-scheduler.js +24 -33
- package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +2 -36
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js +0 -4
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +2 -23
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/workers/json-worker.js +0 -2
- package/dist/es5/workers/json-worker.js.map +1 -1
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/json-loader.js +3 -2
- package/dist/esm/json-loader.js.map +1 -1
- package/dist/esm/lib/binary-utils/array-buffer-utils.js +16 -15
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/binary-copy-utils.js +2 -2
- package/dist/esm/lib/binary-utils/binary-copy-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/buffer-utils.js +3 -1
- package/dist/esm/lib/binary-utils/buffer-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/encode-utils.js +2 -4
- package/dist/esm/lib/binary-utils/encode-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/get-first-characters.js +2 -5
- package/dist/esm/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/esm/lib/binary-utils/memory-copy-utils.js +5 -2
- package/dist/esm/lib/binary-utils/memory-copy-utils.js.map +1 -1
- package/dist/esm/lib/env-utils/assert.js +1 -0
- package/dist/esm/lib/env-utils/assert.js.map +1 -1
- package/dist/esm/lib/env-utils/globals.js +7 -1
- package/dist/esm/lib/env-utils/globals.js.map +1 -1
- package/dist/esm/lib/filesystems/node-filesystem.js +10 -16
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/esm/lib/iterators/async-iteration.js +2 -7
- package/dist/esm/lib/iterators/async-iteration.js.map +1 -1
- package/dist/esm/lib/iterators/text-iterators.js +7 -7
- package/dist/esm/lib/iterators/text-iterators.js.map +1 -1
- package/dist/esm/lib/node/buffer.js +4 -5
- package/dist/esm/lib/node/buffer.js.map +1 -1
- package/dist/esm/lib/node/fs.js +7 -4
- package/dist/esm/lib/node/fs.js.map +1 -1
- package/dist/esm/lib/node/util.js +1 -0
- package/dist/esm/lib/node/util.js.map +1 -1
- package/dist/esm/lib/parser-utils/parse-json.js +1 -0
- package/dist/esm/lib/parser-utils/parse-json.js.map +1 -1
- package/dist/esm/lib/path-utils/file-aliases.js +6 -2
- package/dist/esm/lib/path-utils/file-aliases.js.map +1 -1
- package/dist/esm/lib/path-utils/path.js +8 -3
- package/dist/esm/lib/path-utils/path.js.map +1 -1
- package/dist/esm/lib/request-utils/request-scheduler.js +11 -21
- package/dist/esm/lib/request-utils/request-scheduler.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +19 -17
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js +1 -1
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +6 -7
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/json-worker.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/binary-utils/buffer-utils.js +5 -1
- package/dist/lib/filesystems/node-filesystem.d.ts +1 -0
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/node-filesystem.js +5 -1
- package/dist/lib/node/util.js +5 -1
- package/package.json +3 -3
|
@@ -1,433 +1,318 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.makeTextDecoderIterator = makeTextDecoderIterator;
|
|
9
|
-
exports.makeTextEncoderIterator = makeTextEncoderIterator;
|
|
10
7
|
exports.makeLineIterator = makeLineIterator;
|
|
11
8
|
exports.makeNumberedLineIterator = makeNumberedLineIterator;
|
|
12
|
-
|
|
9
|
+
exports.makeTextDecoderIterator = makeTextDecoderIterator;
|
|
10
|
+
exports.makeTextEncoderIterator = makeTextEncoderIterator;
|
|
13
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
|
-
|
|
15
12
|
var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
|
|
16
|
-
|
|
17
13
|
var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
15
|
+
function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
|
|
21
16
|
function makeTextDecoderIterator(_x) {
|
|
22
17
|
return _makeTextDecoderIterator.apply(this, arguments);
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
function _makeTextDecoderIterator() {
|
|
26
20
|
_makeTextDecoderIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee(arrayBufferIterator) {
|
|
27
21
|
var options,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_args = arguments;
|
|
37
|
-
|
|
22
|
+
textDecoder,
|
|
23
|
+
_iteratorAbruptCompletion,
|
|
24
|
+
_didIteratorError,
|
|
25
|
+
_iteratorError,
|
|
26
|
+
_iterator,
|
|
27
|
+
_step,
|
|
28
|
+
arrayBuffer,
|
|
29
|
+
_args = arguments;
|
|
38
30
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
39
31
|
while (1) {
|
|
40
32
|
switch (_context.prev = _context.next) {
|
|
41
33
|
case 0:
|
|
42
34
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
43
35
|
textDecoder = new TextDecoder(undefined, options);
|
|
44
|
-
|
|
36
|
+
_iteratorAbruptCompletion = false;
|
|
45
37
|
_didIteratorError = false;
|
|
46
38
|
_context.prev = 4;
|
|
47
|
-
_iterator = (
|
|
48
|
-
|
|
39
|
+
_iterator = _asyncIterator(arrayBufferIterator);
|
|
49
40
|
case 6:
|
|
50
41
|
_context.next = 8;
|
|
51
42
|
return (0, _awaitAsyncGenerator2.default)(_iterator.next());
|
|
52
|
-
|
|
53
43
|
case 8:
|
|
54
|
-
_step = _context.sent
|
|
55
|
-
|
|
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;
|
|
44
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
45
|
+
_context.next = 15;
|
|
64
46
|
break;
|
|
65
47
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_context.next = 17;
|
|
48
|
+
arrayBuffer = _step.value;
|
|
49
|
+
_context.next = 12;
|
|
69
50
|
return typeof arrayBuffer === 'string' ? arrayBuffer : textDecoder.decode(arrayBuffer, {
|
|
70
51
|
stream: true
|
|
71
52
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
_iteratorNormalCompletion = true;
|
|
53
|
+
case 12:
|
|
54
|
+
_iteratorAbruptCompletion = false;
|
|
75
55
|
_context.next = 6;
|
|
76
56
|
break;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_context.next = 26;
|
|
57
|
+
case 15:
|
|
58
|
+
_context.next = 21;
|
|
80
59
|
break;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_context.prev = 22;
|
|
60
|
+
case 17:
|
|
61
|
+
_context.prev = 17;
|
|
84
62
|
_context.t0 = _context["catch"](4);
|
|
85
63
|
_didIteratorError = true;
|
|
86
64
|
_iteratorError = _context.t0;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_context.prev =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
|
|
93
|
-
_context.next = 31;
|
|
65
|
+
case 21:
|
|
66
|
+
_context.prev = 21;
|
|
67
|
+
_context.prev = 22;
|
|
68
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
|
|
69
|
+
_context.next = 26;
|
|
94
70
|
break;
|
|
95
71
|
}
|
|
96
|
-
|
|
97
|
-
_context.next = 31;
|
|
72
|
+
_context.next = 26;
|
|
98
73
|
return (0, _awaitAsyncGenerator2.default)(_iterator.return());
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
_context.prev = 31;
|
|
102
|
-
|
|
74
|
+
case 26:
|
|
75
|
+
_context.prev = 26;
|
|
103
76
|
if (!_didIteratorError) {
|
|
104
|
-
_context.next =
|
|
77
|
+
_context.next = 29;
|
|
105
78
|
break;
|
|
106
79
|
}
|
|
107
|
-
|
|
108
80
|
throw _iteratorError;
|
|
109
|
-
|
|
110
|
-
case 34:
|
|
111
|
-
return _context.finish(31);
|
|
112
|
-
|
|
113
|
-
case 35:
|
|
81
|
+
case 29:
|
|
114
82
|
return _context.finish(26);
|
|
115
|
-
|
|
116
|
-
|
|
83
|
+
case 30:
|
|
84
|
+
return _context.finish(21);
|
|
85
|
+
case 31:
|
|
117
86
|
case "end":
|
|
118
87
|
return _context.stop();
|
|
119
88
|
}
|
|
120
89
|
}
|
|
121
|
-
}, _callee, null, [[4,
|
|
90
|
+
}, _callee, null, [[4, 17, 21, 31], [22,, 26, 30]]);
|
|
122
91
|
}));
|
|
123
92
|
return _makeTextDecoderIterator.apply(this, arguments);
|
|
124
93
|
}
|
|
125
|
-
|
|
126
94
|
function makeTextEncoderIterator(_x2) {
|
|
127
95
|
return _makeTextEncoderIterator.apply(this, arguments);
|
|
128
96
|
}
|
|
129
|
-
|
|
130
97
|
function _makeTextEncoderIterator() {
|
|
131
98
|
_makeTextEncoderIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee2(textIterator) {
|
|
132
|
-
var textEncoder,
|
|
133
|
-
|
|
99
|
+
var textEncoder, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, text;
|
|
134
100
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
135
101
|
while (1) {
|
|
136
102
|
switch (_context2.prev = _context2.next) {
|
|
137
103
|
case 0:
|
|
138
104
|
textEncoder = new TextEncoder();
|
|
139
|
-
|
|
105
|
+
_iteratorAbruptCompletion2 = false;
|
|
140
106
|
_didIteratorError2 = false;
|
|
141
107
|
_context2.prev = 3;
|
|
142
|
-
_iterator2 = (
|
|
143
|
-
|
|
108
|
+
_iterator2 = _asyncIterator(textIterator);
|
|
144
109
|
case 5:
|
|
145
110
|
_context2.next = 7;
|
|
146
111
|
return (0, _awaitAsyncGenerator2.default)(_iterator2.next());
|
|
147
|
-
|
|
148
112
|
case 7:
|
|
149
|
-
_step2 = _context2.sent
|
|
150
|
-
|
|
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;
|
|
113
|
+
if (!(_iteratorAbruptCompletion2 = !(_step2 = _context2.sent).done)) {
|
|
114
|
+
_context2.next = 14;
|
|
159
115
|
break;
|
|
160
116
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
_context2.next = 16;
|
|
117
|
+
text = _step2.value;
|
|
118
|
+
_context2.next = 11;
|
|
164
119
|
return typeof text === 'string' ? textEncoder.encode(text) : text;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
_iteratorNormalCompletion2 = true;
|
|
120
|
+
case 11:
|
|
121
|
+
_iteratorAbruptCompletion2 = false;
|
|
168
122
|
_context2.next = 5;
|
|
169
123
|
break;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
_context2.next = 25;
|
|
124
|
+
case 14:
|
|
125
|
+
_context2.next = 20;
|
|
173
126
|
break;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
_context2.prev = 21;
|
|
127
|
+
case 16:
|
|
128
|
+
_context2.prev = 16;
|
|
177
129
|
_context2.t0 = _context2["catch"](3);
|
|
178
130
|
_didIteratorError2 = true;
|
|
179
131
|
_iteratorError2 = _context2.t0;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
_context2.prev =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (!(!_iteratorNormalCompletion2 && _iterator2.return != null)) {
|
|
186
|
-
_context2.next = 30;
|
|
132
|
+
case 20:
|
|
133
|
+
_context2.prev = 20;
|
|
134
|
+
_context2.prev = 21;
|
|
135
|
+
if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) {
|
|
136
|
+
_context2.next = 25;
|
|
187
137
|
break;
|
|
188
138
|
}
|
|
189
|
-
|
|
190
|
-
_context2.next = 30;
|
|
139
|
+
_context2.next = 25;
|
|
191
140
|
return (0, _awaitAsyncGenerator2.default)(_iterator2.return());
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
_context2.prev = 30;
|
|
195
|
-
|
|
141
|
+
case 25:
|
|
142
|
+
_context2.prev = 25;
|
|
196
143
|
if (!_didIteratorError2) {
|
|
197
|
-
_context2.next =
|
|
144
|
+
_context2.next = 28;
|
|
198
145
|
break;
|
|
199
146
|
}
|
|
200
|
-
|
|
201
147
|
throw _iteratorError2;
|
|
202
|
-
|
|
203
|
-
case 33:
|
|
204
|
-
return _context2.finish(30);
|
|
205
|
-
|
|
206
|
-
case 34:
|
|
148
|
+
case 28:
|
|
207
149
|
return _context2.finish(25);
|
|
208
|
-
|
|
209
|
-
|
|
150
|
+
case 29:
|
|
151
|
+
return _context2.finish(20);
|
|
152
|
+
case 30:
|
|
210
153
|
case "end":
|
|
211
154
|
return _context2.stop();
|
|
212
155
|
}
|
|
213
156
|
}
|
|
214
|
-
}, _callee2, null, [[3,
|
|
157
|
+
}, _callee2, null, [[3, 16, 20, 30], [21,, 25, 29]]);
|
|
215
158
|
}));
|
|
216
159
|
return _makeTextEncoderIterator.apply(this, arguments);
|
|
217
160
|
}
|
|
218
|
-
|
|
219
161
|
function makeLineIterator(_x3) {
|
|
220
162
|
return _makeLineIterator.apply(this, arguments);
|
|
221
163
|
}
|
|
222
|
-
|
|
223
164
|
function _makeLineIterator() {
|
|
224
165
|
_makeLineIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee3(textIterator) {
|
|
225
|
-
var previous,
|
|
226
|
-
|
|
166
|
+
var previous, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, textChunk, eolIndex, line;
|
|
227
167
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
228
168
|
while (1) {
|
|
229
169
|
switch (_context3.prev = _context3.next) {
|
|
230
170
|
case 0:
|
|
231
171
|
previous = '';
|
|
232
|
-
|
|
172
|
+
_iteratorAbruptCompletion3 = false;
|
|
233
173
|
_didIteratorError3 = false;
|
|
234
174
|
_context3.prev = 3;
|
|
235
|
-
_iterator3 = (
|
|
236
|
-
|
|
175
|
+
_iterator3 = _asyncIterator(textIterator);
|
|
237
176
|
case 5:
|
|
238
177
|
_context3.next = 7;
|
|
239
178
|
return (0, _awaitAsyncGenerator2.default)(_iterator3.next());
|
|
240
|
-
|
|
241
179
|
case 7:
|
|
242
|
-
_step3 = _context3.sent
|
|
243
|
-
|
|
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;
|
|
180
|
+
if (!(_iteratorAbruptCompletion3 = !(_step3 = _context3.sent).done)) {
|
|
181
|
+
_context3.next = 21;
|
|
252
182
|
break;
|
|
253
183
|
}
|
|
254
|
-
|
|
255
|
-
textChunk = _value3;
|
|
184
|
+
textChunk = _step3.value;
|
|
256
185
|
previous += textChunk;
|
|
257
186
|
eolIndex = void 0;
|
|
258
|
-
|
|
259
|
-
case 16:
|
|
187
|
+
case 11:
|
|
260
188
|
if (!((eolIndex = previous.indexOf('\n')) >= 0)) {
|
|
261
|
-
_context3.next =
|
|
189
|
+
_context3.next = 18;
|
|
262
190
|
break;
|
|
263
191
|
}
|
|
264
|
-
|
|
265
192
|
line = previous.slice(0, eolIndex + 1);
|
|
266
193
|
previous = previous.slice(eolIndex + 1);
|
|
267
|
-
_context3.next = 21;
|
|
268
|
-
return line;
|
|
269
|
-
|
|
270
|
-
case 21:
|
|
271
194
|
_context3.next = 16;
|
|
195
|
+
return line;
|
|
196
|
+
case 16:
|
|
197
|
+
_context3.next = 11;
|
|
272
198
|
break;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
_iteratorNormalCompletion3 = true;
|
|
199
|
+
case 18:
|
|
200
|
+
_iteratorAbruptCompletion3 = false;
|
|
276
201
|
_context3.next = 5;
|
|
277
202
|
break;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
_context3.next = 32;
|
|
203
|
+
case 21:
|
|
204
|
+
_context3.next = 27;
|
|
281
205
|
break;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
_context3.prev = 28;
|
|
206
|
+
case 23:
|
|
207
|
+
_context3.prev = 23;
|
|
285
208
|
_context3.t0 = _context3["catch"](3);
|
|
286
209
|
_didIteratorError3 = true;
|
|
287
210
|
_iteratorError3 = _context3.t0;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
_context3.prev =
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (!(!_iteratorNormalCompletion3 && _iterator3.return != null)) {
|
|
294
|
-
_context3.next = 37;
|
|
211
|
+
case 27:
|
|
212
|
+
_context3.prev = 27;
|
|
213
|
+
_context3.prev = 28;
|
|
214
|
+
if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) {
|
|
215
|
+
_context3.next = 32;
|
|
295
216
|
break;
|
|
296
217
|
}
|
|
297
|
-
|
|
298
|
-
_context3.next = 37;
|
|
218
|
+
_context3.next = 32;
|
|
299
219
|
return (0, _awaitAsyncGenerator2.default)(_iterator3.return());
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
_context3.prev = 37;
|
|
303
|
-
|
|
220
|
+
case 32:
|
|
221
|
+
_context3.prev = 32;
|
|
304
222
|
if (!_didIteratorError3) {
|
|
305
|
-
_context3.next =
|
|
223
|
+
_context3.next = 35;
|
|
306
224
|
break;
|
|
307
225
|
}
|
|
308
|
-
|
|
309
226
|
throw _iteratorError3;
|
|
310
|
-
|
|
311
|
-
case 40:
|
|
312
|
-
return _context3.finish(37);
|
|
313
|
-
|
|
314
|
-
case 41:
|
|
227
|
+
case 35:
|
|
315
228
|
return _context3.finish(32);
|
|
316
|
-
|
|
317
|
-
|
|
229
|
+
case 36:
|
|
230
|
+
return _context3.finish(27);
|
|
231
|
+
case 37:
|
|
318
232
|
if (!(previous.length > 0)) {
|
|
319
|
-
_context3.next =
|
|
233
|
+
_context3.next = 40;
|
|
320
234
|
break;
|
|
321
235
|
}
|
|
322
|
-
|
|
323
|
-
_context3.next = 45;
|
|
236
|
+
_context3.next = 40;
|
|
324
237
|
return previous;
|
|
325
|
-
|
|
326
|
-
case 45:
|
|
238
|
+
case 40:
|
|
327
239
|
case "end":
|
|
328
240
|
return _context3.stop();
|
|
329
241
|
}
|
|
330
242
|
}
|
|
331
|
-
}, _callee3, null, [[3,
|
|
243
|
+
}, _callee3, null, [[3, 23, 27, 37], [28,, 32, 36]]);
|
|
332
244
|
}));
|
|
333
245
|
return _makeLineIterator.apply(this, arguments);
|
|
334
246
|
}
|
|
335
|
-
|
|
336
247
|
function makeNumberedLineIterator(_x4) {
|
|
337
248
|
return _makeNumberedLineIterator.apply(this, arguments);
|
|
338
249
|
}
|
|
339
|
-
|
|
340
250
|
function _makeNumberedLineIterator() {
|
|
341
251
|
_makeNumberedLineIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee4(lineIterator) {
|
|
342
|
-
var counter,
|
|
343
|
-
|
|
252
|
+
var counter, _iteratorAbruptCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, line;
|
|
344
253
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
345
254
|
while (1) {
|
|
346
255
|
switch (_context4.prev = _context4.next) {
|
|
347
256
|
case 0:
|
|
348
257
|
counter = 1;
|
|
349
|
-
|
|
258
|
+
_iteratorAbruptCompletion4 = false;
|
|
350
259
|
_didIteratorError4 = false;
|
|
351
260
|
_context4.prev = 3;
|
|
352
|
-
_iterator4 = (
|
|
353
|
-
|
|
261
|
+
_iterator4 = _asyncIterator(lineIterator);
|
|
354
262
|
case 5:
|
|
355
263
|
_context4.next = 7;
|
|
356
264
|
return (0, _awaitAsyncGenerator2.default)(_iterator4.next());
|
|
357
|
-
|
|
358
265
|
case 7:
|
|
359
|
-
_step4 = _context4.sent
|
|
360
|
-
|
|
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;
|
|
266
|
+
if (!(_iteratorAbruptCompletion4 = !(_step4 = _context4.sent).done)) {
|
|
267
|
+
_context4.next = 15;
|
|
369
268
|
break;
|
|
370
269
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
_context4.next = 16;
|
|
270
|
+
line = _step4.value;
|
|
271
|
+
_context4.next = 11;
|
|
374
272
|
return {
|
|
375
273
|
counter: counter,
|
|
376
274
|
line: line
|
|
377
275
|
};
|
|
378
|
-
|
|
379
|
-
case 16:
|
|
276
|
+
case 11:
|
|
380
277
|
counter++;
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
_iteratorNormalCompletion4 = true;
|
|
278
|
+
case 12:
|
|
279
|
+
_iteratorAbruptCompletion4 = false;
|
|
384
280
|
_context4.next = 5;
|
|
385
281
|
break;
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
_context4.next = 26;
|
|
282
|
+
case 15:
|
|
283
|
+
_context4.next = 21;
|
|
389
284
|
break;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
_context4.prev = 22;
|
|
285
|
+
case 17:
|
|
286
|
+
_context4.prev = 17;
|
|
393
287
|
_context4.t0 = _context4["catch"](3);
|
|
394
288
|
_didIteratorError4 = true;
|
|
395
289
|
_iteratorError4 = _context4.t0;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
_context4.prev =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (!(!_iteratorNormalCompletion4 && _iterator4.return != null)) {
|
|
402
|
-
_context4.next = 31;
|
|
290
|
+
case 21:
|
|
291
|
+
_context4.prev = 21;
|
|
292
|
+
_context4.prev = 22;
|
|
293
|
+
if (!(_iteratorAbruptCompletion4 && _iterator4.return != null)) {
|
|
294
|
+
_context4.next = 26;
|
|
403
295
|
break;
|
|
404
296
|
}
|
|
405
|
-
|
|
406
|
-
_context4.next = 31;
|
|
297
|
+
_context4.next = 26;
|
|
407
298
|
return (0, _awaitAsyncGenerator2.default)(_iterator4.return());
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
_context4.prev = 31;
|
|
411
|
-
|
|
299
|
+
case 26:
|
|
300
|
+
_context4.prev = 26;
|
|
412
301
|
if (!_didIteratorError4) {
|
|
413
|
-
_context4.next =
|
|
302
|
+
_context4.next = 29;
|
|
414
303
|
break;
|
|
415
304
|
}
|
|
416
|
-
|
|
417
305
|
throw _iteratorError4;
|
|
418
|
-
|
|
419
|
-
case 34:
|
|
420
|
-
return _context4.finish(31);
|
|
421
|
-
|
|
422
|
-
case 35:
|
|
306
|
+
case 29:
|
|
423
307
|
return _context4.finish(26);
|
|
424
|
-
|
|
425
|
-
|
|
308
|
+
case 30:
|
|
309
|
+
return _context4.finish(21);
|
|
310
|
+
case 31:
|
|
426
311
|
case "end":
|
|
427
312
|
return _context4.stop();
|
|
428
313
|
}
|
|
429
314
|
}
|
|
430
|
-
}, _callee4, null, [[3,
|
|
315
|
+
}, _callee4, null, [[3, 17, 21, 31], [22,, 26, 30]]);
|
|
431
316
|
}));
|
|
432
317
|
return _makeNumberedLineIterator.apply(this, arguments);
|
|
433
318
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"text-iterators.js","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"],"sources":["../../../../src/lib/iterators/text-iterators.ts"],"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"],"mappings":"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"}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.toArrayBuffer = toArrayBuffer;
|
|
7
7
|
exports.toBuffer = toBuffer;
|
|
8
|
-
|
|
9
8
|
var _assert = require("../env-utils/assert");
|
|
10
9
|
|
|
11
10
|
function toArrayBuffer(buffer) {
|
|
@@ -13,7 +12,6 @@ function toArrayBuffer(buffer) {
|
|
|
13
12
|
var typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
14
13
|
return typedArray.slice().buffer;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
return buffer;
|
|
18
16
|
}
|
|
19
17
|
|
|
@@ -21,18 +19,14 @@ function toBuffer(binaryData) {
|
|
|
21
19
|
if (ArrayBuffer.isView(binaryData)) {
|
|
22
20
|
binaryData = binaryData.buffer;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
26
23
|
var buffer = new Buffer(binaryData.byteLength);
|
|
27
24
|
var view = new Uint8Array(binaryData);
|
|
28
|
-
|
|
29
25
|
for (var i = 0; i < buffer.length; ++i) {
|
|
30
26
|
buffer[i] = view[i];
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
return buffer;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
return (0, _assert.assert)(false);
|
|
37
31
|
}
|
|
38
32
|
//# sourceMappingURL=buffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"buffer.js","names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i","assert"],"sources":["../../../../src/lib/node/buffer.ts"],"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.buffer, buffer.byteOffset, buffer.length);\n return typedArray.slice().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"],"mappings":";;;;;;;AAGA;;AAKO,SAASA,aAAa,CAACC,MAAM,EAAE;EAEpC,IAAIC,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,EAAE;IAC3B,IAAMG,UAAU,GAAG,IAAIC,UAAU,CAACJ,MAAM,CAACA,MAAM,EAAEA,MAAM,CAACK,UAAU,EAAEL,MAAM,CAACM,MAAM,CAAC;IAClF,OAAOH,UAAU,CAACI,KAAK,EAAE,CAACP,MAAM;EAClC;EACA,OAAOA,MAAM;AACf;;AAKO,SAASQ,QAAQ,CAACC,UAAU,EAAE;EACnC,IAAIC,WAAW,CAACC,MAAM,CAACF,UAAU,CAAC,EAAE;IAClCA,UAAU,GAAGA,UAAU,CAACT,MAAM;EAChC;EAEA,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAIQ,UAAU,YAAYC,WAAW,EAAE;IACtE,IAAMV,MAAM,GAAG,IAAIC,MAAM,CAACQ,UAAU,CAACG,UAAU,CAAC;IAChD,IAAMC,IAAI,GAAG,IAAIT,UAAU,CAACK,UAAU,CAAC;IACvC,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGd,MAAM,CAACM,MAAM,EAAE,EAAEQ,CAAC,EAAE;MACtCd,MAAM,CAACc,CAAC,CAAC,GAAGD,IAAI,CAACC,CAAC,CAAC;IACrB;IACA,OAAOd,MAAM;EACf;EAEA,OAAO,IAAAe,cAAM,EAAC,KAAK,CAAC;AACtB"}
|