@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.
Files changed (52) hide show
  1. package/dist/es5/index.js +46 -48
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/json-loader.js +5 -33
  4. package/dist/es5/json-loader.js.map +1 -1
  5. package/dist/es5/lib/binary-utils/array-buffer-utils.js +25 -62
  6. package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
  7. package/dist/es5/lib/binary-utils/binary-copy-utils.js +7 -7
  8. package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -1
  9. package/dist/es5/lib/binary-utils/buffer-utils.js +3 -9
  10. package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -1
  11. package/dist/es5/lib/binary-utils/encode-utils.js +7 -7
  12. package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -1
  13. package/dist/es5/lib/binary-utils/get-first-characters.js +5 -7
  14. package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
  15. package/dist/es5/lib/binary-utils/memory-copy-utils.js +6 -7
  16. package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
  17. package/dist/es5/lib/env-utils/globals.js +9 -14
  18. package/dist/es5/lib/env-utils/globals.js.map +1 -1
  19. package/dist/es5/lib/filesystems/node-filesystem.js +50 -243
  20. package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
  21. package/dist/es5/lib/iterators/async-iteration.js +27 -242
  22. package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
  23. package/dist/es5/lib/iterators/text-iterators.js +35 -410
  24. package/dist/es5/lib/iterators/text-iterators.js.map +1 -1
  25. package/dist/es5/lib/node/buffer.js +4 -4
  26. package/dist/es5/lib/node/buffer.js.map +1 -1
  27. package/dist/es5/lib/node/fs.js +20 -51
  28. package/dist/es5/lib/node/fs.js.map +1 -1
  29. package/dist/es5/lib/node/util.js +3 -5
  30. package/dist/es5/lib/node/util.js.map +1 -1
  31. package/dist/es5/lib/path-utils/file-aliases.js +4 -4
  32. package/dist/es5/lib/path-utils/file-aliases.js.map +1 -1
  33. package/dist/es5/lib/path-utils/path.js +4 -8
  34. package/dist/es5/lib/path-utils/path.js.map +1 -1
  35. package/dist/es5/lib/request-utils/request-scheduler.js +96 -124
  36. package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -1
  37. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +63 -132
  38. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  39. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +51 -111
  40. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  41. package/dist/esm/json-loader.js +1 -1
  42. package/dist/esm/lib/parser-utils/parse-json.js +1 -1
  43. package/dist/esm/lib/parser-utils/parse-json.js.map +1 -1
  44. package/dist/esm/lib/path-utils/file-aliases.js +1 -1
  45. package/dist/esm/lib/path-utils/file-aliases.js.map +1 -1
  46. package/dist/esm/lib/path-utils/path.js +2 -2
  47. package/dist/esm/lib/path-utils/path.js.map +1 -1
  48. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +1 -1
  49. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  50. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +1 -1
  51. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  52. package/package.json +3 -3
package/dist/es5/index.js CHANGED
@@ -2,272 +2,270 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  Object.defineProperty(exports, "assert", {
11
9
  enumerable: true,
12
- get: function get() {
10
+ get: function () {
13
11
  return _assert.assert;
14
12
  }
15
13
  });
16
14
  Object.defineProperty(exports, "isBrowser", {
17
15
  enumerable: true,
18
- get: function get() {
16
+ get: function () {
19
17
  return _globals.isBrowser;
20
18
  }
21
19
  });
22
20
  Object.defineProperty(exports, "isWorker", {
23
21
  enumerable: true,
24
- get: function get() {
22
+ get: function () {
25
23
  return _globals.isWorker;
26
24
  }
27
25
  });
28
26
  Object.defineProperty(exports, "nodeVersion", {
29
27
  enumerable: true,
30
- get: function get() {
28
+ get: function () {
31
29
  return _globals.nodeVersion;
32
30
  }
33
31
  });
34
32
  Object.defineProperty(exports, "self", {
35
33
  enumerable: true,
36
- get: function get() {
34
+ get: function () {
37
35
  return _globals.self;
38
36
  }
39
37
  });
40
38
  Object.defineProperty(exports, "window", {
41
39
  enumerable: true,
42
- get: function get() {
40
+ get: function () {
43
41
  return _globals.window;
44
42
  }
45
43
  });
46
44
  Object.defineProperty(exports, "global", {
47
45
  enumerable: true,
48
- get: function get() {
46
+ get: function () {
49
47
  return _globals.global;
50
48
  }
51
49
  });
52
50
  Object.defineProperty(exports, "document", {
53
51
  enumerable: true,
54
- get: function get() {
52
+ get: function () {
55
53
  return _globals.document;
56
54
  }
57
55
  });
58
56
  Object.defineProperty(exports, "createLoaderWorker", {
59
57
  enumerable: true,
60
- get: function get() {
58
+ get: function () {
61
59
  return _createLoaderWorker.createLoaderWorker;
62
60
  }
63
61
  });
64
62
  Object.defineProperty(exports, "parseWithWorker", {
65
63
  enumerable: true,
66
- get: function get() {
64
+ get: function () {
67
65
  return _parseWithWorker.parseWithWorker;
68
66
  }
69
67
  });
70
68
  Object.defineProperty(exports, "canParseWithWorker", {
71
69
  enumerable: true,
72
- get: function get() {
70
+ get: function () {
73
71
  return _parseWithWorker.canParseWithWorker;
74
72
  }
75
73
  });
76
74
  Object.defineProperty(exports, "parseJSON", {
77
75
  enumerable: true,
78
- get: function get() {
76
+ get: function () {
79
77
  return _parseJson.parseJSON;
80
78
  }
81
79
  });
82
80
  Object.defineProperty(exports, "toArrayBuffer", {
83
81
  enumerable: true,
84
- get: function get() {
82
+ get: function () {
85
83
  return _arrayBufferUtils.toArrayBuffer;
86
84
  }
87
85
  });
88
86
  Object.defineProperty(exports, "sliceArrayBuffer", {
89
87
  enumerable: true,
90
- get: function get() {
88
+ get: function () {
91
89
  return _arrayBufferUtils.sliceArrayBuffer;
92
90
  }
93
91
  });
94
92
  Object.defineProperty(exports, "concatenateArrayBuffers", {
95
93
  enumerable: true,
96
- get: function get() {
94
+ get: function () {
97
95
  return _arrayBufferUtils.concatenateArrayBuffers;
98
96
  }
99
97
  });
100
98
  Object.defineProperty(exports, "concatenateTypedArrays", {
101
99
  enumerable: true,
102
- get: function get() {
100
+ get: function () {
103
101
  return _arrayBufferUtils.concatenateTypedArrays;
104
102
  }
105
103
  });
106
104
  Object.defineProperty(exports, "compareArrayBuffers", {
107
105
  enumerable: true,
108
- get: function get() {
106
+ get: function () {
109
107
  return _arrayBufferUtils.compareArrayBuffers;
110
108
  }
111
109
  });
112
110
  Object.defineProperty(exports, "padToNBytes", {
113
111
  enumerable: true,
114
- get: function get() {
112
+ get: function () {
115
113
  return _memoryCopyUtils.padToNBytes;
116
114
  }
117
115
  });
118
116
  Object.defineProperty(exports, "copyToArray", {
119
117
  enumerable: true,
120
- get: function get() {
118
+ get: function () {
121
119
  return _memoryCopyUtils.copyToArray;
122
120
  }
123
121
  });
124
122
  Object.defineProperty(exports, "copyArrayBuffer", {
125
123
  enumerable: true,
126
- get: function get() {
124
+ get: function () {
127
125
  return _memoryCopyUtils.copyArrayBuffer;
128
126
  }
129
127
  });
130
128
  Object.defineProperty(exports, "copyPaddedArrayBufferToDataView", {
131
129
  enumerable: true,
132
- get: function get() {
130
+ get: function () {
133
131
  return _binaryCopyUtils.copyPaddedArrayBufferToDataView;
134
132
  }
135
133
  });
136
134
  Object.defineProperty(exports, "copyPaddedStringToDataView", {
137
135
  enumerable: true,
138
- get: function get() {
136
+ get: function () {
139
137
  return _binaryCopyUtils.copyPaddedStringToDataView;
140
138
  }
141
139
  });
142
140
  Object.defineProperty(exports, "padStringToByteAlignment", {
143
141
  enumerable: true,
144
- get: function get() {
142
+ get: function () {
145
143
  return _encodeUtils.padStringToByteAlignment;
146
144
  }
147
145
  });
148
146
  Object.defineProperty(exports, "copyStringToDataView", {
149
147
  enumerable: true,
150
- get: function get() {
148
+ get: function () {
151
149
  return _encodeUtils.copyStringToDataView;
152
150
  }
153
151
  });
154
152
  Object.defineProperty(exports, "copyBinaryToDataView", {
155
153
  enumerable: true,
156
- get: function get() {
154
+ get: function () {
157
155
  return _encodeUtils.copyBinaryToDataView;
158
156
  }
159
157
  });
160
158
  Object.defineProperty(exports, "getFirstCharacters", {
161
159
  enumerable: true,
162
- get: function get() {
160
+ get: function () {
163
161
  return _getFirstCharacters.getFirstCharacters;
164
162
  }
165
163
  });
166
164
  Object.defineProperty(exports, "getMagicString", {
167
165
  enumerable: true,
168
- get: function get() {
166
+ get: function () {
169
167
  return _getFirstCharacters.getMagicString;
170
168
  }
171
169
  });
172
170
  Object.defineProperty(exports, "makeTextEncoderIterator", {
173
171
  enumerable: true,
174
- get: function get() {
172
+ get: function () {
175
173
  return _textIterators.makeTextEncoderIterator;
176
174
  }
177
175
  });
178
176
  Object.defineProperty(exports, "makeTextDecoderIterator", {
179
177
  enumerable: true,
180
- get: function get() {
178
+ get: function () {
181
179
  return _textIterators.makeTextDecoderIterator;
182
180
  }
183
181
  });
184
182
  Object.defineProperty(exports, "makeLineIterator", {
185
183
  enumerable: true,
186
- get: function get() {
184
+ get: function () {
187
185
  return _textIterators.makeLineIterator;
188
186
  }
189
187
  });
190
188
  Object.defineProperty(exports, "makeNumberedLineIterator", {
191
189
  enumerable: true,
192
- get: function get() {
190
+ get: function () {
193
191
  return _textIterators.makeNumberedLineIterator;
194
192
  }
195
193
  });
196
194
  Object.defineProperty(exports, "forEach", {
197
195
  enumerable: true,
198
- get: function get() {
196
+ get: function () {
199
197
  return _asyncIteration.forEach;
200
198
  }
201
199
  });
202
200
  Object.defineProperty(exports, "concatenateArrayBuffersAsync", {
203
201
  enumerable: true,
204
- get: function get() {
202
+ get: function () {
205
203
  return _asyncIteration.concatenateArrayBuffersAsync;
206
204
  }
207
205
  });
208
206
  Object.defineProperty(exports, "RequestScheduler", {
209
207
  enumerable: true,
210
- get: function get() {
208
+ get: function () {
211
209
  return _requestScheduler.default;
212
210
  }
213
211
  });
214
212
  Object.defineProperty(exports, "setPathPrefix", {
215
213
  enumerable: true,
216
- get: function get() {
214
+ get: function () {
217
215
  return _fileAliases.setPathPrefix;
218
216
  }
219
217
  });
220
218
  Object.defineProperty(exports, "getPathPrefix", {
221
219
  enumerable: true,
222
- get: function get() {
220
+ get: function () {
223
221
  return _fileAliases.getPathPrefix;
224
222
  }
225
223
  });
226
224
  Object.defineProperty(exports, "resolvePath", {
227
225
  enumerable: true,
228
- get: function get() {
226
+ get: function () {
229
227
  return _fileAliases.resolvePath;
230
228
  }
231
229
  });
232
230
  Object.defineProperty(exports, "_addAliases", {
233
231
  enumerable: true,
234
- get: function get() {
232
+ get: function () {
235
233
  return _fileAliases.addAliases;
236
234
  }
237
235
  });
238
236
  Object.defineProperty(exports, "JSONLoader", {
239
237
  enumerable: true,
240
- get: function get() {
238
+ get: function () {
241
239
  return _jsonLoader.JSONLoader;
242
240
  }
243
241
  });
244
242
  Object.defineProperty(exports, "isBuffer", {
245
243
  enumerable: true,
246
- get: function get() {
244
+ get: function () {
247
245
  return _bufferUtils.isBuffer;
248
246
  }
249
247
  });
250
248
  Object.defineProperty(exports, "toBuffer", {
251
249
  enumerable: true,
252
- get: function get() {
250
+ get: function () {
253
251
  return _bufferUtils.toBuffer;
254
252
  }
255
253
  });
256
254
  Object.defineProperty(exports, "bufferToArrayBuffer", {
257
255
  enumerable: true,
258
- get: function get() {
256
+ get: function () {
259
257
  return _bufferUtils.bufferToArrayBuffer;
260
258
  }
261
259
  });
262
260
  Object.defineProperty(exports, "promisify", {
263
261
  enumerable: true,
264
- get: function get() {
262
+ get: function () {
265
263
  return util.promisify;
266
264
  }
267
265
  });
268
266
  Object.defineProperty(exports, "_NodeFileSystem", {
269
267
  enumerable: true,
270
- get: function get() {
268
+ get: function () {
271
269
  return _nodeFilesystem.default;
272
270
  }
273
271
  });
@@ -319,7 +317,7 @@ exports.fs = fs;
319
317
 
320
318
  var _nodeFilesystem = _interopRequireDefault(require("./lib/filesystems/node-filesystem"));
321
319
 
322
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
320
+ 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); }
323
321
 
324
- 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; }
322
+ 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; }
325
323
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA;;AACA;;AAWA;;AACA;;AAGA;;AAGA;;AAOA;;AACA;;AAIA;;AAKA;;AAGA;;AAMA;;AAGA;;AAGA;;AAIA;;AAOA;;;;AAIA;;AAKA;;;;AAMA;;;;AAIA","sourcesContent":["// TYPES\nexport type {\n Loader,\n LoaderWithParser,\n LoaderContext,\n LoaderOptions,\n Writer,\n WriterOptions,\n DataType,\n SyncDataType,\n BatchableDataType,\n IFileSystem,\n IRandomAccessReadFileSystem\n} from './types';\n\n// GENERAL UTILS\nexport {assert} from './lib/env-utils/assert';\nexport {\n isBrowser,\n isWorker,\n nodeVersion,\n self,\n window,\n global,\n document\n} from './lib/env-utils/globals';\n\n// LOADERS.GL-SPECIFIC WORKER UTILS\nexport {createLoaderWorker} from './lib/worker-loader-utils/create-loader-worker';\nexport {parseWithWorker, canParseWithWorker} from './lib/worker-loader-utils/parse-with-worker';\n\n// PARSER UTILS\nexport {parseJSON} from './lib/parser-utils/parse-json';\n\n// MEMORY COPY UTILS\nexport {\n toArrayBuffer,\n sliceArrayBuffer,\n concatenateArrayBuffers,\n concatenateTypedArrays,\n compareArrayBuffers\n} from './lib/binary-utils/array-buffer-utils';\nexport {padToNBytes, copyToArray, copyArrayBuffer} from './lib/binary-utils/memory-copy-utils';\nexport {\n copyPaddedArrayBufferToDataView,\n copyPaddedStringToDataView\n} from './lib/binary-utils/binary-copy-utils';\nexport {\n padStringToByteAlignment,\n copyStringToDataView,\n copyBinaryToDataView\n} from './lib/binary-utils/encode-utils';\nexport {getFirstCharacters, getMagicString} from './lib/binary-utils/get-first-characters';\n\n// ITERATOR UTILS\nexport {\n makeTextEncoderIterator,\n makeTextDecoderIterator,\n makeLineIterator,\n makeNumberedLineIterator\n} from './lib/iterators/text-iterators';\nexport {forEach, concatenateArrayBuffersAsync} from './lib/iterators/async-iteration';\n\n// REQUEST UTILS\nexport {default as RequestScheduler} from './lib/request-utils/request-scheduler';\n\n// PATH HELPERS\nexport {setPathPrefix, getPathPrefix, resolvePath} from './lib/path-utils/file-aliases';\nexport {addAliases as _addAliases} from './lib/path-utils/file-aliases';\n\n// MICRO LOADERS\nexport {JSONLoader} from './json-loader';\n\n// NODE support\n\n// Node.js emulation (can be used in browser)\n\n// `path` replacement (avoids bundling big path polyfill)\nimport * as path from './lib/path-utils/path';\nexport {path};\n\n// Avoid direct use of `Buffer` which pulls in 50KB polyfill\nexport {isBuffer, toBuffer, bufferToArrayBuffer} from './lib/binary-utils/buffer-utils';\n\n// Note.js wrappers (can be safely imported, but not used in browser)\n\n// Use instead of importing 'util'\nimport * as util from './lib/node/util';\nexport {util};\n// TODO - remove\nexport {promisify} from './lib/node/util';\n\n// Use instead of importing 'fs';`\nimport * as fs from './lib/node/fs';\nexport {fs};\n\n// EXPERIMENTAL\nexport {default as _NodeFileSystem} from './lib/filesystems/node-filesystem';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA;;AACA;;AAWA;;AACA;;AAGA;;AAGA;;AAOA;;AACA;;AAIA;;AAKA;;AAGA;;AAMA;;AAGA;;AAGA;;AAIA;;AAOA;;;;AAIA;;AAKA;;;;AAMA;;;;AAIA","sourcesContent":["// TYPES\nexport type {\n Loader,\n LoaderWithParser,\n LoaderContext,\n LoaderOptions,\n Writer,\n WriterOptions,\n DataType,\n SyncDataType,\n BatchableDataType,\n IFileSystem,\n IRandomAccessReadFileSystem\n} from './types';\n\n// GENERAL UTILS\nexport {assert} from './lib/env-utils/assert';\nexport {\n isBrowser,\n isWorker,\n nodeVersion,\n self,\n window,\n global,\n document\n} from './lib/env-utils/globals';\n\n// LOADERS.GL-SPECIFIC WORKER UTILS\nexport {createLoaderWorker} from './lib/worker-loader-utils/create-loader-worker';\nexport {parseWithWorker, canParseWithWorker} from './lib/worker-loader-utils/parse-with-worker';\n\n// PARSER UTILS\nexport {parseJSON} from './lib/parser-utils/parse-json';\n\n// MEMORY COPY UTILS\nexport {\n toArrayBuffer,\n sliceArrayBuffer,\n concatenateArrayBuffers,\n concatenateTypedArrays,\n compareArrayBuffers\n} from './lib/binary-utils/array-buffer-utils';\nexport {padToNBytes, copyToArray, copyArrayBuffer} from './lib/binary-utils/memory-copy-utils';\nexport {\n copyPaddedArrayBufferToDataView,\n copyPaddedStringToDataView\n} from './lib/binary-utils/binary-copy-utils';\nexport {\n padStringToByteAlignment,\n copyStringToDataView,\n copyBinaryToDataView\n} from './lib/binary-utils/encode-utils';\nexport {getFirstCharacters, getMagicString} from './lib/binary-utils/get-first-characters';\n\n// ITERATOR UTILS\nexport {\n makeTextEncoderIterator,\n makeTextDecoderIterator,\n makeLineIterator,\n makeNumberedLineIterator\n} from './lib/iterators/text-iterators';\nexport {forEach, concatenateArrayBuffersAsync} from './lib/iterators/async-iteration';\n\n// REQUEST UTILS\nexport {default as RequestScheduler} from './lib/request-utils/request-scheduler';\n\n// PATH HELPERS\nexport {setPathPrefix, getPathPrefix, resolvePath} from './lib/path-utils/file-aliases';\nexport {addAliases as _addAliases} from './lib/path-utils/file-aliases';\n\n// MICRO LOADERS\nexport {JSONLoader} from './json-loader';\n\n// NODE support\n\n// Node.js emulation (can be used in browser)\n\n// `path` replacement (avoids bundling big path polyfill)\nimport * as path from './lib/path-utils/path';\nexport {path};\n\n// Avoid direct use of `Buffer` which pulls in 50KB polyfill\nexport {isBuffer, toBuffer, bufferToArrayBuffer} from './lib/binary-utils/buffer-utils';\n\n// Note.js wrappers (can be safely imported, but not used in browser)\n\n// Use instead of importing 'util'\nimport * as util from './lib/node/util';\nexport {util};\n// TODO - remove\nexport {promisify} from './lib/node/util';\n\n// Use instead of importing 'fs';`\nimport * as fs from './lib/node/fs';\nexport {fs};\n\n// EXPERIMENTAL\nexport {default as _NodeFileSystem} from './lib/filesystems/node-filesystem';\n"],"file":"index.js"}
@@ -1,18 +1,11 @@
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
  });
8
6
  exports._typecheckJSONLoader = exports.JSONLoader = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var VERSION = typeof "3.0.12" !== 'undefined' ? "3.0.12" : 'latest';
15
- var JSONLoader = {
7
+ const VERSION = typeof "3.0.13" !== 'undefined' ? "3.0.13" : 'latest';
8
+ const JSONLoader = {
16
9
  name: 'JSON',
17
10
  id: 'json',
18
11
  module: 'json',
@@ -21,29 +14,8 @@ var JSONLoader = {
21
14
  mimeTypes: ['application/json'],
22
15
  category: 'json',
23
16
  text: true,
24
- parseTextSync: parseTextSync,
25
- parse: function () {
26
- var _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer) {
27
- return _regenerator.default.wrap(function _callee$(_context) {
28
- while (1) {
29
- switch (_context.prev = _context.next) {
30
- case 0:
31
- return _context.abrupt("return", parseTextSync(new TextDecoder().decode(arrayBuffer)));
32
-
33
- case 1:
34
- case "end":
35
- return _context.stop();
36
- }
37
- }
38
- }, _callee);
39
- }));
40
-
41
- function parse(_x) {
42
- return _parse.apply(this, arguments);
43
- }
44
-
45
- return parse;
46
- }(),
17
+ parseTextSync,
18
+ parse: async arrayBuffer => parseTextSync(new TextDecoder().decode(arrayBuffer)),
47
19
  options: {}
48
20
  };
49
21
  exports.JSONLoader = JSONLoader;
@@ -52,6 +24,6 @@ function parseTextSync(text) {
52
24
  return JSON.parse(text);
53
25
  }
54
26
 
55
- var _typecheckJSONLoader = JSONLoader;
27
+ const _typecheckJSONLoader = JSONLoader;
56
28
  exports._typecheckJSONLoader = _typecheckJSONLoader;
57
29
  //# sourceMappingURL=json-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON","_typecheckJSONLoader"],"mappings":";;;;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAMO,IAAMC,UAAU,GAAG;AACxBC,EAAAA,IAAI,EAAE,MADkB;AAExBC,EAAAA,EAAE,EAAE,MAFoB;AAGxBC,EAAAA,MAAM,EAAE,MAHgB;AAIxBC,EAAAA,OAAO,EAAEL,OAJe;AAKxBM,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CALY;AAMxBC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CANa;AAOxBC,EAAAA,QAAQ,EAAE,MAPc;AAQxBC,EAAAA,IAAI,EAAE,IARkB;AASxBC,EAAAA,aAAa,EAAbA,aATwB;AAUxBC,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAuBF,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,CAApC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KAVmB;AAWxBG,EAAAA,OAAO,EAAE;AAXe,CAAnB;;;AAeP,SAASL,aAAT,CAAuBD,IAAvB,EAA6B;AAC3B,SAAOO,IAAI,CAACL,KAAL,CAAWF,IAAX,CAAP;AACD;;AAEM,IAAMQ,oBAAsC,GAAGhB,UAA/C","sourcesContent":["import type {LoaderWithParser} from './types';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'json',\n text: true,\n parseTextSync,\n parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),\n options: {}\n};\n\n// TODO - deprecated\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n\nexport const _typecheckJSONLoader: LoaderWithParser = JSONLoader;\n"],"file":"json-loader.js"}
1
+ {"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON","_typecheckJSONLoader"],"mappings":";;;;;;AAIA,MAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAMO,MAAMC,UAAU,GAAG;AACxBC,EAAAA,IAAI,EAAE,MADkB;AAExBC,EAAAA,EAAE,EAAE,MAFoB;AAGxBC,EAAAA,MAAM,EAAE,MAHgB;AAIxBC,EAAAA,OAAO,EAAEL,OAJe;AAKxBM,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CALY;AAMxBC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CANa;AAOxBC,EAAAA,QAAQ,EAAE,MAPc;AAQxBC,EAAAA,IAAI,EAAE,IARkB;AASxBC,EAAAA,aATwB;AAUxBC,EAAAA,KAAK,EAAE,MAAOC,WAAP,IAAuBF,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,CAVnB;AAWxBG,EAAAA,OAAO,EAAE;AAXe,CAAnB;;;AAeP,SAASL,aAAT,CAAuBD,IAAvB,EAA6B;AAC3B,SAAOO,IAAI,CAACL,KAAL,CAAWF,IAAX,CAAP;AACD;;AAEM,MAAMQ,oBAAsC,GAAGhB,UAA/C","sourcesContent":["import type {LoaderWithParser} from './types';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'json',\n text: true,\n parseTextSync,\n parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),\n options: {}\n};\n\n// TODO - deprecated\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n\nexport const _typecheckJSONLoader: LoaderWithParser = JSONLoader;\n"],"file":"json-loader.js"}
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
3
  Object.defineProperty(exports, "__esModule", {
8
4
  value: true
9
5
  });
@@ -13,19 +9,11 @@ exports.concatenateArrayBuffers = concatenateArrayBuffers;
13
9
  exports.concatenateTypedArrays = concatenateTypedArrays;
14
10
  exports.sliceArrayBuffer = sliceArrayBuffer;
15
11
 
16
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
17
-
18
12
  var node = _interopRequireWildcard(require("./buffer-utils"));
19
13
 
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
23
-
24
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
+ 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); }
25
15
 
26
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
-
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
+ 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; }
29
17
 
30
18
  function toArrayBuffer(data) {
31
19
  if (node.isBuffer(data)) {
@@ -45,12 +33,12 @@ function toArrayBuffer(data) {
45
33
  }
46
34
 
47
35
  if (typeof data === 'string') {
48
- var text = data;
49
- var uint8Array = new TextEncoder().encode(text);
36
+ const text = data;
37
+ const uint8Array = new TextEncoder().encode(text);
50
38
  return uint8Array.buffer;
51
39
  }
52
40
 
53
- if (data && (0, _typeof2.default)(data) === 'object' && data._toArrayBuffer) {
41
+ if (data && typeof data === 'object' && data._toArrayBuffer) {
54
42
  return data._toArrayBuffer();
55
43
  }
56
44
 
@@ -64,10 +52,10 @@ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
64
52
  return false;
65
53
  }
66
54
 
67
- var array1 = new Uint8Array(arrayBuffer1);
68
- var array2 = new Uint8Array(arrayBuffer2);
55
+ const array1 = new Uint8Array(arrayBuffer1);
56
+ const array2 = new Uint8Array(arrayBuffer2);
69
57
 
70
- for (var i = 0; i < array1.length; ++i) {
58
+ for (let i = 0; i < array1.length; ++i) {
71
59
  if (array1[i] !== array2[i]) {
72
60
  return false;
73
61
  }
@@ -76,58 +64,33 @@ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
76
64
  return true;
77
65
  }
78
66
 
79
- function concatenateArrayBuffers() {
80
- for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
81
- sources[_key] = arguments[_key];
82
- }
67
+ function concatenateArrayBuffers(...sources) {
68
+ const sourceArrays = sources.map(source2 => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
69
+ const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
70
+ const result = new Uint8Array(byteLength);
71
+ let offset = 0;
83
72
 
84
- var sourceArrays = sources.map(function (source2) {
85
- return source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2;
86
- });
87
- var byteLength = sourceArrays.reduce(function (length, typedArray) {
88
- return length + typedArray.byteLength;
89
- }, 0);
90
- var result = new Uint8Array(byteLength);
91
- var offset = 0;
92
-
93
- var _iterator = _createForOfIteratorHelper(sourceArrays),
94
- _step;
95
-
96
- try {
97
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
98
- var sourceArray = _step.value;
99
- result.set(sourceArray, offset);
100
- offset += sourceArray.byteLength;
101
- }
102
- } catch (err) {
103
- _iterator.e(err);
104
- } finally {
105
- _iterator.f();
73
+ for (const sourceArray of sourceArrays) {
74
+ result.set(sourceArray, offset);
75
+ offset += sourceArray.byteLength;
106
76
  }
107
77
 
108
78
  return result.buffer;
109
79
  }
110
80
 
111
- function concatenateTypedArrays() {
112
- for (var _len2 = arguments.length, typedArrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
113
- typedArrays[_key2] = arguments[_key2];
114
- }
115
-
116
- var arrays = typedArrays;
117
- var TypedArrayConstructor = arrays && arrays.length > 1 && arrays[0].constructor || null;
81
+ function concatenateTypedArrays(...typedArrays) {
82
+ const arrays = typedArrays;
83
+ const TypedArrayConstructor = arrays && arrays.length > 1 && arrays[0].constructor || null;
118
84
 
119
85
  if (!TypedArrayConstructor) {
120
86
  throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');
121
87
  }
122
88
 
123
- var sumLength = arrays.reduce(function (acc, value) {
124
- return acc + value.length;
125
- }, 0);
126
- var result = new TypedArrayConstructor(sumLength);
127
- var offset = 0;
89
+ const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);
90
+ const result = new TypedArrayConstructor(sumLength);
91
+ let offset = 0;
128
92
 
129
- for (var _i = 0, _arrays = arrays; _i < _arrays.length; _i++) {
130
- var array = _arrays[_i];
93
+ for (const array of arrays) {
131
94
  result.set(array, offset);
132
95
  offset += array.length;
133
96
  }
@@ -136,8 +99,8 @@ function concatenateTypedArrays() {
136
99
  }
137
100
 
138
101
  function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) {
139
- var subArray = byteLength !== undefined ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
140
- var arrayCopy = new Uint8Array(subArray);
102
+ const subArray = byteLength !== undefined ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
103
+ const arrayCopy = new Uint8Array(subArray);
141
104
  return arrayCopy.buffer;
142
105
  }
143
106
  //# sourceMappingURL=array-buffer-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","node","isBuffer","bufferToArrayBuffer","ArrayBuffer","isView","byteOffset","byteLength","buffer","slice","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error","compareArrayBuffers","arrayBuffer1","arrayBuffer2","array1","Uint8Array","array2","i","length","concatenateArrayBuffers","sources","sourceArrays","map","source2","reduce","typedArray","result","offset","sourceArray","set","concatenateTypedArrays","typedArrays","arrays","TypedArrayConstructor","constructor","sumLength","acc","value","array","sliceArrayBuffer","arrayBuffer","subArray","undefined","subarray","arrayCopy"],"mappings":";;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;AAKO,SAASA,aAAT,CAAuBC,IAAvB,EAA+C;AAEpD,MAAIC,IAAI,CAACC,QAAL,CAAcF,IAAd,CAAJ,EAAyB;AAEvBA,IAAAA,IAAI,GAAGC,IAAI,CAACE,mBAAL,CAAyBH,IAAzB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYI,WAApB,EAAiC;AAC/B,WAAOJ,IAAP;AACD;;AAGD,MAAII,WAAW,CAACC,MAAZ,CAAmBL,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACM,UAAL,KAAoB,CAApB,IAAyBN,IAAI,CAACO,UAAL,KAAoBP,IAAI,CAACQ,MAAL,CAAYD,UAA7D,E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,SAA1B,CAAf;AACA,MAAIR,MAAM,GAAG,CAAb;;AACA,6BAAoBK,MAApB,6BAA4B;AAAvB,QAAMM,KAAK,cAAX;AACHZ,IAAAA,MAAM,CAACG,GAAP,CAAWS,KAAX,EAAkBX,MAAlB;AACAA,IAAAA,MAAM,IAAIW,KAAK,CAACpB,MAAhB;AACD;;AACD,SAAOQ,MAAP;AACD;;AAQM,SAASa,gBAAT,CACLC,WADK,EAELvC,UAFK,EAGLC,UAHK,EAIQ;AACb,MAAMuC,QAAQ,GACZvC,UAAU,KAAKwC,SAAf,GACI,IAAI3B,UAAJ,CAAeyB,WAAf,EAA4BG,QAA5B,CAAqC1C,UAArC,EAAiDA,UAAU,GAAGC,UAA9D,CADJ,GAEI,IAAIa,UAAJ,CAAeyB,WAAf,EAA4BG,QAA5B,CAAqC1C,UAArC,CAHN;AAIA,MAAM2C,SAAS,GAAG,IAAI7B,UAAJ,CAAe0B,QAAf,CAAlB;AACA,SAAOG,SAAS,CAACzC,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport * as node from './buffer-utils';\n\n/**\n * Convert an object to an array buffer\n */\nexport function toArrayBuffer(data: any): ArrayBuffer {\n // Note: Should be called first, Buffers can trigger other detections below\n if (node.isBuffer(data)) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n data = node.bufferToArrayBuffer(data);\n }\n\n if (data instanceof ArrayBuffer) {\n return data;\n }\n\n // Careful - Node Buffers look like Uint8Arrays (keep after isBuffer)\n if (ArrayBuffer.isView(data)) {\n if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {\n return data.buffer;\n }\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);\n }\n\n if (typeof data === 'string') {\n const text = data;\n const uint8Array = new TextEncoder().encode(text);\n return uint8Array.buffer;\n }\n\n // HACK to support Blob polyfill\n if (data && typeof data === 'object' && data._toArrayBuffer) {\n return data._toArrayBuffer();\n }\n\n throw new Error('toArrayBuffer');\n}\n\n/**\n * compare two binary arrays for equality\n * @param {ArrayBuffer} a\n * @param {ArrayBuffer} b\n * @param {number} byteLength\n */\nexport function compareArrayBuffers(\n arrayBuffer1: ArrayBuffer,\n arrayBuffer2: ArrayBuffer,\n byteLength?: number\n): boolean {\n byteLength = byteLength || arrayBuffer1.byteLength;\n if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {\n return false;\n }\n const array1 = new Uint8Array(arrayBuffer1);\n const array2 = new Uint8Array(arrayBuffer2);\n for (let i = 0; i < array1.length; ++i) {\n if (array1[i] !== array2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Concatenate a sequence of ArrayBuffers\n * @return A concatenated ArrayBuffer\n */\nexport function concatenateArrayBuffers(...sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer {\n // Make sure all inputs are wrapped in typed arrays\n const sourceArrays = sources.map((source2) =>\n source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2\n );\n\n // Get length of all inputs\n const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);\n\n // Allocate array with space for all inputs\n const result = new Uint8Array(byteLength);\n\n // Copy the subarrays\n let offset = 0;\n for (const sourceArray of sourceArrays) {\n result.set(sourceArray, offset);\n offset += sourceArray.byteLength;\n }\n\n // We work with ArrayBuffers, discard the typed array wrapper\n return result.buffer;\n}\n\n/**\n * Concatenate arbitrary count of typed arrays\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\n * @param {...*} arrays - list of arrays. All arrays should be the same type\n * @return A concatenated TypedArray\n */\nexport function concatenateTypedArrays<T>(...typedArrays: T[]): T {\n // @ts-ignore\n const arrays = typedArrays as TypedArray[];\n // @ts-ignore\n const TypedArrayConstructor = (arrays && arrays.length > 1 && arrays[0].constructor) || null;\n if (!TypedArrayConstructor) {\n throw new Error(\n '\"concatenateTypedArrays\" - incorrect quantity of arguments or arguments have incompatible data types'\n );\n }\n\n const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);\n // @ts-ignore typescript does not like dynamic constructors\n const result = new TypedArrayConstructor(sumLength);\n let offset = 0;\n for (const array of arrays) {\n result.set(array, offset);\n offset += array.length;\n }\n return result;\n}\n\n/**\n * Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0\n * @param arrayBuffer\n * @param byteOffset\n * @param byteLength\n */\nexport function sliceArrayBuffer(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n byteLength?: number\n): ArrayBuffer {\n const subArray =\n byteLength !== undefined\n ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength)\n : new Uint8Array(arrayBuffer).subarray(byteOffset);\n const arrayCopy = new Uint8Array(subArray);\n return arrayCopy.buffer;\n}\n"],"file":"array-buffer-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","node","isBuffer","bufferToArrayBuffer","ArrayBuffer","isView","byteOffset","byteLength","buffer","slice","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error","compareArrayBuffers","arrayBuffer1","arrayBuffer2","array1","Uint8Array","array2","i","length","concatenateArrayBuffers","sources","sourceArrays","map","source2","reduce","typedArray","result","offset","sourceArray","set","concatenateTypedArrays","typedArrays","arrays","TypedArrayConstructor","constructor","sumLength","acc","value","array","sliceArrayBuffer","arrayBuffer","subArray","undefined","subarray","arrayCopy"],"mappings":";;;;;;;;;;;AACA;;;;;;AAKO,SAASA,aAAT,CAAuBC,IAAvB,EAA+C;AAEpD,MAAIC,IAAI,CAACC,QAAL,CAAcF,IAAd,CAAJ,EAAyB;AAEvBA,IAAAA,IAAI,GAAGC,IAAI,CAACE,mBAAL,CAAyBH,IAAzB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYI,WAApB,EAAiC;AAC/B,WAAOJ,IAAP;AACD;;AAGD,MAAII,WAAW,CAACC,MAAZ,CAAmBL,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACM,UAAL,KAAoB,CAApB,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AACG,GAAP,CAAWS,KAAX,EAAkBX,MAAlB;AACAA,IAAAA,MAAM,IAAIW,KAAK,CAACpB,MAAhB;AACD;;AACD,SAAOQ,MAAP;AACD;;AAQM,SAASa,gBAAT,CACLC,WADK,EAELvC,UAFK,EAGLC,UAHK,EAIQ;AACb,QAAMuC,QAAQ,GACZvC,UAAU,KAAKwC,SAAf,GACI,IAAI3B,UAAJ,CAAeyB,WAAf,EAA4BG,QAA5B,CAAqC1C,UAArC,EAAiDA,UAAU,GAAGC,UAA9D,CADJ,GAEI,IAAIa,UAAJ,CAAeyB,WAAf,EAA4BG,QAA5B,CAAqC1C,UAArC,CAHN;AAIA,QAAM2C,SAAS,GAAG,IAAI7B,UAAJ,CAAe0B,QAAf,CAAlB;AACA,SAAOG,SAAS,CAACzC,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport * as node from './buffer-utils';\n\n/**\n * Convert an object to an array buffer\n */\nexport function toArrayBuffer(data: any): ArrayBuffer {\n // Note: Should be called first, Buffers can trigger other detections below\n if (node.isBuffer(data)) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n data = node.bufferToArrayBuffer(data);\n }\n\n if (data instanceof ArrayBuffer) {\n return data;\n }\n\n // Careful - Node Buffers look like Uint8Arrays (keep after isBuffer)\n if (ArrayBuffer.isView(data)) {\n if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {\n return data.buffer;\n }\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);\n }\n\n if (typeof data === 'string') {\n const text = data;\n const uint8Array = new TextEncoder().encode(text);\n return uint8Array.buffer;\n }\n\n // HACK to support Blob polyfill\n if (data && typeof data === 'object' && data._toArrayBuffer) {\n return data._toArrayBuffer();\n }\n\n throw new Error('toArrayBuffer');\n}\n\n/**\n * compare two binary arrays for equality\n * @param {ArrayBuffer} a\n * @param {ArrayBuffer} b\n * @param {number} byteLength\n */\nexport function compareArrayBuffers(\n arrayBuffer1: ArrayBuffer,\n arrayBuffer2: ArrayBuffer,\n byteLength?: number\n): boolean {\n byteLength = byteLength || arrayBuffer1.byteLength;\n if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {\n return false;\n }\n const array1 = new Uint8Array(arrayBuffer1);\n const array2 = new Uint8Array(arrayBuffer2);\n for (let i = 0; i < array1.length; ++i) {\n if (array1[i] !== array2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Concatenate a sequence of ArrayBuffers\n * @return A concatenated ArrayBuffer\n */\nexport function concatenateArrayBuffers(...sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer {\n // Make sure all inputs are wrapped in typed arrays\n const sourceArrays = sources.map((source2) =>\n source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2\n );\n\n // Get length of all inputs\n const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);\n\n // Allocate array with space for all inputs\n const result = new Uint8Array(byteLength);\n\n // Copy the subarrays\n let offset = 0;\n for (const sourceArray of sourceArrays) {\n result.set(sourceArray, offset);\n offset += sourceArray.byteLength;\n }\n\n // We work with ArrayBuffers, discard the typed array wrapper\n return result.buffer;\n}\n\n/**\n * Concatenate arbitrary count of typed arrays\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\n * @param {...*} arrays - list of arrays. All arrays should be the same type\n * @return A concatenated TypedArray\n */\nexport function concatenateTypedArrays<T>(...typedArrays: T[]): T {\n // @ts-ignore\n const arrays = typedArrays as TypedArray[];\n // @ts-ignore\n const TypedArrayConstructor = (arrays && arrays.length > 1 && arrays[0].constructor) || null;\n if (!TypedArrayConstructor) {\n throw new Error(\n '\"concatenateTypedArrays\" - incorrect quantity of arguments or arguments have incompatible data types'\n );\n }\n\n const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);\n // @ts-ignore typescript does not like dynamic constructors\n const result = new TypedArrayConstructor(sumLength);\n let offset = 0;\n for (const array of arrays) {\n result.set(array, offset);\n offset += array.length;\n }\n return result;\n}\n\n/**\n * Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0\n * @param arrayBuffer\n * @param byteOffset\n * @param byteLength\n */\nexport function sliceArrayBuffer(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n byteLength?: number\n): ArrayBuffer {\n const subArray =\n byteLength !== undefined\n ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength)\n : new Uint8Array(arrayBuffer).subarray(byteOffset);\n const arrayCopy = new Uint8Array(subArray);\n return arrayCopy.buffer;\n}\n"],"file":"array-buffer-utils.js"}
@@ -9,15 +9,15 @@ exports.copyPaddedStringToDataView = copyPaddedStringToDataView;
9
9
  var _memoryCopyUtils = require("./memory-copy-utils");
10
10
 
11
11
  function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
12
- var paddedLength = (0, _memoryCopyUtils.padToNBytes)(sourceBuffer.byteLength, padding);
13
- var padLength = paddedLength - sourceBuffer.byteLength;
12
+ const paddedLength = (0, _memoryCopyUtils.padToNBytes)(sourceBuffer.byteLength, padding);
13
+ const padLength = paddedLength - sourceBuffer.byteLength;
14
14
 
15
15
  if (dataView) {
16
- var targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
17
- var sourceArray = new Uint8Array(sourceBuffer);
16
+ const targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
17
+ const sourceArray = new Uint8Array(sourceBuffer);
18
18
  targetArray.set(sourceArray);
19
19
 
20
- for (var i = 0; i < padLength; ++i) {
20
+ for (let i = 0; i < padLength; ++i) {
21
21
  dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 0x20);
22
22
  }
23
23
  }
@@ -27,8 +27,8 @@ function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, pad
27
27
  }
28
28
 
29
29
  function copyPaddedStringToDataView(dataView, byteOffset, string, padding) {
30
- var textEncoder = new TextEncoder();
31
- var stringBuffer = textEncoder.encode(string);
30
+ const textEncoder = new TextEncoder();
31
+ const stringBuffer = textEncoder.encode(string);
32
32
  byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
33
33
  return byteOffset;
34
34
  }