2.3.0 • Published 9 days ago

nibs v2.3.0

Weekly downloads
-
License
-
Repository
-
Last release
9 days ago

Nibs for JavaScript

This is a generic nibs serializtion implementaion for any modern JavaScript runtime.

Unit Tests

npm version

Install

npm i nibs

Usage

Nibs is packaged as an ES module. You can import the exports individually:

import { 
    encode, // JS Value -> Nibs Uint8Array
    decode, // Nibs Uint8Array -> Lazy JS Value
} from 'nibs'

Or you can grab the entire namespace:

import * as Nibs from 'nibs'

Encoding turns any supported JS value into a memory buffer.

const encoded = Nibs.encode({ hello: "world" })

Decoding turns any memory buffer into a nibs object.

const decoded = decode(encoded)

// All nibs maps decode to JavaScript objects.
// It doesn't matter of you used a map or an object when encoding.
// This does mean non-string keys get stringified.
const hello = decoded.hello

Lazy Reading

The JS implementation of nibs takes advantage getter functions to make objects and arrays appear like normal, but only decode when properties are actually read. It will cache the result as you traverse an object and replace the getter with the decoded value.

2.3.0

9 days ago

2.2.1

10 days ago

2.2.2

10 days ago

2.0.9

10 days ago

2.2.0

7 months ago

2.0.7

10 months ago

2.0.6

10 months ago

2.0.8

10 months ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.1.0

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago