MCPcopy Create free account
hub / github.com/csound/csound / arraybufferCode

Function arraybufferCode

wasm/browser/script/rollup-arraybuffer.js:3–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { readFileSync, realpathSync } from "fs";
2
3const arraybufferCode = () =>
4 `
5function atobPolyfill(input) {
6 var chars =
7 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
8 var str = String(input).replace(/[=]+$/, "");
9 if (str.length % 4 === 1) {
10 console.error(
11 "'atob' failed: The string to be decoded is not correctly encoded."
12 );
13 }
14 for (
15 var bc = 0, bs, buffer, idx = 0, output = "";
16 (buffer = str.charAt(idx++));
17 ~buffer &&
18 ((bs = bc % 4 ? bs * 64 + buffer : buffer),
19 bc++ % 4)
20 ? (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6))))
21 : 0
22 ) {
23 buffer = chars.indexOf(buffer);
24 }
25 return output;
26}
27
28function bufferFromBrowser(base64Data) {
29 if (typeof AudioWorkletGlobalScope != "undefined") {
30 return atobPolyfill(base64Data);
31 } else {
32 return window.atob(base64Data);
33 }
34}
35function bufferFromNodeJS(base64Data) {
36 return Buffer.from(base64Data, "base64").toString("binary");
37}
38function __toArrayBuffer(base64Data) {
39 var window = window || this;
40 var isBrowser = typeof process === "undefined";
41 var binary = isBrowser
42 ? bufferFromBrowser(base64Data)
43 : bufferFromNodeJS(base64Data);
44 var bytes = new Uint8Array(binary.length);
45 for (var i = 0; i < binary.length; ++i) {
46 bytes[i] = binary.charCodeAt(i);
47 }
48 return bytes.buffer;
49}
50`
51 .split("\n")
52 .map(Function.prototype.call, String.prototype.trim)
53 .join("");
54
55export default function arraybufferPlugin(options = {}) {
56 // const filter = createFilter(options.include, options.exclude);

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected