Interface: IStream

March 10, 2023 · View on GitHub

node-taglib-sharp / Exports / IStream

Interface: IStream

Interface for a stream, it wraps around a file descriptor to make reading and writing to files using node IO a lot easier.

Table of contents

Properties

Methods

Properties

canWrite

Readonly canWrite: boolean

Whether or not the stream can be written to


length

Readonly length: number

Number of bytes currently stored in file this stream connects to


position

position: number

Position within the stream

Methods

close

close(): void

Closes the stream

Returns

void


read

read(buffer, offset, length): number

Reads a block of bytes from the current stream and writes the data to a buffer.

Parameters

NameTypeDescription
bufferUint8ArrayWhen this method returns, contains the specified byte array with the values between offset and (offset + length - 1) replaced by the characters read from the current stream
offsetnumberZero-based byte offset in buffer at which to begin storing data from the current stream
lengthnumberThe maximum number of bytes to read

Returns

number

Total number of bytes written to the buffer. This can be less than the number of bytes requested if that number of bytes are not currently available or zero if the end of the stream is reached before any bytes are read


seek

seek(offset, origin): void

Sets the position within the current stream to the specified value.

Parameters

NameTypeDescription
offsetnumberNew position within the stream. this is relative to the origin parameter and can be positive or negative
originSeekOriginSeek reference point SeekOrigin

Returns

void


setLength

setLength(length): void

Sets the length of the current current stream to the specified value.

Parameters

NameTypeDescription
lengthnumberNumber of bytes to set the length of the stream to

Returns

void


write

write(buffer, bufferOffset, length): number

Writes a block of bytes to the current stream using data read from a buffer.

Parameters

NameTypeDescription
bufferByteVector | Uint8ArrayBuffer to write data from
bufferOffsetnumberZero-based byte offset in buffer at which to begin copying bytes to the current stream
lengthnumberMaximum number of bytes to write

Returns

number