streaming zip archiver/extractor jsr.io/@mary/zip
typescript jsr
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: fromBlob

Mary 78fc682a e491a462

+20
+20
lib/reader/common.ts
··· 42 42 }; 43 43 } 44 44 45 + /** 46 + * creates a reader from a Blob object 47 + * @param blob Blob object to read from 48 + * @returns a reader for the Blob 49 + */ 50 + export function fromFile(blob: Blob): Reader { 51 + const totalLength = blob.size; 52 + 53 + return { 54 + length: totalLength, 55 + // deno-lint-ignore require-await 56 + async read(offset: number, length?: number): Promise<ReadableStream<Uint8Array>> { 57 + const endOffset = length !== undefined ? offset + length : totalLength; 58 + 59 + const slice = blob.slice(offset, endOffset); 60 + return slice.stream(); 61 + }, 62 + }; 63 + } 64 + 45 65 export interface FetchReaderOptions { 46 66 input: string | URL | Request; 47 67 fetch?: typeof fetch;