2.0.29 • Published 2 years ago

@jeffriggle/bison v2.0.29

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

bison

bison

A JSON to binary tool. This tool takes in JSON and converts it to a binary structure to save some bytes. This library is intended to serialize a JSON object similar to how you might expect with something like JSON.stringify.

Installing

npm i @jeffriggle/bison

Basic usage

const { encode, decode } = require('@jeffriggle/bison/cjs/index')

const jsonObject = {
    hello: 'World',
    num: 42,
    required: false
    nested: {
        foo: 'bar',
        arr: [42, 15, 'baz']
    }
}

const encoded = encode(jsonObject)
console.log(encoded) // binary structure.
const decoded = decode(encoded)
console.log(decoded) // original object.

Examples

Examples using bison can be found here https://github.com/JeffreyRiggle/bison-examples

Initial testing

All testing has been done on a local development machine, results may vary. To run the tests yourself use the npm run perf:nano through npm run perf:large commands provided by this package.

Encoding

Basic encoding in this case is using a very simple approach

const encoded = Buffer.from(JSON.stringify(obj))
Encode TypeEncode SizeEncode Time
Basic nano120.168547
Bison nano90.668347
Basic small1140.180368
Bison small911.210133
Basic medium5016092.040591
Bison medium47387767.735946
Basic large10032075.178138
Bison large947742133.127045

Decoding

Basic decoding in this case is using a very simple approach

const decoded = JSON.parse(buff.toString('utf8'))
Decode TypeDecode Time
Basic nano65.414897
Bison nano63.667062
Basic small65.364427
Bison small63.256234
Basic medium160.526895
Bison medium135.599895
Basic large216.865982
Bison large176.570844

Totals

TypeTotal time deltaSize delta
nano+1.248035+3
small+1.078428+23
medium-40.768355+27732
large-87.653769+55465

Time differences are Basic - Bison (positive numbers are improvements)

2.0.28

2 years ago

2.0.29

2 years ago

2.0.26

2 years ago

2.0.27

2 years ago

2.0.25

2 years ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.24

2 years ago

2.0.22

2 years ago

2.0.23

2 years ago

2.0.20

2 years ago

2.0.21

2 years ago

2.0.16

3 years ago

2.0.15

3 years ago

2.0.13

3 years ago

2.0.14

3 years ago

2.0.11

3 years ago

2.0.12

3 years ago

2.0.10

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.7

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.0

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago