# nimnjs

> Schema aware compression of JS object/JSON data. 60% more compressed than json

Latest version **2.2.1** (published 2022-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install nimnjs
pnpm add nimnjs
yarn add nimnjs
bun add nimnjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2022-05-28 |
| First published | 2018-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Amit Gupta |
| Maintainers | amitgupta |
| Keywords | nimn, nimnjs, json, compress, parse, format, msgpack |

## Links

- npm: https://www.npmjs.com/package/nimnjs
- Repository: https://github.com/NaturalIntelligence/nimnjs
- Homepage: https://amitkumargupta.work/nimn/
- Issues: https://github.com/NaturalIntelligence/nimnjs/issues
- npm.io page: https://npm.io/package/nimnjs

## Dependencies (2)

- [nimn-date-parser](https://npm.io/package/nimn-date-parser.md) ^1.0.0
- [nimn_schema_builder](https://npm.io/package/nimn_schema_builder.md) ^1.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.2.1 (latest) — 2022-05-28
- 2.2.0 — 2018-07-03
- 2.1.0 — 2018-06-23
- 2.0.1 — 2018-06-10
- 2.0.0 — 2018-06-10
- 1.3.2 — 2018-04-28
- 1.3.1 — 2018-04-28
- 1.3.0 — 2018-04-26
- 1.2.2 — 2018-03-02
- 1.2.1 — 2018-03-01
- 1.2.0 — 2018-03-01
- 1.1.0 — 2018-02-27
- 1.0.0 — 2018-02-25

## README

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

<a href="https://paypal.me/naturalintelligence"> <img src="static/img/support_paypal.svg" alt="Stubmatic donate button" width="200"/></a>


<img align="right" src="static/img/nimnjs-logo.png" /> 

## Introduction
NIMN JS can parse JS object to nimn data and vice versa. See Nimn [specification](https://github.com/NaturalIntelligence/nimn-spec) for more detail.

## Usages
First install or add to your npm package
```
$npm install nimnjs
```

```js
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](dist/nimn.js) in your HTML to use it in browser.


Check the [demo](https://amitkumargupta.work/nimn/) for instant use. It generates schema automatically with the help of [schema builder](https://github.com/NaturalIntelligence/nimnjs-schema-builder) when sample json is provided.


## Support
Join the [official organization](https://github.com/NaturalIntelligence) on github to support it. It can not only save bandwidth but speed up communication, search and much more.

---
_Source: https://npm.io/package/nimnjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
