@adviser/cement - v0.0.0
    Preparing search index...

    Class ConsoleWriterStream

    WritableStream that outputs to console with JSON log-level parsing.

    Decodes stream chunks and attempts to parse as JSON to extract log levels. Routes messages to console.log/warn/error based on parsed level field. Falls back to console.log for non-JSON content. Useful for structured logging.

    const consoleStream = new ConsoleWriterStream();
    const writer = consoleStream.getWriter();

    // JSON with level field
    await writer.write(
    new TextEncoder().encode('{"level":"error","msg":"Failed"}')
    ); // Outputs to console.error

    // Plain text
    await writer.write(
    new TextEncoder().encode('Hello')
    ); // Outputs to console.log

    // Custom console methods
    const custom = new ConsoleWriterStream({
    error: (msg) => saveToFile('error.log', msg)
    });

    Implements

    • WritableStream<Uint8Array>
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    locked: boolean = false

    The locked read-only property of the WritableStream interface returns a boolean indicating whether the WritableStream is locked to a writer.

    MDN Reference

    _writer?: WritableStreamDefaultWriter<Uint8Array<ArrayBufferLike>>

    Methods

    • The abort() method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.

      MDN Reference

      Parameters

      • Optional_reason: unknown

      Returns Promise<void>

    • The getWriter() method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.

      MDN Reference

      Returns WritableStreamDefaultWriter<Uint8Array<ArrayBufferLike>>