1.0.3 • Published 6 years ago

change-name-of-all-keys v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

change-name-of-all-keys

Change the key name of all attributes of an object given a hash, children as well (handy utility)

Install

$ npm install change-name-of-all-keys

Usage

const changeNameOfAllKeys = require('change-name-of-all-keys');

const original_object = {
    '>': 23,
    and: {
        '>': 44,
        '<': 46,
        or: {
            like: 'bye',
            notlike: 'hello'
        }
    }
};

const hash = {
    or: 'Op.or',
    and: 'Op.and',
    '>': 'Op.gt',
    '<': 'Op.lt',
    '>=': 'Op.gte',
    '<=': 'Op.lte',
    like: 'Op.like',
    notlike: 'Op.notLike',
    '=': 'Op.eq',
    '<>': 'Op.n'
};

const resulting_object = appendToAllAttributes(original_object, hash);
console.log(resulting_object);
//=>
{
    'Op.gt': 23,
    'Op.and': {
        'Op.gt': 44,
        'Op.lt': 46,
        'Op.or': {
            'Op.like': 'bye',
            'Op.notLike': 'hello'
        }
    }
};

License

MIT © Fabio Espinosa

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago