:hibiscus: Immutable buffers for JS
yarn add @sudoo/buffer
# Or
npm install @sudoo/buffer --save
This package provide more feature than the following descriptions.
The usage documents are still working in progress. See source code for more details.
import { ArrayBuffer } from "@sudoo/buffer";
const buffer: ArrayBuffer<string> = ArrayBuffer.create();
buffer.add(chance.string());
buffer.length; // 1
import { NumberBuffer } from "@sudoo/buffer";
const buffer: NumberBuffer = NumberBuffer.create();
buffer.add();
buffer.value; // 1
import { ObjectBuffer } from "@sudoo/buffer";
const buffer: ObjectBuffer = ObjectBuffer.create();
buffer.add('key', 'value');
buffer.add('addIfExist', undefined);
buffer.build(); /* {
key: 'value',
} */
import { StringBuffer } from "@sudoo/buffer";
const buffer: StringBuffer = StringBuffer.create();
buffer.add('foo');
buffer.add('bar');
buffer.flush(); // foobar