Wondering what’s next for npm?Check out our public roadmap! »

    key-remap

    1.0.0 • Public • Published

    Build Status

    key-remap

    Remaps a values from an object to specified keys

    /**
     * Remaps a values from an object to specified keys
     *
     * @param {object} keymap 
     * @param {object} obj 
     *
     * @return {object} 
     */
    function keyRemap(keymap, obj) { ... }

    Install

    npm i -S key-remap

    Usage

    var assert = require('assert');
    var keyRemap = require('key-remap');
    var is = require('is-predicate');
     
    var keymap = {
      nameKey: 'name',
      ageKey: 'age',
      missingKey: 'missing'
    };
     
    var obj = {
      name: 'Trevor',
      age: 28
    };
     
    remapped = keyRemap(keymap, obj);
     
    assert(is.object(remapped)); // true
    assert.equal(remapped.nameKey, obj.name); // true
    assert(is.not.exists(remapped.missingKey)); // true

    Install

    npm i key-remap

    DownloadsWeekly Downloads

    4

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • avatar