@loaders.gl/loader-utils 4.0.0-alpha.23 → 4.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/json-loader.js +1 -1
- package/dist/es5/lib/node/fs.browser.js +9 -0
- package/dist/es5/lib/node/fs.browser.js.map +1 -0
- package/dist/es5/lib/node/fs.js +19 -35
- package/dist/es5/lib/node/fs.js.map +1 -1
- package/dist/es5/lib/node/stream.browser.js +9 -0
- package/dist/es5/lib/node/stream.browser.js.map +1 -0
- package/dist/es5/lib/node/stream.js +1 -4
- package/dist/es5/lib/node/stream.js.map +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/lib/node/fs.browser.js +2 -0
- package/dist/esm/lib/node/fs.browser.js.map +1 -0
- package/dist/esm/lib/node/fs.js +14 -30
- package/dist/esm/lib/node/fs.js.map +1 -1
- package/dist/esm/lib/node/stream.browser.js +2 -0
- package/dist/esm/lib/node/stream.browser.js.map +1 -0
- package/dist/esm/lib/node/stream.js +1 -4
- package/dist/esm/lib/node/stream.js.map +1 -1
- package/dist/lib/node/fs.browser.d.ts +2 -0
- package/dist/lib/node/fs.browser.d.ts.map +1 -0
- package/dist/lib/node/fs.d.ts +16 -14
- package/dist/lib/node/fs.d.ts.map +1 -1
- package/dist/lib/node/stream.browser.d.ts +2 -0
- package/dist/lib/node/stream.browser.d.ts.map +1 -0
- package/dist/lib/node/stream.d.ts +4 -1
- package/dist/lib/node/stream.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/lib/node/fs.browser.ts +1 -0
- package/src/lib/node/fs.ts +16 -53
- package/src/lib/node/stream.browser.ts +1 -0
- package/src/lib/node/stream.ts +2 -10
- package/dist/index.js +0 -135
- package/dist/json-loader.js +0 -27
- package/dist/lib/binary-utils/array-buffer-utils.js +0 -84
- package/dist/lib/binary-utils/dataview-copy-utils.js +0 -97
- package/dist/lib/binary-utils/get-first-characters.js +0 -45
- package/dist/lib/binary-utils/memory-conversion-utils.js +0 -73
- package/dist/lib/binary-utils/memory-copy-utils.js +0 -61
- package/dist/lib/env-utils/assert.js +0 -13
- package/dist/lib/env-utils/globals.js +0 -30
- package/dist/lib/file-provider/data-view-file.js +0 -63
- package/dist/lib/file-provider/file-handle-file.js +0 -92
- package/dist/lib/file-provider/file-handle.js +0 -55
- package/dist/lib/file-provider/file-provider.js +0 -13
- package/dist/lib/filesystems/filesystem.js +0 -37
- package/dist/lib/filesystems/node-filesystem.js +0 -74
- package/dist/lib/filesystems/readable-file.js +0 -25
- package/dist/lib/filesystems/writable-file.js +0 -48
- package/dist/lib/iterators/async-iteration.js +0 -53
- package/dist/lib/iterators/text-iterators.js +0 -61
- package/dist/lib/node/buffer.browser.js +0 -22
- package/dist/lib/node/buffer.js +0 -36
- package/dist/lib/node/fs.js +0 -51
- package/dist/lib/node/promisify.js +0 -22
- package/dist/lib/node/stream.js +0 -17
- package/dist/lib/option-utils/merge-loader-options.js +0 -27
- package/dist/lib/parser-utils/parse-json.js +0 -16
- package/dist/lib/path-utils/file-aliases.js +0 -47
- package/dist/lib/path-utils/get-cwd.js +0 -12
- package/dist/lib/path-utils/path.js +0 -178
- package/dist/lib/request-utils/request-scheduler.js +0 -142
- package/dist/lib/worker-loader-utils/create-loader-worker.js +0 -99
- package/dist/lib/worker-loader-utils/encode-with-worker.js +0 -21
- package/dist/lib/worker-loader-utils/parse-with-worker.js +0 -81
- package/dist/loader-types.js +0 -36
- package/dist/types.js +0 -3
- package/dist/workers/json-worker.js +0 -5
- package/dist/writer-types.js +0 -3
package/dist/index.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.fs = exports.path = exports.promisify2 = exports.promisify1 = exports.toArrayBuffer = exports.toBuffer = exports.isBuffer = exports.JSONLoader = exports._addAliases = exports.resolvePath = exports.getPathPrefix = exports.setPathPrefix = exports.RequestScheduler = exports.concatenateArrayBuffersAsync = exports.forEach = exports.makeNumberedLineIterator = exports.makeLineIterator = exports.makeTextDecoderIterator = exports.makeTextEncoderIterator = exports.getMagicString = exports.getFirstCharacters = exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView = exports.copyBinaryToDataView = exports.copyStringToDataView = exports.padStringToByteAlignment = exports.copyArrayBuffer = exports.copyToArray = exports.padToNBytes = exports.compareArrayBuffers = exports.concatenateTypedArrays = exports.concatenateArrayBuffers = exports.sliceArrayBuffer = exports.parseJSON = exports.canEncodeWithWorker = exports.canParseWithWorker = exports.parseWithWorker = exports.createLoaderWorker = exports.mergeLoaderOptions = exports.document = exports.global = exports.window = exports.self = exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.assert = exports.parseInBatchesFromContext = exports.parseSyncFromContext = exports.parseFromContext = void 0;
|
|
31
|
-
exports.makeWritableFile = exports.makeReadableFile = exports.DataViewFile = exports.FileHandleFile = exports.FileHandle = exports.isFileProvider = exports._NodeFileSystem = exports.stream = void 0;
|
|
32
|
-
var loader_types_1 = require("./loader-types");
|
|
33
|
-
Object.defineProperty(exports, "parseFromContext", { enumerable: true, get: function () { return loader_types_1.parseFromContext; } });
|
|
34
|
-
Object.defineProperty(exports, "parseSyncFromContext", { enumerable: true, get: function () { return loader_types_1.parseSyncFromContext; } });
|
|
35
|
-
Object.defineProperty(exports, "parseInBatchesFromContext", { enumerable: true, get: function () { return loader_types_1.parseInBatchesFromContext; } });
|
|
36
|
-
// GENERAL UTILS
|
|
37
|
-
var assert_1 = require("./lib/env-utils/assert");
|
|
38
|
-
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_1.assert; } });
|
|
39
|
-
var globals_1 = require("./lib/env-utils/globals");
|
|
40
|
-
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return globals_1.isBrowser; } });
|
|
41
|
-
Object.defineProperty(exports, "isWorker", { enumerable: true, get: function () { return globals_1.isWorker; } });
|
|
42
|
-
Object.defineProperty(exports, "nodeVersion", { enumerable: true, get: function () { return globals_1.nodeVersion; } });
|
|
43
|
-
Object.defineProperty(exports, "self", { enumerable: true, get: function () { return globals_1.self; } });
|
|
44
|
-
Object.defineProperty(exports, "window", { enumerable: true, get: function () { return globals_1.window; } });
|
|
45
|
-
Object.defineProperty(exports, "global", { enumerable: true, get: function () { return globals_1.global; } });
|
|
46
|
-
Object.defineProperty(exports, "document", { enumerable: true, get: function () { return globals_1.document; } });
|
|
47
|
-
var merge_loader_options_1 = require("./lib/option-utils/merge-loader-options");
|
|
48
|
-
Object.defineProperty(exports, "mergeLoaderOptions", { enumerable: true, get: function () { return merge_loader_options_1.mergeLoaderOptions; } });
|
|
49
|
-
// LOADERS.GL-SPECIFIC WORKER UTILS
|
|
50
|
-
var create_loader_worker_1 = require("./lib/worker-loader-utils/create-loader-worker");
|
|
51
|
-
Object.defineProperty(exports, "createLoaderWorker", { enumerable: true, get: function () { return create_loader_worker_1.createLoaderWorker; } });
|
|
52
|
-
var parse_with_worker_1 = require("./lib/worker-loader-utils/parse-with-worker");
|
|
53
|
-
Object.defineProperty(exports, "parseWithWorker", { enumerable: true, get: function () { return parse_with_worker_1.parseWithWorker; } });
|
|
54
|
-
Object.defineProperty(exports, "canParseWithWorker", { enumerable: true, get: function () { return parse_with_worker_1.canParseWithWorker; } });
|
|
55
|
-
var encode_with_worker_1 = require("./lib/worker-loader-utils/encode-with-worker");
|
|
56
|
-
Object.defineProperty(exports, "canEncodeWithWorker", { enumerable: true, get: function () { return encode_with_worker_1.canEncodeWithWorker; } });
|
|
57
|
-
// PARSER UTILS
|
|
58
|
-
var parse_json_1 = require("./lib/parser-utils/parse-json");
|
|
59
|
-
Object.defineProperty(exports, "parseJSON", { enumerable: true, get: function () { return parse_json_1.parseJSON; } });
|
|
60
|
-
// MEMORY COPY UTILS
|
|
61
|
-
var array_buffer_utils_1 = require("./lib/binary-utils/array-buffer-utils");
|
|
62
|
-
Object.defineProperty(exports, "sliceArrayBuffer", { enumerable: true, get: function () { return array_buffer_utils_1.sliceArrayBuffer; } });
|
|
63
|
-
Object.defineProperty(exports, "concatenateArrayBuffers", { enumerable: true, get: function () { return array_buffer_utils_1.concatenateArrayBuffers; } });
|
|
64
|
-
Object.defineProperty(exports, "concatenateTypedArrays", { enumerable: true, get: function () { return array_buffer_utils_1.concatenateTypedArrays; } });
|
|
65
|
-
Object.defineProperty(exports, "compareArrayBuffers", { enumerable: true, get: function () { return array_buffer_utils_1.compareArrayBuffers; } });
|
|
66
|
-
var memory_copy_utils_1 = require("./lib/binary-utils/memory-copy-utils");
|
|
67
|
-
Object.defineProperty(exports, "padToNBytes", { enumerable: true, get: function () { return memory_copy_utils_1.padToNBytes; } });
|
|
68
|
-
Object.defineProperty(exports, "copyToArray", { enumerable: true, get: function () { return memory_copy_utils_1.copyToArray; } });
|
|
69
|
-
Object.defineProperty(exports, "copyArrayBuffer", { enumerable: true, get: function () { return memory_copy_utils_1.copyArrayBuffer; } });
|
|
70
|
-
var dataview_copy_utils_1 = require("./lib/binary-utils/dataview-copy-utils");
|
|
71
|
-
Object.defineProperty(exports, "padStringToByteAlignment", { enumerable: true, get: function () { return dataview_copy_utils_1.padStringToByteAlignment; } });
|
|
72
|
-
Object.defineProperty(exports, "copyStringToDataView", { enumerable: true, get: function () { return dataview_copy_utils_1.copyStringToDataView; } });
|
|
73
|
-
Object.defineProperty(exports, "copyBinaryToDataView", { enumerable: true, get: function () { return dataview_copy_utils_1.copyBinaryToDataView; } });
|
|
74
|
-
Object.defineProperty(exports, "copyPaddedArrayBufferToDataView", { enumerable: true, get: function () { return dataview_copy_utils_1.copyPaddedArrayBufferToDataView; } });
|
|
75
|
-
Object.defineProperty(exports, "copyPaddedStringToDataView", { enumerable: true, get: function () { return dataview_copy_utils_1.copyPaddedStringToDataView; } });
|
|
76
|
-
var get_first_characters_1 = require("./lib/binary-utils/get-first-characters");
|
|
77
|
-
Object.defineProperty(exports, "getFirstCharacters", { enumerable: true, get: function () { return get_first_characters_1.getFirstCharacters; } });
|
|
78
|
-
Object.defineProperty(exports, "getMagicString", { enumerable: true, get: function () { return get_first_characters_1.getMagicString; } });
|
|
79
|
-
// ITERATOR UTILS
|
|
80
|
-
var text_iterators_1 = require("./lib/iterators/text-iterators");
|
|
81
|
-
Object.defineProperty(exports, "makeTextEncoderIterator", { enumerable: true, get: function () { return text_iterators_1.makeTextEncoderIterator; } });
|
|
82
|
-
Object.defineProperty(exports, "makeTextDecoderIterator", { enumerable: true, get: function () { return text_iterators_1.makeTextDecoderIterator; } });
|
|
83
|
-
Object.defineProperty(exports, "makeLineIterator", { enumerable: true, get: function () { return text_iterators_1.makeLineIterator; } });
|
|
84
|
-
Object.defineProperty(exports, "makeNumberedLineIterator", { enumerable: true, get: function () { return text_iterators_1.makeNumberedLineIterator; } });
|
|
85
|
-
var async_iteration_1 = require("./lib/iterators/async-iteration");
|
|
86
|
-
Object.defineProperty(exports, "forEach", { enumerable: true, get: function () { return async_iteration_1.forEach; } });
|
|
87
|
-
Object.defineProperty(exports, "concatenateArrayBuffersAsync", { enumerable: true, get: function () { return async_iteration_1.concatenateArrayBuffersAsync; } });
|
|
88
|
-
// REQUEST UTILS
|
|
89
|
-
var request_scheduler_1 = require("./lib/request-utils/request-scheduler");
|
|
90
|
-
Object.defineProperty(exports, "RequestScheduler", { enumerable: true, get: function () { return __importDefault(request_scheduler_1).default; } });
|
|
91
|
-
// PATH HELPERS
|
|
92
|
-
var file_aliases_1 = require("./lib/path-utils/file-aliases");
|
|
93
|
-
Object.defineProperty(exports, "setPathPrefix", { enumerable: true, get: function () { return file_aliases_1.setPathPrefix; } });
|
|
94
|
-
Object.defineProperty(exports, "getPathPrefix", { enumerable: true, get: function () { return file_aliases_1.getPathPrefix; } });
|
|
95
|
-
Object.defineProperty(exports, "resolvePath", { enumerable: true, get: function () { return file_aliases_1.resolvePath; } });
|
|
96
|
-
var file_aliases_2 = require("./lib/path-utils/file-aliases");
|
|
97
|
-
Object.defineProperty(exports, "_addAliases", { enumerable: true, get: function () { return file_aliases_2.addAliases; } });
|
|
98
|
-
// MICRO LOADERS
|
|
99
|
-
var json_loader_1 = require("./json-loader");
|
|
100
|
-
Object.defineProperty(exports, "JSONLoader", { enumerable: true, get: function () { return json_loader_1.JSONLoader; } });
|
|
101
|
-
// NODE support
|
|
102
|
-
// Node.js emulation (can be used in browser)
|
|
103
|
-
// Avoid direct use of `Buffer` which pulls in 50KB polyfill
|
|
104
|
-
var memory_conversion_utils_1 = require("./lib/binary-utils/memory-conversion-utils");
|
|
105
|
-
Object.defineProperty(exports, "isBuffer", { enumerable: true, get: function () { return memory_conversion_utils_1.isBuffer; } });
|
|
106
|
-
Object.defineProperty(exports, "toBuffer", { enumerable: true, get: function () { return memory_conversion_utils_1.toBuffer; } });
|
|
107
|
-
Object.defineProperty(exports, "toArrayBuffer", { enumerable: true, get: function () { return memory_conversion_utils_1.toArrayBuffer; } });
|
|
108
|
-
// Note.js wrappers (can be safely imported, but not used in browser)
|
|
109
|
-
// Use instead of importing 'util' to avoid node dependencies
|
|
110
|
-
var promisify_1 = require("./lib/node/promisify");
|
|
111
|
-
Object.defineProperty(exports, "promisify1", { enumerable: true, get: function () { return promisify_1.promisify1; } });
|
|
112
|
-
Object.defineProperty(exports, "promisify2", { enumerable: true, get: function () { return promisify_1.promisify2; } });
|
|
113
|
-
// `path` replacement (avoids bundling big path polyfill)
|
|
114
|
-
const path = __importStar(require("./lib/path-utils/path"));
|
|
115
|
-
exports.path = path;
|
|
116
|
-
// Use instead of importing 'fs' to avoid node dependencies`
|
|
117
|
-
const fs = __importStar(require("./lib/node/fs"));
|
|
118
|
-
exports.fs = fs;
|
|
119
|
-
// Use instead of importing 'stream' to avoid node dependencies`
|
|
120
|
-
const stream = __importStar(require("./lib/node/stream"));
|
|
121
|
-
exports.stream = stream;
|
|
122
|
-
var node_filesystem_1 = require("./lib/filesystems/node-filesystem");
|
|
123
|
-
Object.defineProperty(exports, "_NodeFileSystem", { enumerable: true, get: function () { return node_filesystem_1.NodeFileSystem; } });
|
|
124
|
-
var file_provider_1 = require("./lib/file-provider/file-provider");
|
|
125
|
-
Object.defineProperty(exports, "isFileProvider", { enumerable: true, get: function () { return file_provider_1.isFileProvider; } });
|
|
126
|
-
var file_handle_1 = require("./lib/file-provider/file-handle");
|
|
127
|
-
Object.defineProperty(exports, "FileHandle", { enumerable: true, get: function () { return file_handle_1.FileHandle; } });
|
|
128
|
-
var file_handle_file_1 = require("./lib/file-provider/file-handle-file");
|
|
129
|
-
Object.defineProperty(exports, "FileHandleFile", { enumerable: true, get: function () { return file_handle_file_1.FileHandleFile; } });
|
|
130
|
-
var data_view_file_1 = require("./lib/file-provider/data-view-file");
|
|
131
|
-
Object.defineProperty(exports, "DataViewFile", { enumerable: true, get: function () { return data_view_file_1.DataViewFile; } });
|
|
132
|
-
var readable_file_1 = require("./lib/filesystems/readable-file");
|
|
133
|
-
Object.defineProperty(exports, "makeReadableFile", { enumerable: true, get: function () { return readable_file_1.makeReadableFile; } });
|
|
134
|
-
var writable_file_1 = require("./lib/filesystems/writable-file");
|
|
135
|
-
Object.defineProperty(exports, "makeWritableFile", { enumerable: true, get: function () { return writable_file_1.makeWritableFile; } });
|
package/dist/json-loader.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JSONLoader = void 0;
|
|
4
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
7
|
-
/**
|
|
8
|
-
* A JSON Micro loader (minimal bundle size)
|
|
9
|
-
* Alternative to `@loaders.gl/json`
|
|
10
|
-
*/
|
|
11
|
-
exports.JSONLoader = {
|
|
12
|
-
name: 'JSON',
|
|
13
|
-
id: 'json',
|
|
14
|
-
module: 'json',
|
|
15
|
-
version: VERSION,
|
|
16
|
-
extensions: ['json', 'geojson'],
|
|
17
|
-
mimeTypes: ['application/json'],
|
|
18
|
-
category: 'json',
|
|
19
|
-
text: true,
|
|
20
|
-
parseTextSync,
|
|
21
|
-
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
22
|
-
options: {}
|
|
23
|
-
};
|
|
24
|
-
// TODO - deprecated
|
|
25
|
-
function parseTextSync(text) {
|
|
26
|
-
return JSON.parse(text);
|
|
27
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sliceArrayBuffer = exports.concatenateTypedArrays = exports.concatenateArrayBuffers = exports.compareArrayBuffers = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* compare two binary arrays for equality
|
|
6
|
-
* @param a
|
|
7
|
-
* @param b
|
|
8
|
-
* @param byteLength
|
|
9
|
-
*/
|
|
10
|
-
function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
|
|
11
|
-
byteLength = byteLength || arrayBuffer1.byteLength;
|
|
12
|
-
if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const array1 = new Uint8Array(arrayBuffer1);
|
|
16
|
-
const array2 = new Uint8Array(arrayBuffer2);
|
|
17
|
-
for (let i = 0; i < array1.length; ++i) {
|
|
18
|
-
if (array1[i] !== array2[i]) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
exports.compareArrayBuffers = compareArrayBuffers;
|
|
25
|
-
/**
|
|
26
|
-
* Concatenate a sequence of ArrayBuffers
|
|
27
|
-
* @return A concatenated ArrayBuffer
|
|
28
|
-
*/
|
|
29
|
-
function concatenateArrayBuffers(...sources) {
|
|
30
|
-
// Make sure all inputs are wrapped in typed arrays
|
|
31
|
-
const sourceArrays = sources.map((source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
|
|
32
|
-
// Get length of all inputs
|
|
33
|
-
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
34
|
-
// Allocate array with space for all inputs
|
|
35
|
-
const result = new Uint8Array(byteLength);
|
|
36
|
-
// Copy the subarrays
|
|
37
|
-
let offset = 0;
|
|
38
|
-
for (const sourceArray of sourceArrays) {
|
|
39
|
-
result.set(sourceArray, offset);
|
|
40
|
-
offset += sourceArray.byteLength;
|
|
41
|
-
}
|
|
42
|
-
// We work with ArrayBuffers, discard the typed array wrapper
|
|
43
|
-
return result.buffer;
|
|
44
|
-
}
|
|
45
|
-
exports.concatenateArrayBuffers = concatenateArrayBuffers;
|
|
46
|
-
/**
|
|
47
|
-
* Concatenate arbitrary count of typed arrays
|
|
48
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
|
|
49
|
-
* @param - list of arrays. All arrays should be the same type
|
|
50
|
-
* @return A concatenated TypedArray
|
|
51
|
-
*/
|
|
52
|
-
function concatenateTypedArrays(...typedArrays) {
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
const arrays = typedArrays;
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
const TypedArrayConstructor = (arrays && arrays.length > 1 && arrays[0].constructor) || null;
|
|
57
|
-
if (!TypedArrayConstructor) {
|
|
58
|
-
throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');
|
|
59
|
-
}
|
|
60
|
-
const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);
|
|
61
|
-
// @ts-ignore typescript does not like dynamic constructors
|
|
62
|
-
const result = new TypedArrayConstructor(sumLength);
|
|
63
|
-
let offset = 0;
|
|
64
|
-
for (const array of arrays) {
|
|
65
|
-
result.set(array, offset);
|
|
66
|
-
offset += array.length;
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
exports.concatenateTypedArrays = concatenateTypedArrays;
|
|
71
|
-
/**
|
|
72
|
-
* Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0
|
|
73
|
-
* @param arrayBuffer
|
|
74
|
-
* @param byteOffset
|
|
75
|
-
* @param byteLength
|
|
76
|
-
*/
|
|
77
|
-
function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) {
|
|
78
|
-
const subArray = byteLength !== undefined
|
|
79
|
-
? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength)
|
|
80
|
-
: new Uint8Array(arrayBuffer).subarray(byteOffset);
|
|
81
|
-
const arrayCopy = new Uint8Array(subArray);
|
|
82
|
-
return arrayCopy.buffer;
|
|
83
|
-
}
|
|
84
|
-
exports.sliceArrayBuffer = sliceArrayBuffer;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders./gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView = exports.copyBinaryToDataView = exports.copyStringToDataView = exports.padStringToByteAlignment = void 0;
|
|
5
|
-
const memory_copy_utils_1 = require("./memory-copy-utils");
|
|
6
|
-
/**
|
|
7
|
-
* Helper function that pads a string with spaces to fit a certain byte alignment
|
|
8
|
-
* @param string
|
|
9
|
-
* @param byteAlignment
|
|
10
|
-
* @returns
|
|
11
|
-
*
|
|
12
|
-
* @todo PERFORMANCE IDEA: No need to copy string twice...
|
|
13
|
-
*/
|
|
14
|
-
function padStringToByteAlignment(string, byteAlignment) {
|
|
15
|
-
const length = string.length;
|
|
16
|
-
const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment; // Round up to the required alignment
|
|
17
|
-
const padding = paddedLength - length;
|
|
18
|
-
let whitespace = '';
|
|
19
|
-
for (let i = 0; i < padding; ++i) {
|
|
20
|
-
whitespace += ' ';
|
|
21
|
-
}
|
|
22
|
-
return string + whitespace;
|
|
23
|
-
}
|
|
24
|
-
exports.padStringToByteAlignment = padStringToByteAlignment;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param dataView
|
|
28
|
-
* @param byteOffset
|
|
29
|
-
* @param string
|
|
30
|
-
* @param byteLength
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
function copyStringToDataView(dataView, byteOffset, string, byteLength) {
|
|
34
|
-
if (dataView) {
|
|
35
|
-
for (let i = 0; i < byteLength; i++) {
|
|
36
|
-
dataView.setUint8(byteOffset + i, string.charCodeAt(i));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return byteOffset + byteLength;
|
|
40
|
-
}
|
|
41
|
-
exports.copyStringToDataView = copyStringToDataView;
|
|
42
|
-
function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {
|
|
43
|
-
if (dataView) {
|
|
44
|
-
for (let i = 0; i < byteLength; i++) {
|
|
45
|
-
dataView.setUint8(byteOffset + i, binary[i]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return byteOffset + byteLength;
|
|
49
|
-
}
|
|
50
|
-
exports.copyBinaryToDataView = copyBinaryToDataView;
|
|
51
|
-
/**
|
|
52
|
-
* Copy sourceBuffer to dataView with some padding
|
|
53
|
-
*
|
|
54
|
-
* @param dataView - destination data container. If null - only new offset is calculated
|
|
55
|
-
* @param byteOffset - destination byte offset to copy to
|
|
56
|
-
* @param sourceBuffer - source data buffer
|
|
57
|
-
* @param padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
58
|
-
*
|
|
59
|
-
* @return new byteOffset of resulting dataView
|
|
60
|
-
*/
|
|
61
|
-
function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
|
|
62
|
-
const paddedLength = (0, memory_copy_utils_1.padToNBytes)(sourceBuffer.byteLength, padding);
|
|
63
|
-
const padLength = paddedLength - sourceBuffer.byteLength;
|
|
64
|
-
if (dataView) {
|
|
65
|
-
// Copy array
|
|
66
|
-
const targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
|
|
67
|
-
const sourceArray = new Uint8Array(sourceBuffer);
|
|
68
|
-
targetArray.set(sourceArray);
|
|
69
|
-
// Add PADDING
|
|
70
|
-
for (let i = 0; i < padLength; ++i) {
|
|
71
|
-
// json chunk is padded with spaces (ASCII 0x20)
|
|
72
|
-
dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 0x20);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
byteOffset += paddedLength;
|
|
76
|
-
return byteOffset;
|
|
77
|
-
}
|
|
78
|
-
exports.copyPaddedArrayBufferToDataView = copyPaddedArrayBufferToDataView;
|
|
79
|
-
/**
|
|
80
|
-
* Copy string to dataView with some padding
|
|
81
|
-
*
|
|
82
|
-
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
83
|
-
* @param {number} byteOffset - destination byte offset to copy to
|
|
84
|
-
* @param {string} string - source string
|
|
85
|
-
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
86
|
-
*
|
|
87
|
-
* @return new byteOffset of resulting dataView
|
|
88
|
-
*/
|
|
89
|
-
function copyPaddedStringToDataView(dataView, byteOffset, string, padding) {
|
|
90
|
-
const textEncoder = new TextEncoder();
|
|
91
|
-
// PERFORMANCE IDEA: We encode twice, once to get size and once to store
|
|
92
|
-
// PERFORMANCE IDEA: Use TextEncoder.encodeInto() to avoid temporary copy
|
|
93
|
-
const stringBuffer = textEncoder.encode(string);
|
|
94
|
-
byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
|
|
95
|
-
return byteOffset;
|
|
96
|
-
}
|
|
97
|
-
exports.copyPaddedStringToDataView = copyPaddedStringToDataView;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getMagicString = exports.getFirstCharacters = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Get the first characters from a binary file (interpret the first bytes as an ASCII string)
|
|
7
|
-
* @param data
|
|
8
|
-
* @param length
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
function getFirstCharacters(data, length = 5) {
|
|
12
|
-
if (typeof data === 'string') {
|
|
13
|
-
return data.slice(0, length);
|
|
14
|
-
}
|
|
15
|
-
else if (ArrayBuffer.isView(data)) {
|
|
16
|
-
// Typed Arrays can have offsets into underlying buffer
|
|
17
|
-
return getMagicString(data.buffer, data.byteOffset, length);
|
|
18
|
-
}
|
|
19
|
-
else if (data instanceof ArrayBuffer) {
|
|
20
|
-
const byteOffset = 0;
|
|
21
|
-
return getMagicString(data, byteOffset, length);
|
|
22
|
-
}
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
25
|
-
exports.getFirstCharacters = getFirstCharacters;
|
|
26
|
-
/**
|
|
27
|
-
* Gets a magic string from a "file"
|
|
28
|
-
* Typically used to check or detect file format
|
|
29
|
-
* @param arrayBuffer
|
|
30
|
-
* @param byteOffset
|
|
31
|
-
* @param length
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
function getMagicString(arrayBuffer, byteOffset, length) {
|
|
35
|
-
if (arrayBuffer.byteLength <= byteOffset + length) {
|
|
36
|
-
return '';
|
|
37
|
-
}
|
|
38
|
-
const dataView = new DataView(arrayBuffer);
|
|
39
|
-
let magic = '';
|
|
40
|
-
for (let i = 0; i < length; i++) {
|
|
41
|
-
magic += String.fromCharCode(dataView.getUint8(byteOffset + i));
|
|
42
|
-
}
|
|
43
|
-
return magic;
|
|
44
|
-
}
|
|
45
|
-
exports.getMagicString = getMagicString;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.toArrayBuffer = exports.toBuffer = exports.isBuffer = void 0;
|
|
28
|
-
const node = __importStar(require("../node/buffer"));
|
|
29
|
-
/**
|
|
30
|
-
* Check for Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
31
|
-
*/
|
|
32
|
-
function isBuffer(value) {
|
|
33
|
-
return value && typeof value === 'object' && value.isBuffer;
|
|
34
|
-
}
|
|
35
|
-
exports.isBuffer = isBuffer;
|
|
36
|
-
/**
|
|
37
|
-
* Converts to Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
38
|
-
* @todo better data type
|
|
39
|
-
*/
|
|
40
|
-
function toBuffer(data) {
|
|
41
|
-
return node.toBuffer ? node.toBuffer(data) : data;
|
|
42
|
-
}
|
|
43
|
-
exports.toBuffer = toBuffer;
|
|
44
|
-
/**
|
|
45
|
-
* Convert an object to an array buffer
|
|
46
|
-
*/
|
|
47
|
-
function toArrayBuffer(data) {
|
|
48
|
-
// Note: Should be called first, Buffers can trigger other detections below
|
|
49
|
-
if (isBuffer(data)) {
|
|
50
|
-
return node.toArrayBuffer(data);
|
|
51
|
-
}
|
|
52
|
-
if (data instanceof ArrayBuffer) {
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
// Careful - Node Buffers look like Uint8Arrays (keep after isBuffer)
|
|
56
|
-
if (ArrayBuffer.isView(data)) {
|
|
57
|
-
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
58
|
-
return data.buffer;
|
|
59
|
-
}
|
|
60
|
-
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
61
|
-
}
|
|
62
|
-
if (typeof data === 'string') {
|
|
63
|
-
const text = data;
|
|
64
|
-
const uint8Array = new TextEncoder().encode(text);
|
|
65
|
-
return uint8Array.buffer;
|
|
66
|
-
}
|
|
67
|
-
// HACK to support Blob polyfill
|
|
68
|
-
if (data && typeof data === 'object' && data._toArrayBuffer) {
|
|
69
|
-
return data._toArrayBuffer();
|
|
70
|
-
}
|
|
71
|
-
throw new Error('toArrayBuffer');
|
|
72
|
-
}
|
|
73
|
-
exports.toArrayBuffer = toArrayBuffer;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyToArray = exports.copyArrayBuffer = exports.padToNBytes = void 0;
|
|
4
|
-
const assert_1 = require("../env-utils/assert");
|
|
5
|
-
/**
|
|
6
|
-
* Calculate new size of an arrayBuffer to be aligned to an n-byte boundary
|
|
7
|
-
* This function increases `byteLength` by the minimum delta,
|
|
8
|
-
* allowing the total length to be divided by `padding`
|
|
9
|
-
* @param byteLength
|
|
10
|
-
* @param padding
|
|
11
|
-
*/
|
|
12
|
-
function padToNBytes(byteLength, padding) {
|
|
13
|
-
(0, assert_1.assert)(byteLength >= 0); // `Incorrect 'byteLength' value: ${byteLength}`
|
|
14
|
-
(0, assert_1.assert)(padding > 0); // `Incorrect 'padding' value: ${padding}`
|
|
15
|
-
return (byteLength + (padding - 1)) & ~(padding - 1);
|
|
16
|
-
}
|
|
17
|
-
exports.padToNBytes = padToNBytes;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new Uint8Array based on two different ArrayBuffers
|
|
20
|
-
* @param targetBuffer The first buffer.
|
|
21
|
-
* @param sourceBuffer The second buffer.
|
|
22
|
-
* @return The new ArrayBuffer created out of the two.
|
|
23
|
-
*/
|
|
24
|
-
function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset, byteLength = sourceBuffer.byteLength) {
|
|
25
|
-
const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);
|
|
26
|
-
const sourceArray = new Uint8Array(sourceBuffer);
|
|
27
|
-
targetArray.set(sourceArray);
|
|
28
|
-
return targetBuffer;
|
|
29
|
-
}
|
|
30
|
-
exports.copyArrayBuffer = copyArrayBuffer;
|
|
31
|
-
/**
|
|
32
|
-
* Copy from source to target at the targetOffset
|
|
33
|
-
*
|
|
34
|
-
* @param source - The data to copy
|
|
35
|
-
* @param target - The destination to copy data into
|
|
36
|
-
* @param targetOffset - The start offset into target to place the copied data
|
|
37
|
-
* @returns the new offset taking into account proper padding
|
|
38
|
-
*/
|
|
39
|
-
function copyToArray(source, target, targetOffset) {
|
|
40
|
-
let sourceArray;
|
|
41
|
-
if (source instanceof ArrayBuffer) {
|
|
42
|
-
sourceArray = new Uint8Array(source);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
// Pack buffer onto the big target array
|
|
46
|
-
//
|
|
47
|
-
// 'source.data.buffer' could be a view onto a larger buffer.
|
|
48
|
-
// We MUST use this constructor to ensure the byteOffset and byteLength is
|
|
49
|
-
// set to correct values from 'source.data' and not the underlying
|
|
50
|
-
// buffer for target.set() to work properly.
|
|
51
|
-
const srcByteOffset = source.byteOffset;
|
|
52
|
-
const srcByteLength = source.byteLength;
|
|
53
|
-
// In gltf parser it is set as "arrayBuffer" instead of "buffer"
|
|
54
|
-
// https://github.com/visgl/loaders.gl/blob/1e3a82a0a65d7b6a67b1e60633453e5edda2960a/modules/gltf/src/lib/parse-gltf.js#L85
|
|
55
|
-
sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);
|
|
56
|
-
}
|
|
57
|
-
// Pack buffer onto the big target array
|
|
58
|
-
target.set(sourceArray, targetOffset);
|
|
59
|
-
return targetOffset + padToNBytes(sourceArray.byteLength, 4);
|
|
60
|
-
}
|
|
61
|
-
exports.copyToArray = copyToArray;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assert = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Throws an `Error` with the optional `message` if `condition` is falsy
|
|
6
|
-
* @note Replacement for the external assert method to reduce bundle size
|
|
7
|
-
*/
|
|
8
|
-
function assert(condition, message) {
|
|
9
|
-
if (!condition) {
|
|
10
|
-
throw new Error(message || 'loader assertion failed.');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.assert = assert;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Purpose: include this in your module to avoid
|
|
3
|
-
// dependencies on micro modules like 'global' and 'is-browser';
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.document = exports.global = exports.window = exports.self = void 0;
|
|
6
|
-
/* eslint-disable no-restricted-globals */
|
|
7
|
-
const globals = {
|
|
8
|
-
self: typeof self !== 'undefined' && self,
|
|
9
|
-
window: typeof window !== 'undefined' && window,
|
|
10
|
-
global: typeof global !== 'undefined' && global,
|
|
11
|
-
document: typeof document !== 'undefined' && document
|
|
12
|
-
};
|
|
13
|
-
const self_ = globals.self || globals.window || globals.global || {};
|
|
14
|
-
exports.self = self_;
|
|
15
|
-
const window_ = globals.window || globals.self || globals.global || {};
|
|
16
|
-
exports.window = window_;
|
|
17
|
-
const global_ = globals.global || globals.self || globals.window || {};
|
|
18
|
-
exports.global = global_;
|
|
19
|
-
const document_ = globals.document || {};
|
|
20
|
-
exports.document = document_;
|
|
21
|
-
/** true if running in a browser */
|
|
22
|
-
exports.isBrowser =
|
|
23
|
-
// @ts-ignore process does not exist on browser
|
|
24
|
-
Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);
|
|
25
|
-
/** true if running in a worker thread */
|
|
26
|
-
exports.isWorker = typeof importScripts === 'function';
|
|
27
|
-
// Extract node major version
|
|
28
|
-
const matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
|
|
29
|
-
/** Major Node version (as a number) */
|
|
30
|
-
exports.nodeVersion = (matches && parseFloat(matches[1])) || 0;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataViewFile = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Checks if bigint can be converted to number and convert it if possible
|
|
6
|
-
* @param bigint bigint to be converted
|
|
7
|
-
* @returns number
|
|
8
|
-
*/
|
|
9
|
-
const toNumber = (bigint) => {
|
|
10
|
-
if (bigint > Number.MAX_SAFE_INTEGER) {
|
|
11
|
-
throw new Error('Offset is out of bounds');
|
|
12
|
-
}
|
|
13
|
-
return Number(bigint);
|
|
14
|
-
};
|
|
15
|
-
/** Provides file data using DataView */
|
|
16
|
-
class DataViewFile {
|
|
17
|
-
constructor(file) {
|
|
18
|
-
this.file = file;
|
|
19
|
-
}
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
21
|
-
async destroy() { }
|
|
22
|
-
/**
|
|
23
|
-
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
24
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
25
|
-
*/
|
|
26
|
-
async getUint8(offset) {
|
|
27
|
-
return this.file.getUint8(toNumber(offset));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
|
|
31
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
32
|
-
*/
|
|
33
|
-
async getUint16(offset) {
|
|
34
|
-
return this.file.getUint16(toNumber(offset), true);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
38
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
39
|
-
*/
|
|
40
|
-
async getUint32(offset) {
|
|
41
|
-
return this.file.getUint32(toNumber(offset), true);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
|
|
45
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
46
|
-
*/
|
|
47
|
-
async getBigUint64(offset) {
|
|
48
|
-
return this.file.getBigUint64(toNumber(offset), true);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
52
|
-
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
53
|
-
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
54
|
-
*/
|
|
55
|
-
async slice(startOffset, endOffset) {
|
|
56
|
-
return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
|
|
57
|
-
}
|
|
58
|
-
/** the length (in bytes) of the data. */
|
|
59
|
-
get length() {
|
|
60
|
-
return BigInt(this.file.byteLength);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.DataViewFile = DataViewFile;
|