BufferBuilder
Provides an efficient builder for Buffers and utility methods to interact with them.
npm i ts-bufferbuilder --save
Merging buffers
Buffers and strings can be merged into a buffer using the append method. It supports the same parameter-types as the buffer-constructor.
; bufferBuilder.appendnew Buffer"Any Buffer";bufferBuilder.append"Any String";bufferBuilder.append"Any Èncoding", "latin1"; ;
Note that this is more efficient than other implementations out there since it only combines the parts into a single buffer when needed. After they are combined the parts are discarded. You can continue to append after the parts are joined creating new parts.
isBuffer
Utility method that detects buffers.
// Detect buffersassert; // ... and nothing elseassert;assert;assert;assert;assert;assert;assert;
toReadable
Turn a buffer into a Readable-Stream
BufferBuilder;
Or
;
toWritable
Create a writable that stores written data into the BufferBuilder
inputStream;
Note that multiple writable-streams can be created for the same BufferBuilder. Closing the writable has no effect on the BufferBuilder.
receive
Reads all remaining data from an input stream.
;