1.0.0 • Published 4 years ago

json-key-aliases v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

json-key-aliases

A simple library to compress your Json size

N|Solid

By Muhammad Abdullah Qamar @ QNAR-Dev

A simple library , can be used to

  • compress your DB size

  • increase data transfer speed

  • less network bandwidth consumption

Features

  • get aliases for a key

  • get key for an aliases

  • convert object to keys (which is previously converted to aliases as keys )

  • convert object to aliases

Installation

npm install json-key-aliases

Usage

First Thing First

//initialize library with a prototype object OR a json file 
//prototype object is like schema 
//see an example in prototype.json file
const { initialize } = require('json-key-aliases');
const prototype = require('./prototype.json');
initialize(prototype);

// do stuff
....

Then you can use convertObjectToAliases() to convert the object's key to aliases

Returns an object with keys converted to aliases

const { initialize, convertObjectToAliases } = require('json-key-aliases');
.....
...

const convertedObject  = convertObjectToAliases(collection, object)

and when you want the converted object in it's original form use convertObjectToKeys()

Returns an object with keys converted to original keys from aliases

const { initialize, convertObjectToKeys } = require('json-key-aliases');
.....
...

const originalObject  = convertObjectToKeys(collection, object)

.......MORE TO COME ........ I'll write the remainig docs when i get some free time Please refer to the example.js for a basic usage example

Enjoy !