unm

unmerge

Generate multiple versions of an object depending on a list or specific property. Can be easily used for writing dev/prod configurations or handling translations inside an object.

Showing:

Popularity

Downloads/wk

0

Maintenance

No Maintenance Data Available

Package

Dependencies

1

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

unmerge

Generate multiple versions of an object depending on a list or specific property. Can be easily used for writing dev/prod configurations or handling translations inside an object.

Examples :

1 - With a list of criterias :

const unmerge = require('unmerge');
const data = {
    "person": {
        "name": 'Johnny',
        "age": 33,
        "nationality": {
          "fr": "Anglais",
          "en": "English"
        }
    },
};

const output = unmerge.byList(['en', 'fr'], data);
/**
output:
{ en: { person: { name: 'Johnny', age: 33, nationality: 'English' } },
  fr: { person: { name: 'Johnny', age: 33, nationality: 'Anglais' } } }
*/

2 - With a specific criteria (single output) :

const unmerge = require('unmerge');
const data = {
    "person": {
        "name": 'Johnny',
        "age": 33,
        "nationality": {
          "fr": "Anglais",
          "en": "English"
        }
    },
};

const output = unmerge.byProperty('en', data);
/**
output:
{ person: { name: 'Johnny', age: 33, nationality: 'English' } }
*/

3 - Using one of the object's property to unmerge :

const unmerge = require('unmerge');
const data = {
    "env": ['prod', 'dev'],
    "config": {
        "basePath": './',
        "scripts": {
          "dev": "./scripts/",
          "prod": "./build/minified/"
        }
    },
};

const output = unmerge.byList('env', data);
/**
output:
{ prod: { config: { basePath: './', scripts: './build/minified/' } },
  dev: { config: { basePath: './', scripts: './scripts/' } } }

*/

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial