0.1.0 • Published 2 years ago

replace-key v0.1.0

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
2 years ago

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 }