MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / string2uint8array

Function string2uint8array

src/common/util.js:128–140  ·  view source on GitHub ↗
(str, b64str)

Source from the content-addressed store, hash-verified

126}
127
128export function string2uint8array(str, b64str) {
129 if (b64str) {
130 if (U8_fromBase64) return U8_fromBase64(b64str);
131 str ??= atob(b64str);
132 }
133 // 5x times faster than fetch() which serializes+deserializes the result over IPC
134 const len = str.length;
135 const array = new Uint8Array(len);
136 for (let i = 0; i < len; i += 1) {
137 array[i] = str.charCodeAt(i);
138 }
139 return array;
140}
141
142const VERSION_RE = /^(.*?)-([-.0-9a-z]+)|$/i;
143const DIGITS_RE = /^\d+$/; // using regexp to avoid +'1e2' being parsed as 100

Callers 2

decodeBodyFunction · 0.90
dataUri2textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected