Sudoo-Buffer

Continuous Integration codecov npm version downloads

:hibiscus: Immutable buffers for JS

Install

yarn add @sudoo/buffer
# Or
npm install @sudoo/buffer --save

Usage

This package provide more feature than the following descriptions.
The usage documents are still working in progress. See source code for more details.

Array Buffer

import { ArrayBuffer } from "@sudoo/buffer";
const buffer: ArrayBuffer<string> = ArrayBuffer.create();
buffer.add(chance.string());
buffer.length; // 1

Number Buffer

import { NumberBuffer } from "@sudoo/buffer";
const buffer: NumberBuffer = NumberBuffer.create();
buffer.add();
buffer.value; // 1

Object Buffer

import { ObjectBuffer } from "@sudoo/buffer";
const buffer: ObjectBuffer = ObjectBuffer.create();
buffer.add('key', 'value');
buffer.add('addIfExist', undefined);
buffer.build(); /* {
    key: 'value',
} */

String Buffer

import { StringBuffer } from "@sudoo/buffer";
const buffer: StringBuffer = StringBuffer.create();
buffer.add('foo');
buffer.add('bar');
buffer.flush(); // foobar