[go: up one dir, main page]

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

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i key-remap

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • landau