4.6 KiB
nimnjs-node
JS implementation of nimn specification. Highly Compressed JS object/JSON. 60% or more compressed than JSON, 40% or more compressed than msgpack
Introduction
NIMN JS can parse JS object to nimn data and vice versa. See Nimn specification for more detail.
Usages
First install or add to your npm package
$npm install nimnjs
var nimn = require("nimnjs");
var schema = {
"name": "string",
"age": "number",
"human": "boolean",
"projects": [{
"name": "string",
"decription": "string"
}]
}
var nimnInstance = new nimn();
nimnInstance.addSchema(schema);
var data = {
"name" : "amit",
"age" : 32,
"human" : true,
"projects" : [
{
"name": "some",
"decription" : "some long description"
}
]
}
var result = nimnInstance.encode(data);//Æamitº32ÙÇÆsomeºsome long description
result = nimnInstance.decode(result);
expect(result).toEqual(data);
For date compression
var nimnDateparser = require("nimn-date-parser");
//generate schema and data
var nimnInstance = new nimn();
nimnInstance.addDataHandler("date",function(val){
return nimnDateparser.parse(val,true,true,true)
},function(val){
return nimnDateparser.parseBack(val,true,true,true)
});
nimnInstance.addSchema(schema); //add after adding all data handlers
var nimndata = nimnInstance.encode(data);
Encode enum type
var nimnInstance = new nimn();
nimnInstance.addDataHandler("status",null,null,{
"M" : "Married",
"S" : "Single"
});
nimnInstance.addSchema(schema); //add after adding all data handlers
Just mark a data type
var nimnInstance = new nimn();
nimnInstance.addDataHandler("image");
nimnInstance.addSchema(schema); //add after adding all data handlers
Include dist in your HTML to use it in browser.
Check the demo for instant use. It generates schema automatically with the help of schema builder when sample json is provided.
Support
I need your expert advice, and contribution to grow nimn (निम्न) so that it can support all mazor languages. Please join the official organization on github to support it. And ask your friends, and colleagues to give it a try. It can not only save bandwidth but speed up communication, search and much more.
Worth to mention
-
imglab : Web based tool to label images for object. So that they can be used to train dlib or other object detectors. You can integrate 3rd party libraries for fast labeling.
-
अनुमार्गक (anumargak) : The fastest router for node web servers.
-
Stubmatic : A stub server to mock behaviour of HTTP(s) / REST / SOAP services.
-
fastify-xml-body-parser : Fastify plugin / module to parse XML payload / body into JS object using fast-xml-parser.
-
fast-lorem-ipsum : Generate lorem ipsum words, sentences, paragraph very quickly.
-
Grapes : Flexible Regular expression engine which can be applied on char stream. (under development)
-
fast XML Parser : Fastest pure js XML parser for xml to js/json and vice versa. And XML validation.