Preparing search index...

    Stream interface for writing to subprocess stdin.

        const Subprocess = await import('LensStudio:Subprocess');

    // Writable is the stdin stream of a Subprocess.
    // Method: write(data: Uint8Array | string) => number (bytes written)

    const proc = Subprocess.Subprocess.create('cat', [], {} as any);

    this.connections.push(
    proc.stdout.connect((data: Editor.Buffer) => {
    console.log(`cat echoed back: ${data.toString().length} bytes`);
    })
    );

    this.connections.push(
    proc.onExit.connect((code: number) => {
    console.log(`cat exited with code: ${code}`);
    })
    );

    proc.start();

    // Write a string to stdin; returns number of bytes written
    const bytesWritten = proc.stdin.write('Hello from Writable\n');
    console.log(`Writable.write returned: ${bytesWritten} bytes written`);

    // Can also write Uint8Array
    const binaryData = new Uint8Array([72, 101, 108, 108, 111, 10]); // "Hello\n"
    const bytesWritten2 = proc.stdin.write(binaryData);
    console.log(`Writable.write (binary): ${bytesWritten2} bytes written`);

    // Kill after writing
    proc.kill();

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Write data to the stream and return the number of bytes written.

      Parameters

      • data: string | Uint8Array

      Returns number