MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / toUint8Array

Function toUint8Array

src/pkg/utils/jszip-x.ts:195–209  ·  view source on GitHub ↗
(content: ZipEntryData)

Source from the content-addressed store, hash-verified

193}
194
195async function toUint8Array(content: ZipEntryData): Promise<Uint8Array<ArrayBuffer>> {
196 if (typeof content === "string") {
197 return new TextEncoder().encode(content) as Uint8Array<ArrayBuffer>;
198 }
199 if (content instanceof Uint8Array) {
200 return content as Uint8Array<ArrayBuffer>;
201 }
202 if (content instanceof ArrayBuffer) {
203 return new Uint8Array(content);
204 }
205 if (typeof Blob !== "undefined" && content instanceof Blob) {
206 return new Uint8Array(await content.arrayBuffer());
207 }
208 return new TextEncoder().encode(String(content)) as Uint8Array<ArrayBuffer>;
209}

Callers 1

toUint8ArrayMethod · 0.85

Calls 1

arrayBufferMethod · 0.45

Tested by

no test coverage detected