UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

66 lines (64 loc) • 1.28 kB
var FileSystemReadableStreamSource = class { handle; size = 1024; type = "bytes"; constructor(handle) { this.handle = handle; } cancel() { this.handle.close(); } async pull(controller) { const view = controller.byobRequest?.view; let bytes; try { bytes = await this.handle.readBytes(view ? view.byteLength : this.size); } catch (error) { try { this.handle.close(); } catch {} throw error; } if (!view) { if (bytes.length === 0) { this.handle.close(); controller.close(); return; } controller.enqueue(bytes); return; } if (bytes.length === 0) { this.handle.close(); controller.close(); controller.byobRequest?.respond(0); return; } new Uint8Array(view.buffer, view.byteOffset, view.byteLength).set(bytes); controller.byobRequest?.respond(bytes.length); } }; var FileSystemWritableSink = class { handle; constructor(handle) { this.handle = handle; } abort() { this.close(); } close() { this.handle.close(); } async write(chunk) { try { await this.handle.writeBytes(chunk); } catch (error) { try { this.handle.close(); } catch {} throw error; } } }; export { FileSystemReadableStreamSource, FileSystemWritableSink }; //# sourceMappingURL=streams.mjs.map