🚀 DAY 1 OF LAUNCH WEEK: Reachability for Ruby Now in Beta.Learn more
Socket
Book a DemoInstallSign in
Socket

superjsonatural

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superjsonatural

SuperJSONatural ⚡⚡⚡ < ~9kB | JSON or Buffer with TypedArray, faster than CBOR & JSON and msgpackr in some case.

latest
Source
npmnpm
Version
3.2.0
Version published
Maintainers
1
Created
Source

SuperJSONatural ~9kB

Truly one of the world faster serializer/parser on the web

SuperJSONatural branding logo

Information :mag:

MIT

JSON yet, somehow lighter & faster with the support of all JS TypedArray! It uses a Base64 optimized algorithm... when you use stringify and parse

And for pack/unpack usage, it is binary serialization which use a JSON tree and lookup table which refer to a buffer appended to the json also encoded inside a buffer using TextEncoder(), up to 5x faster and somehow significally faster than the trusted CBOR-X while being 3.5x lighter! Check the demo ;)

If you use larger TypedArray than buffer, simply use pack/unpack and work with ArrayBuffer. Meanwhile if you can't, the good old stringify/parse function will works fine based on String!

npm

DEMO : Go to codepen.io :sparkles:

Performances ( 1000 x 16kB )

NPM PackagePackingUnpacking
OURS182ms144ms
CBOR-X202ms (+8%)246ms (+70%)

Stringify takes 92ms while parsing take 255ms when it comes to working with string instead of the above BytesArray packing/unpacking methods, still worth the move!

Install :package:

Download it from NPM easily

Run :

+ npm install superjsonatural

And you get that piece of technology for JSON parsing!

How to use it? :wrench:


import SuperJSONatural from "superjsonatural"; // In node.js
/* OR */
var SuperJSONatural = window.SuperJSONatural; // Use the minified version for browser (> safari 10 & > Chrome 51)

var data = {
    name: "Prof. Bernice Champlin Jr.",
    male: true,
    female: false,
    timestamp: Date.now(),
    hair: Uint8Array.of(0, 55, 77, 65, 9, 1, 1, 1, 1, 200, 44, 22, 9, 0),
    email: "stevie.conn@luettgen.com",
    phone: 3476774277,
    description: "Et voluptatem incidunt repellat. Qui laboriosam quis accusamus optio sed. Non qui qui quasi aliquid.",
	other: {
		ANARRAY: ["lol", 99],
		prop: 992,
		str: "str",
		hair: Uint32Array.of(999)
	}
};

// It will be a string when encoded, always
var encoded = SuperJSONatural().stringify(data);
var decoded = SuperJSONatural().parse(encoded);
console.log(data, encoded, decoded)

// NEW!!! It will be a Uint8Array (Like a bytes array buffer)
var encoded = SuperJSONatural().pack(data);
var decoded = SuperJSONatural().unpack(encoded);
console.log(data, encoded, decoded)

Keywords

superjsonatural

FAQs

Package last updated on 07 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts