@loaders.gl/loader-utils 3.1.0-alpha.5 → 3.1.0-beta.4
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/json-loader.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +1 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.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/worker-loader-utils/parse-with-worker.js +1 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +111 -0
- package/dist/json-loader.d.ts +1 -0
- package/dist/json-loader.d.ts.map +1 -0
- package/dist/json-loader.js +28 -0
- package/dist/lib/binary-utils/array-buffer-utils.d.ts +1 -0
- package/dist/lib/binary-utils/array-buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/array-buffer-utils.js +115 -0
- package/dist/lib/binary-utils/binary-copy-utils.d.ts +1 -0
- package/dist/lib/binary-utils/binary-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/binary-copy-utils.js +51 -0
- package/dist/lib/binary-utils/buffer-utils.d.ts +1 -0
- package/dist/lib/binary-utils/buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/buffer-utils.js +50 -0
- package/dist/lib/binary-utils/encode-utils.d.ts +1 -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 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -0
- package/dist/lib/binary-utils/get-first-characters.js +30 -0
- package/dist/lib/binary-utils/memory-copy-utils.d.ts +1 -0
- package/dist/lib/binary-utils/memory-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/memory-copy-utils.js +61 -0
- package/dist/lib/env-utils/assert.d.ts +1 -0
- package/dist/lib/env-utils/assert.d.ts.map +1 -0
- package/dist/lib/env-utils/assert.js +13 -0
- package/dist/lib/env-utils/globals.d.ts +1 -0
- package/dist/lib/env-utils/globals.d.ts.map +1 -0
- package/dist/lib/env-utils/globals.js +30 -0
- package/dist/lib/filesystems/node-filesystem.d.ts +1 -0
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem.js +69 -0
- package/dist/lib/iterators/async-iteration.d.ts +1 -0
- package/dist/lib/iterators/async-iteration.d.ts.map +1 -0
- package/dist/lib/iterators/async-iteration.js +53 -0
- package/dist/lib/iterators/text-iterators.d.ts +1 -0
- package/dist/lib/iterators/text-iterators.d.ts.map +1 -0
- package/dist/lib/iterators/text-iterators.js +61 -0
- package/dist/lib/node/buffer.d.ts +1 -0
- package/dist/lib/node/buffer.d.ts.map +1 -0
- package/dist/lib/node/buffer.js +36 -0
- package/dist/lib/node/fs.d.ts +1 -0
- package/dist/lib/node/fs.d.ts.map +1 -0
- package/dist/lib/node/fs.js +42 -0
- package/dist/lib/node/util.d.ts +1 -0
- package/dist/lib/node/util.d.ts.map +1 -0
- package/dist/lib/node/util.js +25 -0
- package/dist/lib/parser-utils/parse-json.d.ts +1 -0
- package/dist/lib/parser-utils/parse-json.d.ts.map +1 -0
- package/dist/lib/parser-utils/parse-json.js +16 -0
- package/dist/lib/path-utils/file-aliases.d.ts +1 -0
- package/dist/lib/path-utils/file-aliases.d.ts.map +1 -0
- package/dist/lib/path-utils/file-aliases.js +47 -0
- package/dist/lib/path-utils/path.d.ts +1 -0
- package/dist/lib/path-utils/path.d.ts.map +1 -0
- package/dist/lib/path-utils/path.js +40 -0
- package/dist/lib/request-utils/request-scheduler.d.ts +1 -0
- package/dist/lib/request-utils/request-scheduler.d.ts.map +1 -0
- package/dist/lib/request-utils/request-scheduler.js +142 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +1 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.js +97 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +1 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.js +73 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/workers/json-worker.d.ts +1 -0
- package/dist/workers/json-worker.d.ts.map +1 -0
- package/dist/workers/json-worker.js +5 -0
- package/package.json +4 -8
- package/src/lib/worker-loader-utils/parse-with-worker.ts +6 -5
|
@@ -22,3 +22,4 @@ export declare function copyArrayBuffer(targetBuffer: ArrayBuffer, sourceBuffer:
|
|
|
22
22
|
* @returns the new offset taking into account proper padding
|
|
23
23
|
*/
|
|
24
24
|
export declare function copyToArray(source: ArrayBuffer | any, target: any, targetOffset: number): number;
|
|
25
|
+
//# sourceMappingURL=memory-copy-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-copy-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/memory-copy-utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAAgC,GAC3C,WAAW,CAKb;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAuBhG"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/lib/env-utils/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAI7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../src/lib/env-utils/globals.ts"],"names":[],"mappings":"AAWA,aAAK,GAAG,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAC;AAChC,QAAA,MAAM,KAAK,EAAE,GAA4D,CAAC;AAC1E,QAAA,MAAM,OAAO,EAAE,GAA4D,CAAC;AAC5E,QAAA,MAAM,OAAO,EAAE,GAA4D,CAAC;AAC5E,QAAA,MAAM,SAAS,EAAE,GAA4B,CAAC;AAE9C,OAAO,EAAC,KAAK,IAAI,IAAI,EAAE,OAAO,IAAI,MAAM,EAAE,OAAO,IAAI,MAAM,EAAE,SAAS,IAAI,QAAQ,EAAC,CAAC;AAEpF,mCAAmC;AACnC,eAAO,MAAM,SAAS,EAAE,OAE2E,CAAC;AAEpG,yCAAyC;AACzC,eAAO,MAAM,QAAQ,EAAE,OAA6C,CAAC;AAKrE,uCAAuC;AACvC,eAAO,MAAM,WAAW,EAAE,MAAiD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-filesystem.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/node-filesystem.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,WAAW,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAIrE,aAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;CACjB,CAAC;AAEF,aAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,WAAW,EAAE,2BAA2B;gBAEzE,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAInC,OAAO,CAAC,OAAO,SAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAIpD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAQjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvE,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhC,IAAI,CACR,EAAE,EAAE,MAAM,EAEV,EAAC,MAAa,EAAE,MAAU,EAAE,MAA0B,EAAE,QAAe,EAAC,EAAE,WAAW,GACpF,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC;CAehD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const fs = __importStar(require("../node/fs"));
|
|
23
|
+
/**
|
|
24
|
+
* FileSystem pass-through for Node.js
|
|
25
|
+
* Compatible with BrowserFileSystem.
|
|
26
|
+
* @param options
|
|
27
|
+
*/
|
|
28
|
+
class NodeFileSystem {
|
|
29
|
+
// implements IFileSystem
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.fetch = options._fetch;
|
|
32
|
+
}
|
|
33
|
+
async readdir(dirname = '.', options) {
|
|
34
|
+
return await fs.readdir(dirname, options);
|
|
35
|
+
}
|
|
36
|
+
async stat(path, options) {
|
|
37
|
+
const info = await fs.stat(path, options);
|
|
38
|
+
return { size: Number(info.size), isDirectory: () => false, info };
|
|
39
|
+
}
|
|
40
|
+
async fetch(path, options) {
|
|
41
|
+
// Falls back to handle https:/http:/data: etc fetches
|
|
42
|
+
// eslint-disable-next-line
|
|
43
|
+
const fallbackFetch = options.fetch || this.fetch;
|
|
44
|
+
return fallbackFetch(path, options);
|
|
45
|
+
}
|
|
46
|
+
// implements IRandomAccessFileSystem
|
|
47
|
+
async open(path, flags, mode) {
|
|
48
|
+
return await fs.open(path, flags);
|
|
49
|
+
}
|
|
50
|
+
async close(fd) {
|
|
51
|
+
return await fs.close(fd);
|
|
52
|
+
}
|
|
53
|
+
async fstat(fd) {
|
|
54
|
+
const info = await fs.fstat(fd);
|
|
55
|
+
return info;
|
|
56
|
+
}
|
|
57
|
+
async read(fd,
|
|
58
|
+
// @ts-ignore Possibly null
|
|
59
|
+
{ buffer = null, offset = 0, length = buffer.byteLength, position = null }) {
|
|
60
|
+
let totalBytesRead = 0;
|
|
61
|
+
// Read in loop until we get required number of bytes
|
|
62
|
+
while (totalBytesRead < length) {
|
|
63
|
+
const { bytesRead } = await fs.read(fd, buffer, offset + totalBytesRead, length - totalBytesRead, position + totalBytesRead);
|
|
64
|
+
totalBytesRead += bytesRead;
|
|
65
|
+
}
|
|
66
|
+
return { bytesRead: totalBytesRead, buffer };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.default = NodeFileSystem;
|
|
@@ -17,3 +17,4 @@ export declare function forEach(iterator: any, visitor: any): Promise<void>;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function concatenateArrayBuffersAsync(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): Promise<ArrayBuffer>;
|
|
19
19
|
export declare function concatenateStringsAsync(asyncIterator: AsyncIterable<string> | Iterable<string>): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=async-iteration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-iteration.d.ts","sourceRoot":"","sources":["../../../src/lib/iterators/async-iteration.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAsB,OAAO,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAa9C;AAID;;;GAGG;AAEH,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,GACtD,OAAO,CAAC,MAAM,CAAC,CAMjB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.concatenateStringsAsync = exports.concatenateArrayBuffersAsync = exports.forEach = void 0;
|
|
4
|
+
const array_buffer_utils_1 = require("../binary-utils/array-buffer-utils");
|
|
5
|
+
// GENERAL UTILITIES
|
|
6
|
+
/**
|
|
7
|
+
* Iterate over async iterator, without resetting iterator if end is not reached
|
|
8
|
+
* - forEach intentionally does not reset iterator if exiting loop prematurely
|
|
9
|
+
* so that iteration can continue in a second loop
|
|
10
|
+
* - It is recommended to use a standard for-await as last loop to ensure
|
|
11
|
+
* iterator gets properly reset
|
|
12
|
+
*
|
|
13
|
+
* TODO - optimize using sync iteration if argument is an Iterable?
|
|
14
|
+
*
|
|
15
|
+
* @param iterator
|
|
16
|
+
* @param visitor
|
|
17
|
+
*/
|
|
18
|
+
async function forEach(iterator, visitor) {
|
|
19
|
+
// eslint-disable-next-line
|
|
20
|
+
while (true) {
|
|
21
|
+
const { done, value } = await iterator.next();
|
|
22
|
+
if (done) {
|
|
23
|
+
iterator.return();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const cancel = visitor(value);
|
|
27
|
+
if (cancel) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.forEach = forEach;
|
|
33
|
+
// Breaking big data into iterable chunks, concatenating iterable chunks into big data objects
|
|
34
|
+
/**
|
|
35
|
+
* Concatenates all data chunks yielded by an (async) iterator
|
|
36
|
+
* This function can e.g. be used to enable atomic parsers to work on (async) iterator inputs
|
|
37
|
+
*/
|
|
38
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
39
|
+
const arrayBuffers = [];
|
|
40
|
+
for await (const chunk of asyncIterator) {
|
|
41
|
+
arrayBuffers.push(chunk);
|
|
42
|
+
}
|
|
43
|
+
return (0, array_buffer_utils_1.concatenateArrayBuffers)(...arrayBuffers);
|
|
44
|
+
}
|
|
45
|
+
exports.concatenateArrayBuffersAsync = concatenateArrayBuffersAsync;
|
|
46
|
+
async function concatenateStringsAsync(asyncIterator) {
|
|
47
|
+
const strings = [];
|
|
48
|
+
for await (const chunk of asyncIterator) {
|
|
49
|
+
strings.push(chunk);
|
|
50
|
+
}
|
|
51
|
+
return strings.join('');
|
|
52
|
+
}
|
|
53
|
+
exports.concatenateStringsAsync = concatenateStringsAsync;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-iterators.d.ts","sourceRoot":"","sources":["../../../src/lib/iterators/text-iterators.ts"],"names":[],"mappings":"AAGA,wBAAuB,uBAAuB,CAC5C,mBAAmB,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACvE,OAAO,GAAE,kBAAuB,GAC/B,aAAa,CAAC,MAAM,CAAC,CAOvB;AAOD,wBAAuB,uBAAuB,CAC5C,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAC1D,aAAa,CAAC,WAAW,CAAC,CAK5B;AAED;;;;GAIG;AAEH,wBAAuB,gBAAgB,CACrC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,GAClC,aAAa,CAAC,MAAM,CAAC,CAgBvB;AAED;;;;;GAKG;AACH,wBAAuB,wBAAwB,CAC7C,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,GAClC,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,CAMhD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TextDecoder iterators
|
|
3
|
+
// TextDecoder will keep any partial undecoded bytes between calls to `decode`
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.makeNumberedLineIterator = exports.makeLineIterator = exports.makeTextEncoderIterator = exports.makeTextDecoderIterator = void 0;
|
|
6
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
7
|
+
const textDecoder = new TextDecoder(undefined, options);
|
|
8
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
9
|
+
yield typeof arrayBuffer === 'string'
|
|
10
|
+
? arrayBuffer
|
|
11
|
+
: textDecoder.decode(arrayBuffer, { stream: true });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.makeTextDecoderIterator = makeTextDecoderIterator;
|
|
15
|
+
// TextEncoder iterator
|
|
16
|
+
// TODO - this is not useful unless min chunk size is given
|
|
17
|
+
// TextEncoder will keep any partial undecoded bytes between calls to `encode`
|
|
18
|
+
// If iterator does not yield strings, assume arrayBuffer and return unencoded
|
|
19
|
+
async function* makeTextEncoderIterator(textIterator) {
|
|
20
|
+
const textEncoder = new TextEncoder();
|
|
21
|
+
for await (const text of textIterator) {
|
|
22
|
+
yield typeof text === 'string' ? textEncoder.encode(text) : text;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.makeTextEncoderIterator = makeTextEncoderIterator;
|
|
26
|
+
/**
|
|
27
|
+
* @param textIterator async iterable yielding strings
|
|
28
|
+
* @returns an async iterable over lines
|
|
29
|
+
* See http://2ality.com/2018/04/async-iter-nodejs.html
|
|
30
|
+
*/
|
|
31
|
+
async function* makeLineIterator(textIterator) {
|
|
32
|
+
let previous = '';
|
|
33
|
+
for await (const textChunk of textIterator) {
|
|
34
|
+
previous += textChunk;
|
|
35
|
+
let eolIndex;
|
|
36
|
+
while ((eolIndex = previous.indexOf('\n')) >= 0) {
|
|
37
|
+
// line includes the EOL
|
|
38
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
39
|
+
previous = previous.slice(eolIndex + 1);
|
|
40
|
+
yield line;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (previous.length > 0) {
|
|
44
|
+
yield previous;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.makeLineIterator = makeLineIterator;
|
|
48
|
+
/**
|
|
49
|
+
* @param lineIterator async iterable yielding lines
|
|
50
|
+
* @returns async iterable yielding numbered lines
|
|
51
|
+
*
|
|
52
|
+
* See http://2ality.com/2018/04/async-iter-nodejs.html
|
|
53
|
+
*/
|
|
54
|
+
async function* makeNumberedLineIterator(lineIterator) {
|
|
55
|
+
let counter = 1;
|
|
56
|
+
for await (const line of lineIterator) {
|
|
57
|
+
yield { counter, line };
|
|
58
|
+
counter++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.makeNumberedLineIterator = makeNumberedLineIterator;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)
|
|
3
|
+
// this file is not visible to webpack (it is excluded in the package.json "browser" field).
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.toBuffer = exports.toArrayBuffer = void 0;
|
|
6
|
+
const assert_1 = require("../env-utils/assert");
|
|
7
|
+
/**
|
|
8
|
+
* Convert Buffer to ArrayBuffer
|
|
9
|
+
*/
|
|
10
|
+
function toArrayBuffer(buffer) {
|
|
11
|
+
// TODO - per docs we should just be able to call buffer.buffer, but there are issues
|
|
12
|
+
if (Buffer.isBuffer(buffer)) {
|
|
13
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
14
|
+
return typedArray.slice().buffer;
|
|
15
|
+
}
|
|
16
|
+
return buffer;
|
|
17
|
+
}
|
|
18
|
+
exports.toArrayBuffer = toArrayBuffer;
|
|
19
|
+
/**
|
|
20
|
+
* Convert (copy) ArrayBuffer to Buffer
|
|
21
|
+
*/
|
|
22
|
+
function toBuffer(binaryData) {
|
|
23
|
+
if (ArrayBuffer.isView(binaryData)) {
|
|
24
|
+
binaryData = binaryData.buffer;
|
|
25
|
+
}
|
|
26
|
+
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
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;
|
|
33
|
+
}
|
|
34
|
+
return (0, assert_1.assert)(false);
|
|
35
|
+
}
|
|
36
|
+
exports.toBuffer = toBuffer;
|
package/dist/lib/node/fs.d.ts
CHANGED
|
@@ -23,3 +23,4 @@ export declare const read: typeof fs.read.__promisify__;
|
|
|
23
23
|
export declare const fstat: typeof fs.fstat.__promisify__;
|
|
24
24
|
export declare const isSupported: boolean;
|
|
25
25
|
export declare function _readToArrayBuffer(fd: number, start: number, length: number): Promise<any>;
|
|
26
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/lib/node/fs.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,YAAY,EAAC,KAAK,EAAC,MAAM,IAAI,CAAC;AAI9B,oCAAoC;AACpC,eAAO,MAAM,OAAO,iCAAwB,CAAC;AAC7C,oCAAoC;AACpC,eAAO,MAAM,IAAI,8BAAqB,CAAC;AAEvC,oCAAoC;AACpC,eAAO,MAAM,QAAQ,kCAAyB,CAAC;AAC/C,oCAAoC;AACpC,eAAO,MAAM,YAAY,wBAAkB,CAAC;AAC5C,oCAAoC;AACpC,eAAO,MAAM,SAAS,mCAA0B,CAAC;AACjD,oCAAoC;AACpC,eAAO,MAAM,aAAa,yBAAmB,CAAC;AAI9C,oCAAoC;AACpC,eAAO,MAAM,IAAI,8BAAqB,CAAC;AACvC,oCAAoC;AACpC,eAAO,MAAM,KAAK,+BAAsB,CAAC;AACzC,oCAAoC;AACpC,eAAO,MAAM,IAAI,8BAAqB,CAAC;AACvC,oCAAoC;AACpC,eAAO,MAAM,KAAK,+BAAsB,CAAC;AAEzC,eAAO,MAAM,WAAW,SAAc,CAAC;AAEvC,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAOjF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
// fs wrapper (promisified fs + avoids bundling fs in browsers)
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const buffer_1 = require("./buffer");
|
|
10
|
+
const util_1 = require("./util");
|
|
11
|
+
// paths
|
|
12
|
+
/** Wrapper for Node.js fs method */
|
|
13
|
+
exports.readdir = (0, util_1.promisify)(fs_1.default.readdir);
|
|
14
|
+
/** Wrapper for Node.js fs method */
|
|
15
|
+
exports.stat = (0, util_1.promisify)(fs_1.default.stat);
|
|
16
|
+
/** Wrapper for Node.js fs method */
|
|
17
|
+
exports.readFile = (0, util_1.promisify)(fs_1.default.readFile);
|
|
18
|
+
/** Wrapper for Node.js fs method */
|
|
19
|
+
exports.readFileSync = fs_1.default.readFileSync;
|
|
20
|
+
/** Wrapper for Node.js fs method */
|
|
21
|
+
exports.writeFile = (0, util_1.promisify)(fs_1.default.writeFile);
|
|
22
|
+
/** Wrapper for Node.js fs method */
|
|
23
|
+
exports.writeFileSync = fs_1.default.writeFileSync;
|
|
24
|
+
// file descriptors
|
|
25
|
+
/** Wrapper for Node.js fs method */
|
|
26
|
+
exports.open = (0, util_1.promisify)(fs_1.default.open);
|
|
27
|
+
/** Wrapper for Node.js fs method */
|
|
28
|
+
exports.close = (0, util_1.promisify)(fs_1.default.close);
|
|
29
|
+
/** Wrapper for Node.js fs method */
|
|
30
|
+
exports.read = (0, util_1.promisify)(fs_1.default.read);
|
|
31
|
+
/** Wrapper for Node.js fs method */
|
|
32
|
+
exports.fstat = (0, util_1.promisify)(fs_1.default.fstat);
|
|
33
|
+
exports.isSupported = Boolean(fs_1.default);
|
|
34
|
+
async function _readToArrayBuffer(fd, start, length) {
|
|
35
|
+
const buffer = Buffer.alloc(length);
|
|
36
|
+
const { bytesRead } = await (0, exports.read)(fd, buffer, 0, length, start);
|
|
37
|
+
if (bytesRead !== length) {
|
|
38
|
+
throw new Error('fs.read failed');
|
|
39
|
+
}
|
|
40
|
+
return (0, buffer_1.toArrayBuffer)(buffer);
|
|
41
|
+
}
|
|
42
|
+
exports._readToArrayBuffer = _readToArrayBuffer;
|
package/dist/lib/node/util.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.promisify = void 0;
|
|
23
|
+
const util = __importStar(require("util"));
|
|
24
|
+
/** Wrapper for Node.js promisify */
|
|
25
|
+
exports.promisify = util.promisify;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["../../../src/lib/parser-utils/parse-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAM7C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseJSON = void 0;
|
|
4
|
+
const get_first_characters_1 = require("../binary-utils/get-first-characters");
|
|
5
|
+
/**
|
|
6
|
+
* Minimal JSON parser that throws more meaningful error messages
|
|
7
|
+
*/
|
|
8
|
+
function parseJSON(string) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(string);
|
|
11
|
+
}
|
|
12
|
+
catch (_) {
|
|
13
|
+
throw new Error(`Failed to parse JSON from data starting with "${(0, get_first_characters_1.getFirstCharacters)(string)}"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.parseJSON = parseJSON;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-aliases.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/file-aliases.ts"],"names":[],"mappings":"AAQA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAElD;AAKD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GAAG,IAAI,CAEvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWpD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Simple file alias mechanisms for tests.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolvePath = exports.addAliases = exports.getPathPrefix = exports.setPathPrefix = void 0;
|
|
5
|
+
let pathPrefix = '';
|
|
6
|
+
const fileAliases = {};
|
|
7
|
+
/*
|
|
8
|
+
* Set a relative path prefix
|
|
9
|
+
*/
|
|
10
|
+
function setPathPrefix(prefix) {
|
|
11
|
+
pathPrefix = prefix;
|
|
12
|
+
}
|
|
13
|
+
exports.setPathPrefix = setPathPrefix;
|
|
14
|
+
/*
|
|
15
|
+
* Get the relative path prefix
|
|
16
|
+
*/
|
|
17
|
+
function getPathPrefix() {
|
|
18
|
+
return pathPrefix;
|
|
19
|
+
}
|
|
20
|
+
exports.getPathPrefix = getPathPrefix;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param aliases
|
|
24
|
+
*
|
|
25
|
+
* Note: addAliases are an experimental export, they are only for testing of loaders.gl loaders
|
|
26
|
+
* not intended as a generic aliasing mechanism
|
|
27
|
+
*/
|
|
28
|
+
function addAliases(aliases) {
|
|
29
|
+
Object.assign(fileAliases, aliases);
|
|
30
|
+
}
|
|
31
|
+
exports.addAliases = addAliases;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves aliases and adds path-prefix to paths
|
|
34
|
+
*/
|
|
35
|
+
function resolvePath(filename) {
|
|
36
|
+
for (const alias in fileAliases) {
|
|
37
|
+
if (filename.startsWith(alias)) {
|
|
38
|
+
const replacement = fileAliases[alias];
|
|
39
|
+
filename = filename.replace(alias, replacement);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!filename.startsWith('http://') && !filename.startsWith('https://')) {
|
|
43
|
+
filename = `${pathPrefix}${filename}`;
|
|
44
|
+
}
|
|
45
|
+
return filename;
|
|
46
|
+
}
|
|
47
|
+
exports.resolvePath = resolvePath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/path.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAY/C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.join = exports.dirname = exports.filename = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Replacement for Node.js path.filename
|
|
7
|
+
* @param url
|
|
8
|
+
*/
|
|
9
|
+
function filename(url) {
|
|
10
|
+
const slashIndex = url && url.lastIndexOf('/');
|
|
11
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
12
|
+
}
|
|
13
|
+
exports.filename = filename;
|
|
14
|
+
/**
|
|
15
|
+
* Replacement for Node.js path.dirname
|
|
16
|
+
* @param url
|
|
17
|
+
*/
|
|
18
|
+
function dirname(url) {
|
|
19
|
+
const slashIndex = url && url.lastIndexOf('/');
|
|
20
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
21
|
+
}
|
|
22
|
+
exports.dirname = dirname;
|
|
23
|
+
/**
|
|
24
|
+
* Replacement for Node.js path.join
|
|
25
|
+
* @param parts
|
|
26
|
+
*/
|
|
27
|
+
function join(...parts) {
|
|
28
|
+
const separator = '/';
|
|
29
|
+
parts = parts.map((part, index) => {
|
|
30
|
+
if (index) {
|
|
31
|
+
part = part.replace(new RegExp(`^${separator}`), '');
|
|
32
|
+
}
|
|
33
|
+
if (index !== parts.length - 1) {
|
|
34
|
+
part = part.replace(new RegExp(`${separator}$`), '');
|
|
35
|
+
}
|
|
36
|
+
return part;
|
|
37
|
+
});
|
|
38
|
+
return parts.join(separator);
|
|
39
|
+
}
|
|
40
|
+
exports.join = join;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-scheduler.d.ts","sourceRoot":"","sources":["../../../src/lib/request-utils/request-scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAEtC,aAAK,MAAM,GAAG,GAAG,CAAC;AAClB,aAAK,YAAY,GAAG,MAAM,GAAG,CAAC;AAC9B,aAAK,mBAAmB,GAAG,MAAM,MAAM,CAAC;AACxC,aAAK,aAAa,GAAG;IACnB,IAAI,EAAE,YAAY,CAAC;CACpB,GAAG,IAAI,CAAC;AAET,+BAA+B;AAC/B,oBAAY,qBAAqB,GAAG;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAgBF,yBAAyB;AACzB,aAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAK;IAE/B,oFAAoF;IACpF,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,UAAU,CAAkD;IACpE,OAAO,CAAC,cAAc,CAAa;gBAEvB,KAAK,GAAE,qBAA0B;IAY7C;;;;;;;;;;;;;;;OAeG;IACH,eAAe,CACb,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,mBAA6B,GACzC,OAAO,CAAC,aAAa,CAAC;IA0BzB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB7C,oEAAoE;IACpE,iBAAiB,IAAI,IAAI;IAMzB,4BAA4B;IAC5B,sBAAsB;IAwBtB,mGAAmG;IACnG,kBAAkB;IAgBlB,sDAAsD;IACtD,cAAc,CAAC,OAAO,KAAA;CAUvB"}
|