Where Graph.writeTo puts the bytes of a graph: anything with a write(chunk) method that
takes a Uint8Array. That is a Node.js Writable such as a file stream, a
WritableStreamDefaultWriter, or a collector of one's own. It is the counterpart of Java's
OutputStream.
The graph passes its bytes in a few chunks and ignores what write returns: a Node.js stream
buffers past its high-water mark, and the promise of a stream writer is not awaited. A chunk is
never changed after it is passed, so the sink may keep it instead of copying it. On a
little-endian platform, the chunks after the header are views of the graph's own arrays, which
the sink must not change. A write that throws ends the writing with its error.
Only a write that throws fails the call, as Java's IOException does. A Node.js stream reports
its errors through its 'error' event, and a WritableStreamDefaultWriter through its promises
(writer.closed, writer.close()), after the call has returned. The caller must watch these, as
Node.js otherwise ends the process on such an error. For an error that fails the call itself, use
a sink that writes synchronously, such as one that calls fs.writeSync.
Where Graph.writeTo puts the bytes of a graph: anything with a
write(chunk)method that takes aUint8Array. That is a Node.jsWritablesuch as a file stream, aWritableStreamDefaultWriter, or a collector of one's own. It is the counterpart of Java'sOutputStream.The graph passes its bytes in a few chunks and ignores what
writereturns: a Node.js stream buffers past its high-water mark, and the promise of a stream writer is not awaited. A chunk is never changed after it is passed, so the sink may keep it instead of copying it. On a little-endian platform, the chunks after the header are views of the graph's own arrays, which the sink must not change. Awritethat throws ends the writing with its error.Only a
writethat throws fails the call, as Java'sIOExceptiondoes. A Node.js stream reports its errors through its'error'event, and aWritableStreamDefaultWriterthrough its promises (writer.closed,writer.close()), after the call has returned. The caller must watch these, as Node.js otherwise ends the process on such an error. For an error that fails the call itself, use a sink that writes synchronously, such as one that callsfs.writeSync.