@k13engineering/rubberband 0.0.4 → 0.0.5
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/lib/rubberband.js +18 -7
- package/package.json +1 -1
package/dist/lib/rubberband.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const isNode = typeof globalThis.process !== "undefined" &&
|
|
2
|
+
globalThis.process.versions !== null &&
|
|
3
|
+
globalThis.process.versions.node !== null;
|
|
4
|
+
|
|
5
|
+
const loadRubberbandWasmNodeJs = async () => {
|
|
6
|
+
const nodeFs = await import("fs");
|
|
7
|
+
const nodeUrl = await import("url");
|
|
8
|
+
const rubberbandWasmUrl = import.meta.resolve("rubberband-wasm/dist/rubberband.wasm");
|
|
9
|
+
const rubberbandWasmPath = nodeUrl.fileURLToPath(rubberbandWasmUrl);
|
|
10
|
+
const rubberbandWasm = await nodeFs.promises.readFile(rubberbandWasmPath);
|
|
11
|
+
return new Uint8Array(rubberbandWasm);
|
|
12
|
+
};
|
|
3
13
|
|
|
4
14
|
const loadRubberbandWasm = async () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
|
|
16
|
+
if (isNode) {
|
|
17
|
+
return await loadRubberbandWasmNodeJs();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
throw Error("browser environment not implemented yet");
|
|
9
21
|
};
|
|
10
22
|
|
|
11
23
|
export {
|
|
12
24
|
loadRubberbandWasm
|
|
13
25
|
};
|
|
14
|
-
/* c8 ignore end */
|
package/package.json
CHANGED