@loaders.gl/loader-utils 3.3.0 → 3.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/index.js +22 -36
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/json-loader.js +1 -1
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +30 -0
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/{dataview-copy-utils.js → binary-copy-utils.js} +1 -33
- package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/{memory-conversion-utils.js → buffer-utils.js} +7 -26
- package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/encode-utils.js +36 -0
- package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/get-first-characters.js +0 -2
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/es5/lib/node/buffer.js +8 -5
- package/dist/es5/lib/node/buffer.js.map +1 -1
- package/dist/es5/lib/node/fs.js +9 -18
- package/dist/es5/lib/node/fs.js.map +1 -1
- package/dist/es5/lib/node/util.js +7 -31
- package/dist/es5/lib/node/util.js.map +1 -1
- package/dist/esm/index.js +9 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/json-loader.js.map +1 -1
- package/dist/esm/lib/binary-utils/array-buffer-utils.js +27 -0
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/{dataview-copy-utils.js → binary-copy-utils.js} +1 -31
- package/dist/esm/lib/binary-utils/binary-copy-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/buffer-utils.js +18 -0
- package/dist/esm/lib/binary-utils/buffer-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/encode-utils.js +29 -0
- package/dist/esm/lib/binary-utils/encode-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/get-first-characters.js +0 -3
- package/dist/esm/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/esm/lib/node/buffer.js +9 -5
- package/dist/esm/lib/node/buffer.js.map +1 -1
- package/dist/esm/lib/node/fs.js +9 -11
- package/dist/esm/lib/node/fs.js.map +1 -1
- package/dist/esm/lib/node/util.js +2 -10
- package/dist/esm/lib/node/util.js.map +1 -1
- package/dist/index.d.ts +7 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -25
- package/dist/lib/binary-utils/array-buffer-utils.d.ts +8 -4
- package/dist/lib/binary-utils/array-buffer-utils.d.ts.map +1 -1
- package/dist/lib/binary-utils/array-buffer-utils.js +36 -5
- package/dist/lib/binary-utils/binary-copy-utils.d.ts +24 -0
- package/dist/lib/binary-utils/binary-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/{dataview-copy-utils.js → binary-copy-utils.js} +5 -51
- package/dist/lib/binary-utils/{memory-conversion-utils.d.ts → buffer-utils.d.ts} +4 -3
- package/dist/lib/binary-utils/buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/{memory-conversion-utils.js → buffer-utils.js} +9 -28
- package/dist/lib/binary-utils/encode-utils.d.ts +4 -0
- package/dist/lib/binary-utils/encode-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/encode-utils.js +35 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts +1 -15
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -1
- package/dist/lib/binary-utils/get-first-characters.js +0 -15
- package/dist/lib/node/buffer.d.ts +1 -3
- package/dist/lib/node/buffer.d.ts.map +1 -1
- package/dist/lib/node/buffer.js +8 -7
- package/dist/lib/node/fs.d.ts +2 -4
- package/dist/lib/node/fs.d.ts.map +1 -1
- package/dist/lib/node/fs.js +9 -10
- package/dist/lib/node/util.d.ts +3 -11
- package/dist/lib/node/util.d.ts.map +1 -1
- package/dist/lib/node/util.js +27 -20
- package/dist/lib/worker-loader-utils/create-loader-worker.js +1 -1
- package/package.json +4 -5
- package/src/index.ts +18 -22
- package/src/lib/binary-utils/array-buffer-utils.ts +40 -4
- package/src/lib/binary-utils/{dataview-copy-utils.ts → binary-copy-utils.ts} +5 -57
- package/src/lib/binary-utils/buffer-utils.ts +28 -0
- package/src/lib/binary-utils/encode-utils.ts +32 -0
- package/src/lib/binary-utils/get-first-characters.ts +1 -17
- package/src/lib/node/buffer.ts +10 -9
- package/src/lib/node/fs.ts +11 -16
- package/src/lib/node/util.ts +2 -68
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js.map +0 -1
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js.map +0 -1
- package/dist/es5/lib/filesystems/readable-file.js +0 -100
- package/dist/es5/lib/filesystems/readable-file.js.map +0 -1
- package/dist/es5/lib/filesystems/writable-file.js +0 -89
- package/dist/es5/lib/filesystems/writable-file.js.map +0 -1
- package/dist/es5/lib/loader-utils/buffer-utils.js +0 -19
- package/dist/es5/lib/loader-utils/buffer-utils.js.map +0 -1
- package/dist/es5/lib/node/stream.js +0 -20
- package/dist/es5/lib/node/stream.js.map +0 -1
- package/dist/esm/lib/binary-utils/dataview-copy-utils.js.map +0 -1
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js +0 -38
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js.map +0 -1
- package/dist/esm/lib/filesystems/readable-file.js +0 -22
- package/dist/esm/lib/filesystems/readable-file.js.map +0 -1
- package/dist/esm/lib/filesystems/writable-file.js +0 -21
- package/dist/esm/lib/filesystems/writable-file.js.map +0 -1
- package/dist/esm/lib/loader-utils/buffer-utils.js +0 -13
- package/dist/esm/lib/loader-utils/buffer-utils.js.map +0 -1
- package/dist/esm/lib/node/stream.js +0 -11
- package/dist/esm/lib/node/stream.js.map +0 -1
- package/dist/lib/binary-utils/dataview-copy-utils.d.ts +0 -43
- package/dist/lib/binary-utils/dataview-copy-utils.d.ts.map +0 -1
- package/dist/lib/binary-utils/memory-conversion-utils.d.ts.map +0 -1
- package/dist/lib/filesystems/readable-file.d.ts +0 -10
- package/dist/lib/filesystems/readable-file.d.ts.map +0 -1
- package/dist/lib/filesystems/readable-file.js +0 -25
- package/dist/lib/filesystems/writable-file.d.ts +0 -18
- package/dist/lib/filesystems/writable-file.d.ts.map +0 -1
- package/dist/lib/filesystems/writable-file.js +0 -48
- package/dist/lib/loader-utils/buffer-utils.d.ts +0 -10
- package/dist/lib/loader-utils/buffer-utils.d.ts.map +0 -1
- package/dist/lib/loader-utils/buffer-utils.js +0 -22
- package/dist/lib/node/stream.d.ts +0 -4
- package/dist/lib/node/stream.d.ts.map +0 -1
- package/dist/lib/node/stream.js +0 -17
- package/src/lib/binary-utils/memory-conversion-utils.ts +0 -53
- package/src/lib/filesystems/readable-file.ts +0 -30
- package/src/lib/filesystems/writable-file.ts +0 -44
- package/src/lib/loader-utils/buffer-utils.ts +0 -18
- package/src/lib/node/stream.ts +0 -18
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports._NodeFileSystem = exports.
|
|
29
|
+
exports._NodeFileSystem = exports.fs = exports.promisify = exports.util = exports.bufferToArrayBuffer = exports.toBuffer = exports.isBuffer = exports.path = 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.copyBinaryToDataView = exports.copyStringToDataView = exports.padStringToByteAlignment = exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView = exports.copyArrayBuffer = exports.copyToArray = exports.padToNBytes = exports.compareArrayBuffers = exports.concatenateTypedArrays = exports.concatenateArrayBuffers = exports.sliceArrayBuffer = exports.toArrayBuffer = exports.parseJSON = exports.canEncodeWithWorker = exports.canParseWithWorker = exports.parseWithWorker = exports.createLoaderWorker = exports.document = exports.global = exports.window = exports.self = exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.assert = void 0;
|
|
30
30
|
// GENERAL UTILS
|
|
31
31
|
var assert_1 = require("./lib/env-utils/assert");
|
|
32
32
|
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_1.assert; } });
|
|
@@ -51,6 +51,7 @@ var parse_json_1 = require("./lib/parser-utils/parse-json");
|
|
|
51
51
|
Object.defineProperty(exports, "parseJSON", { enumerable: true, get: function () { return parse_json_1.parseJSON; } });
|
|
52
52
|
// MEMORY COPY UTILS
|
|
53
53
|
var array_buffer_utils_1 = require("./lib/binary-utils/array-buffer-utils");
|
|
54
|
+
Object.defineProperty(exports, "toArrayBuffer", { enumerable: true, get: function () { return array_buffer_utils_1.toArrayBuffer; } });
|
|
54
55
|
Object.defineProperty(exports, "sliceArrayBuffer", { enumerable: true, get: function () { return array_buffer_utils_1.sliceArrayBuffer; } });
|
|
55
56
|
Object.defineProperty(exports, "concatenateArrayBuffers", { enumerable: true, get: function () { return array_buffer_utils_1.concatenateArrayBuffers; } });
|
|
56
57
|
Object.defineProperty(exports, "concatenateTypedArrays", { enumerable: true, get: function () { return array_buffer_utils_1.concatenateTypedArrays; } });
|
|
@@ -59,12 +60,13 @@ var memory_copy_utils_1 = require("./lib/binary-utils/memory-copy-utils");
|
|
|
59
60
|
Object.defineProperty(exports, "padToNBytes", { enumerable: true, get: function () { return memory_copy_utils_1.padToNBytes; } });
|
|
60
61
|
Object.defineProperty(exports, "copyToArray", { enumerable: true, get: function () { return memory_copy_utils_1.copyToArray; } });
|
|
61
62
|
Object.defineProperty(exports, "copyArrayBuffer", { enumerable: true, get: function () { return memory_copy_utils_1.copyArrayBuffer; } });
|
|
62
|
-
var
|
|
63
|
-
Object.defineProperty(exports, "
|
|
64
|
-
Object.defineProperty(exports, "
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(exports, "
|
|
67
|
-
Object.defineProperty(exports, "
|
|
63
|
+
var binary_copy_utils_1 = require("./lib/binary-utils/binary-copy-utils");
|
|
64
|
+
Object.defineProperty(exports, "copyPaddedArrayBufferToDataView", { enumerable: true, get: function () { return binary_copy_utils_1.copyPaddedArrayBufferToDataView; } });
|
|
65
|
+
Object.defineProperty(exports, "copyPaddedStringToDataView", { enumerable: true, get: function () { return binary_copy_utils_1.copyPaddedStringToDataView; } });
|
|
66
|
+
var encode_utils_1 = require("./lib/binary-utils/encode-utils");
|
|
67
|
+
Object.defineProperty(exports, "padStringToByteAlignment", { enumerable: true, get: function () { return encode_utils_1.padStringToByteAlignment; } });
|
|
68
|
+
Object.defineProperty(exports, "copyStringToDataView", { enumerable: true, get: function () { return encode_utils_1.copyStringToDataView; } });
|
|
69
|
+
Object.defineProperty(exports, "copyBinaryToDataView", { enumerable: true, get: function () { return encode_utils_1.copyBinaryToDataView; } });
|
|
68
70
|
var get_first_characters_1 = require("./lib/binary-utils/get-first-characters");
|
|
69
71
|
Object.defineProperty(exports, "getFirstCharacters", { enumerable: true, get: function () { return get_first_characters_1.getFirstCharacters; } });
|
|
70
72
|
Object.defineProperty(exports, "getMagicString", { enumerable: true, get: function () { return get_first_characters_1.getMagicString; } });
|
|
@@ -92,28 +94,24 @@ var json_loader_1 = require("./json-loader");
|
|
|
92
94
|
Object.defineProperty(exports, "JSONLoader", { enumerable: true, get: function () { return json_loader_1.JSONLoader; } });
|
|
93
95
|
// NODE support
|
|
94
96
|
// Node.js emulation (can be used in browser)
|
|
95
|
-
// Avoid direct use of `Buffer` which pulls in 50KB polyfill
|
|
96
|
-
var memory_conversion_utils_1 = require("./lib/binary-utils/memory-conversion-utils");
|
|
97
|
-
Object.defineProperty(exports, "isBuffer", { enumerable: true, get: function () { return memory_conversion_utils_1.isBuffer; } });
|
|
98
|
-
Object.defineProperty(exports, "toBuffer", { enumerable: true, get: function () { return memory_conversion_utils_1.toBuffer; } });
|
|
99
|
-
Object.defineProperty(exports, "toArrayBuffer", { enumerable: true, get: function () { return memory_conversion_utils_1.toArrayBuffer; } });
|
|
100
|
-
// Note.js wrappers (can be safely imported, but not used in browser)
|
|
101
|
-
// Use instead of importing 'util' to avoid node dependencies
|
|
102
|
-
var util_1 = require("./lib/node/util");
|
|
103
|
-
Object.defineProperty(exports, "promisify1", { enumerable: true, get: function () { return util_1.promisify1; } });
|
|
104
|
-
Object.defineProperty(exports, "promisify2", { enumerable: true, get: function () { return util_1.promisify2; } });
|
|
105
97
|
// `path` replacement (avoids bundling big path polyfill)
|
|
106
98
|
const path = __importStar(require("./lib/path-utils/path"));
|
|
107
99
|
exports.path = path;
|
|
108
|
-
//
|
|
100
|
+
// Avoid direct use of `Buffer` which pulls in 50KB polyfill
|
|
101
|
+
var buffer_utils_1 = require("./lib/binary-utils/buffer-utils");
|
|
102
|
+
Object.defineProperty(exports, "isBuffer", { enumerable: true, get: function () { return buffer_utils_1.isBuffer; } });
|
|
103
|
+
Object.defineProperty(exports, "toBuffer", { enumerable: true, get: function () { return buffer_utils_1.toBuffer; } });
|
|
104
|
+
Object.defineProperty(exports, "bufferToArrayBuffer", { enumerable: true, get: function () { return buffer_utils_1.bufferToArrayBuffer; } });
|
|
105
|
+
// Note.js wrappers (can be safely imported, but not used in browser)
|
|
106
|
+
// Use instead of importing 'util'
|
|
107
|
+
const util = __importStar(require("./lib/node/util"));
|
|
108
|
+
exports.util = util;
|
|
109
|
+
// TODO - remove
|
|
110
|
+
var util_1 = require("./lib/node/util");
|
|
111
|
+
Object.defineProperty(exports, "promisify", { enumerable: true, get: function () { return util_1.promisify; } });
|
|
112
|
+
// Use instead of importing 'fs';`
|
|
109
113
|
const fs = __importStar(require("./lib/node/fs"));
|
|
110
114
|
exports.fs = fs;
|
|
111
|
-
//
|
|
112
|
-
const stream = __importStar(require("./lib/node/stream"));
|
|
113
|
-
exports.stream = stream;
|
|
114
|
-
var readable_file_1 = require("./lib/filesystems/readable-file");
|
|
115
|
-
Object.defineProperty(exports, "makeReadableFile", { enumerable: true, get: function () { return readable_file_1.makeReadableFile; } });
|
|
116
|
-
var writable_file_1 = require("./lib/filesystems/writable-file");
|
|
117
|
-
Object.defineProperty(exports, "makeWritableFile", { enumerable: true, get: function () { return writable_file_1.makeWritableFile; } });
|
|
115
|
+
// EXPERIMENTAL
|
|
118
116
|
var node_filesystem_1 = require("./lib/filesystems/node-filesystem");
|
|
119
117
|
Object.defineProperty(exports, "_NodeFileSystem", { enumerable: true, get: function () { return __importDefault(node_filesystem_1).default; } });
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an object to an array buffer
|
|
3
|
+
*/
|
|
4
|
+
export declare function toArrayBuffer(data: any): ArrayBuffer;
|
|
1
5
|
/**
|
|
2
6
|
* compare two binary arrays for equality
|
|
3
|
-
* @param a
|
|
4
|
-
* @param b
|
|
5
|
-
* @param byteLength
|
|
7
|
+
* @param {ArrayBuffer} a
|
|
8
|
+
* @param {ArrayBuffer} b
|
|
9
|
+
* @param {number} byteLength
|
|
6
10
|
*/
|
|
7
11
|
export declare function compareArrayBuffers(arrayBuffer1: ArrayBuffer, arrayBuffer2: ArrayBuffer, byteLength?: number): boolean;
|
|
8
12
|
/**
|
|
@@ -13,7 +17,7 @@ export declare function concatenateArrayBuffers(...sources: (ArrayBuffer | Uint8
|
|
|
13
17
|
/**
|
|
14
18
|
* Concatenate arbitrary count of typed arrays
|
|
15
19
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
|
|
16
|
-
* @param - list of arrays. All arrays should be the same type
|
|
20
|
+
* @param {...*} arrays - list of arrays. All arrays should be the same type
|
|
17
21
|
* @return A concatenated TypedArray
|
|
18
22
|
*/
|
|
19
23
|
export declare function concatenateTypedArrays<T>(...typedArrays: T[]): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-buffer-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-buffer-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,GAAG,WAAW,CA8BpD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAaT;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,OAAO,EAAE,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,GAAG,WAAW,CAqB7F;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,CAoBhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,WAAW,CAOb"}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sliceArrayBuffer = exports.concatenateTypedArrays = exports.concatenateArrayBuffers = exports.compareArrayBuffers = void 0;
|
|
3
|
+
exports.sliceArrayBuffer = exports.concatenateTypedArrays = exports.concatenateArrayBuffers = exports.compareArrayBuffers = exports.toArrayBuffer = void 0;
|
|
4
|
+
const buffer_utils_1 = require("./buffer-utils");
|
|
5
|
+
/**
|
|
6
|
+
* Convert an object to an array buffer
|
|
7
|
+
*/
|
|
8
|
+
function toArrayBuffer(data) {
|
|
9
|
+
// Note: Should be called first, Buffers can trigger other detections below
|
|
10
|
+
if ((0, buffer_utils_1.isBuffer)(data)) {
|
|
11
|
+
return (0, buffer_utils_1.bufferToArrayBuffer)(data);
|
|
12
|
+
}
|
|
13
|
+
if (data instanceof ArrayBuffer) {
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
// Careful - Node Buffers look like Uint8Arrays (keep after isBuffer)
|
|
17
|
+
if (ArrayBuffer.isView(data)) {
|
|
18
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
19
|
+
return data.buffer;
|
|
20
|
+
}
|
|
21
|
+
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
22
|
+
}
|
|
23
|
+
if (typeof data === 'string') {
|
|
24
|
+
const text = data;
|
|
25
|
+
const uint8Array = new TextEncoder().encode(text);
|
|
26
|
+
return uint8Array.buffer;
|
|
27
|
+
}
|
|
28
|
+
// HACK to support Blob polyfill
|
|
29
|
+
if (data && typeof data === 'object' && data._toArrayBuffer) {
|
|
30
|
+
return data._toArrayBuffer();
|
|
31
|
+
}
|
|
32
|
+
throw new Error('toArrayBuffer');
|
|
33
|
+
}
|
|
34
|
+
exports.toArrayBuffer = toArrayBuffer;
|
|
4
35
|
/**
|
|
5
36
|
* compare two binary arrays for equality
|
|
6
|
-
* @param a
|
|
7
|
-
* @param b
|
|
8
|
-
* @param byteLength
|
|
37
|
+
* @param {ArrayBuffer} a
|
|
38
|
+
* @param {ArrayBuffer} b
|
|
39
|
+
* @param {number} byteLength
|
|
9
40
|
*/
|
|
10
41
|
function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
|
|
11
42
|
byteLength = byteLength || arrayBuffer1.byteLength;
|
|
@@ -46,7 +77,7 @@ exports.concatenateArrayBuffers = concatenateArrayBuffers;
|
|
|
46
77
|
/**
|
|
47
78
|
* Concatenate arbitrary count of typed arrays
|
|
48
79
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
|
|
49
|
-
* @param - list of arrays. All arrays should be the same type
|
|
80
|
+
* @param {...*} arrays - list of arrays. All arrays should be the same type
|
|
50
81
|
* @return A concatenated TypedArray
|
|
51
82
|
*/
|
|
52
83
|
function concatenateTypedArrays(...typedArrays) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TypedArray } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Copy sourceBuffer to dataView with some padding
|
|
4
|
+
*
|
|
5
|
+
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
6
|
+
* @param {number} byteOffset - destination byte offset to copy to
|
|
7
|
+
* @param {Array | TypedArray} sourceBuffer - source data buffer
|
|
8
|
+
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
9
|
+
*
|
|
10
|
+
* @return new byteOffset of resulting dataView
|
|
11
|
+
*/
|
|
12
|
+
export declare function copyPaddedArrayBufferToDataView(dataView: DataView | null, byteOffset: number, sourceBuffer: TypedArray, padding: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Copy string to dataView with some padding
|
|
15
|
+
*
|
|
16
|
+
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
17
|
+
* @param {number} byteOffset - destination byte offset to copy to
|
|
18
|
+
* @param {string} string - source string
|
|
19
|
+
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
20
|
+
*
|
|
21
|
+
* @return new byteOffset of resulting dataView
|
|
22
|
+
*/
|
|
23
|
+
export declare function copyPaddedStringToDataView(dataView: DataView | null, byteOffset: number, string: string, padding: number): number;
|
|
24
|
+
//# sourceMappingURL=binary-copy-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-copy-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/binary-copy-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAGvC;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,UAAU,EACxB,OAAO,EAAE,MAAM,UAuBhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,MAAM,CASR"}
|
|
@@ -1,60 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// loaders./gl, MIT license
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView =
|
|
3
|
+
exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView = void 0;
|
|
5
4
|
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
5
|
/**
|
|
52
6
|
* Copy sourceBuffer to dataView with some padding
|
|
53
7
|
*
|
|
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)
|
|
8
|
+
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
9
|
+
* @param {number} byteOffset - destination byte offset to copy to
|
|
10
|
+
* @param {Array | TypedArray} sourceBuffer - source data buffer
|
|
11
|
+
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
58
12
|
*
|
|
59
13
|
* @return new byteOffset of resulting dataView
|
|
60
14
|
*/
|
|
@@ -9,7 +9,8 @@ export declare function isBuffer(value: any): boolean;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function toBuffer(data: any): Buffer;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
13
|
+
* @todo better data type
|
|
13
14
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
export declare function bufferToArrayBuffer(buffer: any): ArrayBuffer;
|
|
16
|
+
//# sourceMappingURL=buffer-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/buffer-utils.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAE1C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,WAAW,CAM5D"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
3
|
if (k2 === undefined) k2 = k;
|
|
5
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -24,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
23
|
return result;
|
|
25
24
|
};
|
|
26
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
26
|
+
exports.bufferToArrayBuffer = exports.toBuffer = exports.isBuffer = void 0;
|
|
28
27
|
const node = __importStar(require("../node/buffer"));
|
|
29
28
|
/**
|
|
30
29
|
* Check for Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
@@ -42,32 +41,14 @@ function toBuffer(data) {
|
|
|
42
41
|
}
|
|
43
42
|
exports.toBuffer = toBuffer;
|
|
44
43
|
/**
|
|
45
|
-
*
|
|
44
|
+
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
45
|
+
* @todo better data type
|
|
46
46
|
*/
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
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();
|
|
47
|
+
function bufferToArrayBuffer(buffer) {
|
|
48
|
+
if (isBuffer(buffer)) {
|
|
49
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
50
|
+
return typedArray.slice().buffer;
|
|
70
51
|
}
|
|
71
|
-
|
|
52
|
+
return buffer;
|
|
72
53
|
}
|
|
73
|
-
exports.
|
|
54
|
+
exports.bufferToArrayBuffer = bufferToArrayBuffer;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function padStringToByteAlignment(string: any, byteAlignment: any): string;
|
|
2
|
+
export declare function copyStringToDataView(dataView: any, byteOffset: any, string: any, byteLength: any): any;
|
|
3
|
+
export declare function copyBinaryToDataView(dataView: any, byteOffset: any, binary: any, byteLength: any): any;
|
|
4
|
+
//# sourceMappingURL=encode-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/encode-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,EAAE,aAAa,KAAA,UAS7D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,KAAA,OAO5E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,KAAA,OAO5E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Note: These were broken out from gltf loader...
|
|
3
|
+
// eslint-disable-next-line complexity
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.copyBinaryToDataView = exports.copyStringToDataView = exports.padStringToByteAlignment = void 0;
|
|
6
|
+
// PERFORMANCE IDEA: No need to copy string twice...
|
|
7
|
+
function padStringToByteAlignment(string, byteAlignment) {
|
|
8
|
+
const length = string.length;
|
|
9
|
+
const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment; // Round up to the required alignment
|
|
10
|
+
const padding = paddedLength - length;
|
|
11
|
+
let whitespace = '';
|
|
12
|
+
for (let i = 0; i < padding; ++i) {
|
|
13
|
+
whitespace += ' ';
|
|
14
|
+
}
|
|
15
|
+
return string + whitespace;
|
|
16
|
+
}
|
|
17
|
+
exports.padStringToByteAlignment = padStringToByteAlignment;
|
|
18
|
+
function copyStringToDataView(dataView, byteOffset, string, byteLength) {
|
|
19
|
+
if (dataView) {
|
|
20
|
+
for (let i = 0; i < byteLength; i++) {
|
|
21
|
+
dataView.setUint8(byteOffset + i, string.charCodeAt(i));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return byteOffset + byteLength;
|
|
25
|
+
}
|
|
26
|
+
exports.copyStringToDataView = copyStringToDataView;
|
|
27
|
+
function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {
|
|
28
|
+
if (dataView) {
|
|
29
|
+
for (let i = 0; i < byteLength; i++) {
|
|
30
|
+
dataView.setUint8(byteOffset + i, binary[i]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return byteOffset + byteLength;
|
|
34
|
+
}
|
|
35
|
+
exports.copyBinaryToDataView = copyBinaryToDataView;
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
* Get the first characters from a binary file (interpret the first bytes as an ASCII string)
|
|
3
|
-
* @param data
|
|
4
|
-
* @param length
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export declare function getFirstCharacters(data: string | ArrayBuffer, length?: number): string;
|
|
8
|
-
/**
|
|
9
|
-
* Gets a magic string from a "file"
|
|
10
|
-
* Typically used to check or detect file format
|
|
11
|
-
* @param arrayBuffer
|
|
12
|
-
* @param byteOffset
|
|
13
|
-
* @param length
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
1
|
+
export declare function getFirstCharacters(data: any, length?: number): string;
|
|
16
2
|
export declare function getMagicString(arrayBuffer: ArrayBuffer, byteOffset: number, length: number): string;
|
|
17
3
|
//# sourceMappingURL=get-first-characters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-first-characters.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-first-characters.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,IAAI,KAAA,EAAE,MAAM,SAAI,GAAG,MAAM,CAW3D;AAED,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAUR"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
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
4
|
function getFirstCharacters(data, length = 5) {
|
|
12
5
|
if (typeof data === 'string') {
|
|
13
6
|
return data.slice(0, length);
|
|
@@ -23,14 +16,6 @@ function getFirstCharacters(data, length = 5) {
|
|
|
23
16
|
return '';
|
|
24
17
|
}
|
|
25
18
|
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
19
|
function getMagicString(arrayBuffer, byteOffset, length) {
|
|
35
20
|
if (arrayBuffer.byteLength <= byteOffset + length) {
|
|
36
21
|
return '';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/**
|
|
3
3
|
* Convert Buffer to ArrayBuffer
|
|
4
|
-
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
5
|
-
* @todo better data type
|
|
6
4
|
*/
|
|
7
5
|
export declare function toArrayBuffer(buffer: any): any;
|
|
8
6
|
/**
|
|
9
7
|
* Convert (copy) ArrayBuffer to Buffer
|
|
10
8
|
*/
|
|
11
|
-
export declare function toBuffer(binaryData:
|
|
9
|
+
export declare function toBuffer(binaryData: any): void | Buffer;
|
|
12
10
|
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";AAKA;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAA,OAOnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,KAAA,iBAelC"}
|
package/dist/lib/node/buffer.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
// this file is not visible to webpack (it is excluded in the package.json "browser" field).
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.toBuffer = exports.toArrayBuffer = void 0;
|
|
6
|
+
const assert_1 = require("../env-utils/assert");
|
|
6
7
|
/**
|
|
7
8
|
* Convert Buffer to ArrayBuffer
|
|
8
|
-
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
9
|
-
* @todo better data type
|
|
10
9
|
*/
|
|
11
10
|
function toArrayBuffer(buffer) {
|
|
12
11
|
// TODO - per docs we should just be able to call buffer.buffer, but there are issues
|
|
@@ -21,15 +20,17 @@ exports.toArrayBuffer = toArrayBuffer;
|
|
|
21
20
|
* Convert (copy) ArrayBuffer to Buffer
|
|
22
21
|
*/
|
|
23
22
|
function toBuffer(binaryData) {
|
|
24
|
-
if (Buffer.isBuffer(binaryData)) {
|
|
25
|
-
return binaryData;
|
|
26
|
-
}
|
|
27
23
|
if (ArrayBuffer.isView(binaryData)) {
|
|
28
24
|
binaryData = binaryData.buffer;
|
|
29
25
|
}
|
|
30
26
|
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
31
|
-
|
|
27
|
+
const buffer = new Buffer(binaryData.byteLength);
|
|
28
|
+
const view = new Uint8Array(binaryData);
|
|
29
|
+
for (let i = 0; i < buffer.length; ++i) {
|
|
30
|
+
buffer[i] = view[i];
|
|
31
|
+
}
|
|
32
|
+
return buffer;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
return (0, assert_1.assert)(false);
|
|
34
35
|
}
|
|
35
36
|
exports.toBuffer = toBuffer;
|
package/dist/lib/node/fs.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export type { Stats, WriteStream } from 'fs';
|
|
1
|
+
export type { Stats } from 'fs';
|
|
3
2
|
export declare let readdir: any;
|
|
4
3
|
/** Wrapper for Node.js fs method */
|
|
5
4
|
export declare let stat: any;
|
|
@@ -14,12 +13,11 @@ export declare let writeFileSync: any;
|
|
|
14
13
|
/** Wrapper for Node.js fs method */
|
|
15
14
|
export declare let open: any;
|
|
16
15
|
/** Wrapper for Node.js fs method */
|
|
17
|
-
export declare let close:
|
|
16
|
+
export declare let close: any;
|
|
18
17
|
/** Wrapper for Node.js fs method */
|
|
19
18
|
export declare let read: any;
|
|
20
19
|
/** Wrapper for Node.js fs method */
|
|
21
20
|
export declare let fstat: any;
|
|
22
|
-
export declare let createWriteStream: typeof fs.createWriteStream;
|
|
23
21
|
export declare let isSupported: boolean;
|
|
24
22
|
export declare function _readToArrayBuffer(fd: number, start: number, length: number): Promise<any>;
|
|
25
23
|
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/lib/node/fs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/lib/node/fs.ts"],"names":[],"mappings":"AAKA,YAAY,EAAC,KAAK,EAAC,MAAM,IAAI,CAAC;AAE9B,eAAO,IAAI,OAAO,KAAA,CAAC;AACnB,oCAAoC;AACpC,eAAO,IAAI,IAAI,KAAA,CAAC;AAEhB,oCAAoC;AACpC,eAAO,IAAI,QAAQ,KAAA,CAAC;AACpB,oCAAoC;AACpC,eAAO,IAAI,YAAY,KAAA,CAAC;AACxB,oCAAoC;AACpC,eAAO,IAAI,SAAS,KAAA,CAAC;AACrB,oCAAoC;AACpC,eAAO,IAAI,aAAa,KAAA,CAAC;AAIzB,oCAAoC;AACpC,eAAO,IAAI,IAAI,KAAA,CAAC;AAChB,oCAAoC;AACpC,eAAO,IAAI,KAAK,KAAA,CAAC;AACjB,oCAAoC;AACpC,eAAO,IAAI,IAAI,KAAA,CAAC;AAChB,oCAAoC;AACpC,eAAO,IAAI,KAAK,KAAA,CAAC;AAEjB,eAAO,IAAI,WAAW,SAAc,CAAC;AAmCrC,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAOjF"}
|
package/dist/lib/node/fs.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._readToArrayBuffer = exports.isSupported = exports.
|
|
6
|
+
exports._readToArrayBuffer = exports.isSupported = exports.fstat = exports.read = exports.close = exports.open = exports.writeFileSync = exports.writeFile = exports.readFileSync = exports.readFile = exports.stat = exports.readdir = void 0;
|
|
7
7
|
// fs wrapper (promisified fs + avoids bundling fs in browsers)
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const buffer_1 = require("./buffer");
|
|
@@ -12,27 +12,26 @@ exports.isSupported = Boolean(fs_1.default);
|
|
|
12
12
|
// paths
|
|
13
13
|
try {
|
|
14
14
|
/** Wrapper for Node.js fs method */
|
|
15
|
-
exports.readdir = (0, util_1.
|
|
15
|
+
exports.readdir = (0, util_1.promisify)(fs_1.default.readdir);
|
|
16
16
|
/** Wrapper for Node.js fs method */
|
|
17
|
-
exports.stat = (0, util_1.
|
|
17
|
+
exports.stat = (0, util_1.promisify)(fs_1.default.stat);
|
|
18
18
|
/** Wrapper for Node.js fs method */
|
|
19
|
-
exports.readFile = fs_1.default.readFile;
|
|
19
|
+
exports.readFile = (0, util_1.promisify)(fs_1.default.readFile);
|
|
20
20
|
/** Wrapper for Node.js fs method */
|
|
21
21
|
exports.readFileSync = fs_1.default.readFileSync;
|
|
22
22
|
/** Wrapper for Node.js fs method */
|
|
23
|
-
exports.writeFile = (0, util_1.
|
|
23
|
+
exports.writeFile = (0, util_1.promisify)(fs_1.default.writeFile);
|
|
24
24
|
/** Wrapper for Node.js fs method */
|
|
25
25
|
exports.writeFileSync = fs_1.default.writeFileSync;
|
|
26
26
|
// file descriptors
|
|
27
27
|
/** Wrapper for Node.js fs method */
|
|
28
|
-
exports.open = fs_1.default.open;
|
|
28
|
+
exports.open = (0, util_1.promisify)(fs_1.default.open);
|
|
29
29
|
/** Wrapper for Node.js fs method */
|
|
30
|
-
exports.close = (
|
|
30
|
+
exports.close = (0, util_1.promisify)(fs_1.default.close);
|
|
31
31
|
/** Wrapper for Node.js fs method */
|
|
32
|
-
exports.read = fs_1.default.read;
|
|
32
|
+
exports.read = (0, util_1.promisify)(fs_1.default.read);
|
|
33
33
|
/** Wrapper for Node.js fs method */
|
|
34
|
-
exports.fstat = fs_1.default.fstat;
|
|
35
|
-
exports.createWriteStream = fs_1.default.createWriteStream;
|
|
34
|
+
exports.fstat = (0, util_1.promisify)(fs_1.default.fstat);
|
|
36
35
|
exports.isSupported = Boolean(fs_1.default);
|
|
37
36
|
}
|
|
38
37
|
catch {
|
package/dist/lib/node/util.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as util from 'util';
|
|
1
3
|
/** Wrapper for Node.js promisify */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Typesafe promisify implementation
|
|
5
|
-
* @link https://dev.to/_gdelgado/implement-a-type-safe-version-of-node-s-promisify-in-7-lines-of-code-in-typescript-2j34
|
|
6
|
-
* @param fn
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export declare function promisify1<T, A>(fn: (args: T, cb: Callback<A>) => void): (args: T) => Promise<A>;
|
|
10
|
-
export declare function promisify2<T1, T2, A>(fn: (arg1: T1, arg2: T2, cb: Callback<A>) => void): (arg1: T1, arg2: T2) => Promise<A>;
|
|
11
|
-
export declare function promisify3<T1, T2, T3, A>(fn: (arg1: T1, arg2: T2, arg3: T3, cb: Callback<A>) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<A>;
|
|
12
|
-
export {};
|
|
4
|
+
export declare const promisify: typeof util.promisify;
|
|
13
5
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/lib/node/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/lib/node/util.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,oCAAoC;AACpC,eAAO,MAAM,SAAS,uBAAiB,CAAC"}
|