@loaders.gl/loader-utils 3.1.0-beta.4 → 3.1.0

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 (43) hide show
  1. package/dist/es5/index.js +48 -46
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/json-loader.js +33 -5
  4. package/dist/es5/json-loader.js.map +1 -1
  5. package/dist/es5/lib/binary-utils/array-buffer-utils.js +58 -23
  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 +10 -4
  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 +7 -5
  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 +7 -6
  16. package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
  17. package/dist/es5/lib/env-utils/globals.js +14 -9
  18. package/dist/es5/lib/env-utils/globals.js.map +1 -1
  19. package/dist/es5/lib/filesystems/node-filesystem.js +243 -50
  20. package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
  21. package/dist/es5/lib/iterators/async-iteration.js +242 -27
  22. package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
  23. package/dist/es5/lib/iterators/text-iterators.js +410 -35
  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 +51 -20
  28. package/dist/es5/lib/node/fs.js.map +1 -1
  29. package/dist/es5/lib/node/util.js +5 -3
  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 +9 -5
  34. package/dist/es5/lib/path-utils/path.js.map +1 -1
  35. package/dist/es5/lib/request-utils/request-scheduler.js +124 -96
  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 +132 -63
  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 +112 -51
  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/json-loader.js.map +1 -1
  43. package/package.json +3 -3
package/dist/es5/index.js CHANGED
@@ -2,270 +2,272 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  Object.defineProperty(exports, "assert", {
9
11
  enumerable: true,
10
- get: function () {
12
+ get: function get() {
11
13
  return _assert.assert;
12
14
  }
13
15
  });
14
16
  Object.defineProperty(exports, "isBrowser", {
15
17
  enumerable: true,
16
- get: function () {
18
+ get: function get() {
17
19
  return _globals.isBrowser;
18
20
  }
19
21
  });
20
22
  Object.defineProperty(exports, "isWorker", {
21
23
  enumerable: true,
22
- get: function () {
24
+ get: function get() {
23
25
  return _globals.isWorker;
24
26
  }
25
27
  });
26
28
  Object.defineProperty(exports, "nodeVersion", {
27
29
  enumerable: true,
28
- get: function () {
30
+ get: function get() {
29
31
  return _globals.nodeVersion;
30
32
  }
31
33
  });
32
34
  Object.defineProperty(exports, "self", {
33
35
  enumerable: true,
34
- get: function () {
36
+ get: function get() {
35
37
  return _globals.self;
36
38
  }
37
39
  });
38
40
  Object.defineProperty(exports, "window", {
39
41
  enumerable: true,
40
- get: function () {
42
+ get: function get() {
41
43
  return _globals.window;
42
44
  }
43
45
  });
44
46
  Object.defineProperty(exports, "global", {
45
47
  enumerable: true,
46
- get: function () {
48
+ get: function get() {
47
49
  return _globals.global;
48
50
  }
49
51
  });
50
52
  Object.defineProperty(exports, "document", {
51
53
  enumerable: true,
52
- get: function () {
54
+ get: function get() {
53
55
  return _globals.document;
54
56
  }
55
57
  });
56
58
  Object.defineProperty(exports, "createLoaderWorker", {
57
59
  enumerable: true,
58
- get: function () {
60
+ get: function get() {
59
61
  return _createLoaderWorker.createLoaderWorker;
60
62
  }
61
63
  });
62
64
  Object.defineProperty(exports, "parseWithWorker", {
63
65
  enumerable: true,
64
- get: function () {
66
+ get: function get() {
65
67
  return _parseWithWorker.parseWithWorker;
66
68
  }
67
69
  });
68
70
  Object.defineProperty(exports, "canParseWithWorker", {
69
71
  enumerable: true,
70
- get: function () {
72
+ get: function get() {
71
73
  return _parseWithWorker.canParseWithWorker;
72
74
  }
73
75
  });
74
76
  Object.defineProperty(exports, "parseJSON", {
75
77
  enumerable: true,
76
- get: function () {
78
+ get: function get() {
77
79
  return _parseJson.parseJSON;
78
80
  }
79
81
  });
80
82
  Object.defineProperty(exports, "toArrayBuffer", {
81
83
  enumerable: true,
82
- get: function () {
84
+ get: function get() {
83
85
  return _arrayBufferUtils.toArrayBuffer;
84
86
  }
85
87
  });
86
88
  Object.defineProperty(exports, "sliceArrayBuffer", {
87
89
  enumerable: true,
88
- get: function () {
90
+ get: function get() {
89
91
  return _arrayBufferUtils.sliceArrayBuffer;
90
92
  }
91
93
  });
92
94
  Object.defineProperty(exports, "concatenateArrayBuffers", {
93
95
  enumerable: true,
94
- get: function () {
96
+ get: function get() {
95
97
  return _arrayBufferUtils.concatenateArrayBuffers;
96
98
  }
97
99
  });
98
100
  Object.defineProperty(exports, "concatenateTypedArrays", {
99
101
  enumerable: true,
100
- get: function () {
102
+ get: function get() {
101
103
  return _arrayBufferUtils.concatenateTypedArrays;
102
104
  }
103
105
  });
104
106
  Object.defineProperty(exports, "compareArrayBuffers", {
105
107
  enumerable: true,
106
- get: function () {
108
+ get: function get() {
107
109
  return _arrayBufferUtils.compareArrayBuffers;
108
110
  }
109
111
  });
110
112
  Object.defineProperty(exports, "padToNBytes", {
111
113
  enumerable: true,
112
- get: function () {
114
+ get: function get() {
113
115
  return _memoryCopyUtils.padToNBytes;
114
116
  }
115
117
  });
116
118
  Object.defineProperty(exports, "copyToArray", {
117
119
  enumerable: true,
118
- get: function () {
120
+ get: function get() {
119
121
  return _memoryCopyUtils.copyToArray;
120
122
  }
121
123
  });
122
124
  Object.defineProperty(exports, "copyArrayBuffer", {
123
125
  enumerable: true,
124
- get: function () {
126
+ get: function get() {
125
127
  return _memoryCopyUtils.copyArrayBuffer;
126
128
  }
127
129
  });
128
130
  Object.defineProperty(exports, "copyPaddedArrayBufferToDataView", {
129
131
  enumerable: true,
130
- get: function () {
132
+ get: function get() {
131
133
  return _binaryCopyUtils.copyPaddedArrayBufferToDataView;
132
134
  }
133
135
  });
134
136
  Object.defineProperty(exports, "copyPaddedStringToDataView", {
135
137
  enumerable: true,
136
- get: function () {
138
+ get: function get() {
137
139
  return _binaryCopyUtils.copyPaddedStringToDataView;
138
140
  }
139
141
  });
140
142
  Object.defineProperty(exports, "padStringToByteAlignment", {
141
143
  enumerable: true,
142
- get: function () {
144
+ get: function get() {
143
145
  return _encodeUtils.padStringToByteAlignment;
144
146
  }
145
147
  });
146
148
  Object.defineProperty(exports, "copyStringToDataView", {
147
149
  enumerable: true,
148
- get: function () {
150
+ get: function get() {
149
151
  return _encodeUtils.copyStringToDataView;
150
152
  }
151
153
  });
152
154
  Object.defineProperty(exports, "copyBinaryToDataView", {
153
155
  enumerable: true,
154
- get: function () {
156
+ get: function get() {
155
157
  return _encodeUtils.copyBinaryToDataView;
156
158
  }
157
159
  });
158
160
  Object.defineProperty(exports, "getFirstCharacters", {
159
161
  enumerable: true,
160
- get: function () {
162
+ get: function get() {
161
163
  return _getFirstCharacters.getFirstCharacters;
162
164
  }
163
165
  });
164
166
  Object.defineProperty(exports, "getMagicString", {
165
167
  enumerable: true,
166
- get: function () {
168
+ get: function get() {
167
169
  return _getFirstCharacters.getMagicString;
168
170
  }
169
171
  });
170
172
  Object.defineProperty(exports, "makeTextEncoderIterator", {
171
173
  enumerable: true,
172
- get: function () {
174
+ get: function get() {
173
175
  return _textIterators.makeTextEncoderIterator;
174
176
  }
175
177
  });
176
178
  Object.defineProperty(exports, "makeTextDecoderIterator", {
177
179
  enumerable: true,
178
- get: function () {
180
+ get: function get() {
179
181
  return _textIterators.makeTextDecoderIterator;
180
182
  }
181
183
  });
182
184
  Object.defineProperty(exports, "makeLineIterator", {
183
185
  enumerable: true,
184
- get: function () {
186
+ get: function get() {
185
187
  return _textIterators.makeLineIterator;
186
188
  }
187
189
  });
188
190
  Object.defineProperty(exports, "makeNumberedLineIterator", {
189
191
  enumerable: true,
190
- get: function () {
192
+ get: function get() {
191
193
  return _textIterators.makeNumberedLineIterator;
192
194
  }
193
195
  });
194
196
  Object.defineProperty(exports, "forEach", {
195
197
  enumerable: true,
196
- get: function () {
198
+ get: function get() {
197
199
  return _asyncIteration.forEach;
198
200
  }
199
201
  });
200
202
  Object.defineProperty(exports, "concatenateArrayBuffersAsync", {
201
203
  enumerable: true,
202
- get: function () {
204
+ get: function get() {
203
205
  return _asyncIteration.concatenateArrayBuffersAsync;
204
206
  }
205
207
  });
206
208
  Object.defineProperty(exports, "RequestScheduler", {
207
209
  enumerable: true,
208
- get: function () {
210
+ get: function get() {
209
211
  return _requestScheduler.default;
210
212
  }
211
213
  });
212
214
  Object.defineProperty(exports, "setPathPrefix", {
213
215
  enumerable: true,
214
- get: function () {
216
+ get: function get() {
215
217
  return _fileAliases.setPathPrefix;
216
218
  }
217
219
  });
218
220
  Object.defineProperty(exports, "getPathPrefix", {
219
221
  enumerable: true,
220
- get: function () {
222
+ get: function get() {
221
223
  return _fileAliases.getPathPrefix;
222
224
  }
223
225
  });
224
226
  Object.defineProperty(exports, "resolvePath", {
225
227
  enumerable: true,
226
- get: function () {
228
+ get: function get() {
227
229
  return _fileAliases.resolvePath;
228
230
  }
229
231
  });
230
232
  Object.defineProperty(exports, "_addAliases", {
231
233
  enumerable: true,
232
- get: function () {
234
+ get: function get() {
233
235
  return _fileAliases.addAliases;
234
236
  }
235
237
  });
236
238
  Object.defineProperty(exports, "JSONLoader", {
237
239
  enumerable: true,
238
- get: function () {
240
+ get: function get() {
239
241
  return _jsonLoader.JSONLoader;
240
242
  }
241
243
  });
242
244
  Object.defineProperty(exports, "isBuffer", {
243
245
  enumerable: true,
244
- get: function () {
246
+ get: function get() {
245
247
  return _bufferUtils.isBuffer;
246
248
  }
247
249
  });
248
250
  Object.defineProperty(exports, "toBuffer", {
249
251
  enumerable: true,
250
- get: function () {
252
+ get: function get() {
251
253
  return _bufferUtils.toBuffer;
252
254
  }
253
255
  });
254
256
  Object.defineProperty(exports, "bufferToArrayBuffer", {
255
257
  enumerable: true,
256
- get: function () {
258
+ get: function get() {
257
259
  return _bufferUtils.bufferToArrayBuffer;
258
260
  }
259
261
  });
260
262
  Object.defineProperty(exports, "promisify", {
261
263
  enumerable: true,
262
- get: function () {
264
+ get: function get() {
263
265
  return util.promisify;
264
266
  }
265
267
  });
266
268
  Object.defineProperty(exports, "_NodeFileSystem", {
267
269
  enumerable: true,
268
- get: function () {
270
+ get: function get() {
269
271
  return _nodeFilesystem.default;
270
272
  }
271
273
  });
@@ -317,7 +319,7 @@ exports.fs = fs;
317
319
 
318
320
  var _nodeFilesystem = _interopRequireDefault(require("./lib/filesystems/node-filesystem"));
319
321
 
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); }
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); }
321
323
 
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; }
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; }
323
325
  //# 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,11 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports._typecheckJSONLoader = exports.JSONLoader = void 0;
7
- const VERSION = typeof "3.1.0-beta.4" !== 'undefined' ? "3.1.0-beta.4" : 'latest';
8
- const JSONLoader = {
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.1.0" !== 'undefined' ? "3.1.0" : 'latest';
15
+ var JSONLoader = {
9
16
  name: 'JSON',
10
17
  id: 'json',
11
18
  module: 'json',
@@ -14,8 +21,29 @@ const JSONLoader = {
14
21
  mimeTypes: ['application/json'],
15
22
  category: 'json',
16
23
  text: true,
17
- parseTextSync,
18
- parse: async arrayBuffer => parseTextSync(new TextDecoder().decode(arrayBuffer)),
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
+ }(),
19
47
  options: {}
20
48
  };
21
49
  exports.JSONLoader = JSONLoader;
@@ -24,6 +52,6 @@ function parseTextSync(text) {
24
52
  return JSON.parse(text);
25
53
  }
26
54
 
27
- const _typecheckJSONLoader = JSONLoader;
55
+ var _typecheckJSONLoader = JSONLoader;
28
56
  exports._typecheckJSONLoader = _typecheckJSONLoader;
29
57
  //# 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,MAAMA,OAAO,GAAG,0BAAuB,WAAvB,oBAAmD,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
+ {"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,mBAAuB,WAAvB,aAAmD,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,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -9,8 +11,16 @@ exports.concatenateArrayBuffers = concatenateArrayBuffers;
9
11
  exports.concatenateTypedArrays = concatenateTypedArrays;
10
12
  exports.sliceArrayBuffer = sliceArrayBuffer;
11
13
 
14
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
+
12
16
  var _bufferUtils = require("./buffer-utils");
13
17
 
18
+ 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; } } }; }
19
+
20
+ 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); }
21
+
22
+ 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; }
23
+
14
24
  function toArrayBuffer(data) {
15
25
  if ((0, _bufferUtils.isBuffer)(data)) {
16
26
  return (0, _bufferUtils.bufferToArrayBuffer)(data);
@@ -29,12 +39,12 @@ function toArrayBuffer(data) {
29
39
  }
30
40
 
31
41
  if (typeof data === 'string') {
32
- const text = data;
33
- const uint8Array = new TextEncoder().encode(text);
42
+ var text = data;
43
+ var uint8Array = new TextEncoder().encode(text);
34
44
  return uint8Array.buffer;
35
45
  }
36
46
 
37
- if (data && typeof data === 'object' && data._toArrayBuffer) {
47
+ if (data && (0, _typeof2.default)(data) === 'object' && data._toArrayBuffer) {
38
48
  return data._toArrayBuffer();
39
49
  }
40
50
 
@@ -48,10 +58,10 @@ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
48
58
  return false;
49
59
  }
50
60
 
51
- const array1 = new Uint8Array(arrayBuffer1);
52
- const array2 = new Uint8Array(arrayBuffer2);
61
+ var array1 = new Uint8Array(arrayBuffer1);
62
+ var array2 = new Uint8Array(arrayBuffer2);
53
63
 
54
- for (let i = 0; i < array1.length; ++i) {
64
+ for (var i = 0; i < array1.length; ++i) {
55
65
  if (array1[i] !== array2[i]) {
56
66
  return false;
57
67
  }
@@ -60,33 +70,58 @@ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
60
70
  return true;
61
71
  }
62
72
 
63
- function concatenateArrayBuffers(...sources) {
64
- const sourceArrays = sources.map(source2 => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
65
- const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
66
- const result = new Uint8Array(byteLength);
67
- let offset = 0;
73
+ function concatenateArrayBuffers() {
74
+ for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
75
+ sources[_key] = arguments[_key];
76
+ }
68
77
 
69
- for (const sourceArray of sourceArrays) {
70
- result.set(sourceArray, offset);
71
- offset += sourceArray.byteLength;
78
+ var sourceArrays = sources.map(function (source2) {
79
+ return source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2;
80
+ });
81
+ var byteLength = sourceArrays.reduce(function (length, typedArray) {
82
+ return length + typedArray.byteLength;
83
+ }, 0);
84
+ var result = new Uint8Array(byteLength);
85
+ var offset = 0;
86
+
87
+ var _iterator = _createForOfIteratorHelper(sourceArrays),
88
+ _step;
89
+
90
+ try {
91
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
92
+ var sourceArray = _step.value;
93
+ result.set(sourceArray, offset);
94
+ offset += sourceArray.byteLength;
95
+ }
96
+ } catch (err) {
97
+ _iterator.e(err);
98
+ } finally {
99
+ _iterator.f();
72
100
  }
73
101
 
74
102
  return result.buffer;
75
103
  }
76
104
 
77
- function concatenateTypedArrays(...typedArrays) {
78
- const arrays = typedArrays;
79
- const TypedArrayConstructor = arrays && arrays.length > 1 && arrays[0].constructor || null;
105
+ function concatenateTypedArrays() {
106
+ for (var _len2 = arguments.length, typedArrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
107
+ typedArrays[_key2] = arguments[_key2];
108
+ }
109
+
110
+ var arrays = typedArrays;
111
+ var TypedArrayConstructor = arrays && arrays.length > 1 && arrays[0].constructor || null;
80
112
 
81
113
  if (!TypedArrayConstructor) {
82
114
  throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');
83
115
  }
84
116
 
85
- const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);
86
- const result = new TypedArrayConstructor(sumLength);
87
- let offset = 0;
117
+ var sumLength = arrays.reduce(function (acc, value) {
118
+ return acc + value.length;
119
+ }, 0);
120
+ var result = new TypedArrayConstructor(sumLength);
121
+ var offset = 0;
88
122
 
89
- for (const array of arrays) {
123
+ for (var _i = 0, _arrays = arrays; _i < _arrays.length; _i++) {
124
+ var array = _arrays[_i];
90
125
  result.set(array, offset);
91
126
  offset += array.length;
92
127
  }
@@ -95,8 +130,8 @@ function concatenateTypedArrays(...typedArrays) {
95
130
  }
96
131
 
97
132
  function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) {
98
- const subArray = byteLength !== undefined ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
99
- const arrayCopy = new Uint8Array(subArray);
133
+ var subArray = byteLength !== undefined ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
134
+ var arrayCopy = new Uint8Array(subArray);
100
135
  return arrayCopy.buffer;
101
136
  }
102
137
  //# sourceMappingURL=array-buffer-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","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,MAAI,2BAASA,IAAT,CAAJ,EAAoB;AAClB,WAAO,sCAAoBA,IAApB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYC,WAApB,EAAiC;AAC/B,WAAOD,IAAP;AACD;;AAGD,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACG,UAAL,KAAoB,CAApB,IAAyBH,IAAI,CAACI,UAAL,KAAoBJ,IAAI,CAACK,MAAL,CAAYD,UAA7D,EAAyE;AACvE,aAAOJ,IAAI,CAACK,MAAZ;AACD;;AACD,WAAOL,IAAI,CAACK,MAAL,CAAYC,KAAZ,CAAkBN,IAAI,CAACG,UAAvB,EAAmCH,IAAI,CAACG,UAAL,GAAkBH,IAAI,CAACI,UAA1D,CAAP;AACD;;AAED,MAAI,OAAOJ,IAAP,KAAgB,QAApB,EAA8B;AAC5B,UAAMO,IAAI,GAAGP,IAAb;AACA,UAAMQ,UAAU,GAAG,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBH,IAAzB,CAAnB;AACA,WAAOC,UAAU,CAACH,MAAlB;AACD;;AAGD,MAAIL,IAAI,IAAI,OAAOA,I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AS,CAACzC,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport {isBuffer, bufferToArrayBuffer} 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 (isBuffer(data)) {\n return 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","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,MAAI,2BAASA,IAAT,CAAJ,EAAoB;AAClB,WAAO,sCAAoBA,IAApB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYC,WAApB,EAAiC;AAC/B,WAAOD,IAAP;AACD;;AAGD,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACG,UAAL,KAAoB,CAApB,IAAyBH,IAAI,CAACI,UAAL,KAAoBJ,IAAI,CAACK,MAAL,CAAYD,UAA7D,EAAyE;AACvE,aAAOJ,IAAI,CAACK,MAAZ;AACD;;AACD,WAAOL,IAAI,CAACK,MAAL,CAAYC,KAAZ,CAAkBN,IAAI,CAACG,UAAvB,EAAmCH,IAAI,CAACG,UAAL,GAAkBH,IAAI,CAACI,UAA1D,CAAP;AACD;;AAED,MAAI,OAAOJ,IAAP,KAAgB,QAApB,EAA8B;AAC5B,QAAMO,IAAI,GAAGP,IAAb;AACA,QAAMQ,UAAU,GAAG,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBH,IAAzB,CAAnB;AACA,WAAOC,UAAU,CAACH,MAAlB;AACD;;AAGD,MAAIL,IAAI,IAAI,sBAAOA,IAAP,MAAgB,QAAxB,IAAoCA,IAAI,CAACW,cAA7C,EAA6D;AAC3D,WAAOX,IAAI,CAACW,cAAL,EAAP;AACD;;AAED,QAAM,IAAIC,KAAJ,CAAU,eAAV,CAAN;AACD;;AAQM,SAASC,mBAAT,CACLC,YADK,EAELC,YAFK,EAGLX,UAHK,EAII;AACTA,E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ourcesContent":["import {TypedArray} from '../../types';\nimport {isBuffer, bufferToArrayBuffer} 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 (isBuffer(data)) {\n return 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
- const paddedLength = (0, _memoryCopyUtils.padToNBytes)(sourceBuffer.byteLength, padding);
13
- const padLength = paddedLength - sourceBuffer.byteLength;
12
+ var paddedLength = (0, _memoryCopyUtils.padToNBytes)(sourceBuffer.byteLength, padding);
13
+ var padLength = paddedLength - sourceBuffer.byteLength;
14
14
 
15
15
  if (dataView) {
16
- const targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
17
- const sourceArray = new Uint8Array(sourceBuffer);
16
+ var targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
17
+ var sourceArray = new Uint8Array(sourceBuffer);
18
18
  targetArray.set(sourceArray);
19
19
 
20
- for (let i = 0; i < padLength; ++i) {
20
+ for (var 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
- const textEncoder = new TextEncoder();
31
- const stringBuffer = textEncoder.encode(string);
30
+ var textEncoder = new TextEncoder();
31
+ var stringBuffer = textEncoder.encode(string);
32
32
  byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
33
33
  return byteOffset;
34
34
  }