🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

change-name-of-all-keys

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

change-name-of-all-keys

Change names of all keys and subkeys given a hash table

1.0.3
latest
npm
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 05 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts