Skip to content

DanielJDufour/replace-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

replace-key

Replace the Key in an Object

features

  • simple
  • universal support (AMD, CJS, IIFE, and ESM)
  • works in Web Workers

install

npm install replace-key

usage

const replaceKey = require("replace-key");

const obj = { a: 1 };
const old_key = 'a';
const new_key = 'b';

replaceKey(obj, old_key, new_key);
// obj is now { b: 1 }

advanced usage

// using "named params"
replaceKey({ obj, old_key, new_key });
// obj is now { b: 1 }

About

Change the Key in an Object

Resources

License

Stars

Watchers

Forks

Packages

No packages published