Graphity for TypeScript 3.0.0
    Preparing search index...

    Interface ByteSink

    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.

    interface ByteSink {
        write(chunk: Uint8Array): unknown;
    }
    Index