1.4.1 • Published 10 months ago

@myrotvorets/buffer-stream v1.4.1

Weekly downloads
6
License
MIT
Repository
github
Last release
10 months ago

buffer-stream

Quality Gate Status Build and Test

Converts a Buffer into a Readable Stream.

Since version 1.1.0, it provides a helper to read the entire stream into a Buffer.

Since version 1.3.0, it provides a writable stream that stores the result in a buffer.

Usage

import { BufferStream, WritableBufferStream, streamToBuffer } from '@myrotvorets/buffer-stream';

// BufferStream
const buf = Buffer.from('123');
const stream = new BufferStream(buf);

// streamToBuffer
streamToBuffer(stream).then((buffer) => { /* ... */ })

// WritableBufferStream
const stream = new WritableBufferStream();
stream.write('something', (err) => {
    if (!err) {
        console.log(stream.toString());

        stream.clear(); // Clear the internal buffer
    }
});

await stream.writeP('something else');

See the test directory for usage examples.

1.4.1

10 months ago

1.3.4

2 years ago

1.4.0

2 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.9

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago