Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielcsapo/compress-object
💎 when objects become too large, let's turn them into something smaller
https://github.com/gabrielcsapo/compress-object
javascript mapping objects utility
Last synced: 21 days ago
JSON representation
💎 when objects become too large, let's turn them into something smaller
- Host: GitHub
- URL: https://github.com/gabrielcsapo/compress-object
- Owner: gabrielcsapo
- Created: 2016-06-20T02:32:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-13T07:13:07.000Z (almost 7 years ago)
- Last Synced: 2024-04-30T00:22:25.694Z (6 months ago)
- Topics: javascript, mapping, objects, utility
- Language: JavaScript
- Homepage: https://gabrielcsapo.github.io/compress-object
- Size: 907 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# compress-object
> 💎 when objects become too large, let's turn them into something smaller
[![Npm Version](https://img.shields.io/npm/v/compress-object.svg)](https://www.npmjs.com/package/compress-object)
[![Build Status](https://travis-ci.org/gabrielcsapo/compress-object.svg?branch=master)](https://travis-ci.org/gabrielcsapo/compress-object)
[![Dependency Status](http://starbuck.gabrielcsapo.com/badge/github/gabrielcsapo/compress-object/status.svg)](http://starbuck.gabrielcsapo.com/github/gabrielcsapo/compress-object)
[![devDependency Status](http://starbuck.gabrielcsapo.com/badge/github/gabrielcsapo/compress-object/dev-status.svg)](http://starbuck.gabrielcsapo.com/github/gabrielcsapo/compress-object#info=devDependencies)
[![Coverage Status](https://lcov-server.gabrielcsapo.com/badge/github%2Ecom/gabrielcsapo/compress-object.svg)](https://lcov-server.gabrielcsapo.com/coverage/github%2Ecom/gabrielcsapo/compress-object)
[![npm](https://img.shields.io/npm/dt/compress-object.svg?maxAge=2592000)]()
[![npm](https://img.shields.io/npm/dm/compress-object.svg?maxAge=2592000)]()## Installation
```
npm install compress-object --save
```## Usage
> a AMD version of this is available at dist/compress-object.js
```javascript
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|