Skip to content

tjconcept/js-rename-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rename-key

Rename a single key in an object

Installation

// npm
$ npm install rename-key

Usage

var renameKey = require('rename-key');

var pets = { hans:  'cat', hugo: 'dog' };

// as a function
renameKey(pets, 'hans', 'per'); // { hugo: 'dog', per: 'cat' }
pets; // { hugo: 'dog', per: 'cat' }

// as a method
pets.renameKey = renameKey;
pets.renameKey('hugo', 'superman'); // { superman: 'dog', per: 'cat' }

Alters the object "by reference" and returns the object.

License

MIT © Thomas Jensen

About

Rename key in object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published