Skip to content

💎 when objects become too large, let's turn them into something smaller

Notifications You must be signed in to change notification settings

gabrielcsapo/compress-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compress-object

💎 when objects become too large, let's turn them into something smaller

Npm Version Build Status Dependency Status devDependency Status Coverage Status npm npm

Installation

npm install compress-object --save

Usage

a AMD version of this is available at dist/compress-object.js

const Compress = require('compress-object');
const flattened = ['Gabriel J. Csapo', 22, 'Male', [], ['PayPal', 'Software Engineer']];
const compressor = new Compress({
    name: '',
    age: 0,
    gender: '',
    friends: [],
    job: {
        employer: '',
        position: ''
    }
});

const object = compressor.deserialize(flattened);
const flattenAgain = compressor.serialize(object);

What does it do?

compress-object aims to remove the need for keys in JSON, by having a map to and from the flattened structure

Turning an array of 1000 complex objects (objects that have nsted objects and nested arrays) (373ms)

size before size after
315.04 KB 231.06 KB