object-rename

0.1.1 • Public • Published

object-rename

Rename an object's keys using a map

const rename = require('object-rename')
 
var object = { foo: 3, bar: 42, baz: 101 }
var keymap = { foo: 'lorem', bar: 'ipsum' }
var result = rename(object, keymap)
 
console.log(result) // -> { lorem: 3, ipsum: 42, baz: 101 }

This module exports the rename function, which takes two arguments:

  • object: The object whose keys are to be renamed
  • keymap: An map-like object whose keys correspond to the new keys to be renamed to

rename returns a copy of object with the keys renamed as described by keymap.

install

npm install object-rename

license

MIT

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i object-rename

      Weekly Downloads

      1

      Version

      0.1.1

      License

      MIT

      Last publish

      Collaborators

      • semibran