Class Writer<Type>

Represents an instance used to write unknown type of data.

Here is an example of custom Writer class used to write binary strings:

class BinaryStringWriter extends Writer {

constructor() {
super();
this.binaryString = "";
}

writeUint8Array(array) {
for (let indexCharacter = 0; indexCharacter < array.length; indexCharacter++) {
this.binaryString += String.fromCharCode(array[indexCharacter]);
}
}

getData() {
return this.binaryString;
}
}

Type Parameters

  • Type

Hierarchy (view full)

Implements

Constructors

Properties

Methods

Constructors

Properties

writable: WritableStream<any>

The WritableStream instance.

Methods

  • Retrieves all the written data

    Returns Promise<Type>

    A promise resolving to the written data.

  • Initializes the instance asynchronously

    Parameters

    • Optionalsize: number

      the total size of the written data in bytes.

    Returns Promise<void>

  • Appends a chunk of data

    Parameters

    • array: Uint8Array

      The chunk data to append.

    Returns Promise<void>