(str, b64str)
| 126 | } |
| 127 | |
| 128 | export 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 | |
| 142 | const VERSION_RE = /^(.*?)-([-.0-9a-z]+)|$/i; |
| 143 | const DIGITS_RE = /^\d+$/; // using regexp to avoid +'1e2' being parsed as 100 |
no outgoing calls
no test coverage detected