GithubHelp home page GithubHelp logo

siloam / nimnjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from naturalintelligence/nimnjs

0.0 0.0 0.0 209 KB

JS implementation of nimn specification

Home Page: http://nimn.in/nimnjs/

License: Other

JavaScript 83.83% HTML 16.17%

nimnjs's Introduction

nimnjs-node

JS implementation of nimn specification. Highly Compressed JS object/JSON. 60% or more compressed than JSON, 40% or more compressed than msgpack

Known Vulnerabilities Travis ci Build Status Coverage Status Try me Twitter URL

Become a Patron! Stubmatic donate button

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 objStructure = {
    type : "list",
    detail : {
        type : "map",
        detail : [{
            name : "name",
            type : "string"
        },{
            name : "age",
            type : "number"
        },{
            name : "isHuman",
            type : "boolean"
        },{
            name : "address",
            type : "string"
        },{
            name : "hobbies",
            type : "list",
            detail : {
                type : "string"
            }
        },{
            name : "project",
            type : "map",
            detail: [{
                name: "title",
                type : "string"
            },{
                name: "description",
                type : "string"
            },{
                name: "status",
                type : "string"
            }
            ]
        }
        ]
    }
}


var schema = nimn.buildSchema(objStructure);

var jData = [{
    "name" : "somename",
    "isHuman" : true,
    "age": 32,
    "address" : "I'll not tell you",
    hobbies : [ 
        null
        , "not reading "+ parser.chars.missingPremitive +" book"
        , "watching \\"+ parser.chars.nilPremitive +" movie"
    ],
    project : {
        title : "nimn",
        //description : "it is 80% smaller",
        status : "rocking"
    }
}]

var nimnDataString = nimn.stringify(schema, jData);
var result = nimn.parse(schema, nimnDataString);
expect(result).toEqual(jData); 

Flexibility

  • You can use old schema to parse nimn data created with old or new schema.
  • You can use new schema to parse nimn data created with old or new schema.

Note that the fields must be added or deleted in the end of the map (object)

  • Fields name can be chaged in the schema used for encoding and decoding. But their type and order must not be changed.

Supported type

  • map : Fixed key value pairs
  • varmap : Variable key value pairs where the values of any key have same structure
  • list : list of similar values
  • boolean : true / false
  • string : Any valid string
  • number : Any valid number

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

Join the official organization on github to support it. It can not only save bandwidth but speed up communication, search and much more.

Users

List of applications and projects using Nimn. (Raise an issue to submit yours)

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.

nimnjs's People

Contributors

amitguptagwl avatar meetall avatar aayushdutt avatar dharshanah avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.