MCPcopy Create free account
hub / github.com/WinterTC55/iter-streams / write

Function write

samples/12-nodejs-interop.ts:120–134  ·  view source on GitHub ↗
(chunk: Uint8Array | string, options?: WriteOptions)

Source from the content-addressed store, hash-verified

118 },
119
120 async write(chunk: Uint8Array | string, options?: WriteOptions): Promise<void> {
121 if (error) throw error;
122 if (closed) throw new Error('Writer is closed');
123
124 const bytes = typeof chunk === 'string' ? textEncoder.encode(chunk) : chunk;
125 const buffer = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
126
127 const canContinue = writable.write(buffer);
128 byteCount += buffer.length;
129
130 if (!canContinue) {
131 await waitForDrain(options?.signal);
132 if (error) throw error;
133 }
134 },
135
136 async writev(chunks: (Uint8Array | string)[], options?: WriteOptions): Promise<void> {
137 for (const chunk of chunks) {

Callers

nothing calls this directly

Calls 2

waitForDrainFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected