JSPM

key-replace

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q19124F
  • License MIT

Replace object keys with String.prototype.replace

Package Exports

  • key-replace

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (key-replace) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

key-replace Build Status

Replace object keys with String.prototype.replace

Install

$ npm install --save key-replace

Usage

const keyReplace = require('key-replace');
const obj = {
    foo: 'bar'
};

keyReplace(obj, 'fo', 'y');
//=> {yo: 'bar'}

keyReplace(obj, 'fo', str => {
    return str.toUpperCase();
});
//=> {FOo: bar}

API

keyReplace(input, search, replace)

Returns a new object.

input

Required
Type: object

The object which keys will be replaced.

Required
Type: string or regexp

Search for mathching substring that will be replaced.

replace

Required
Type: string or function

Replacing the mathing substring.

License

MIT © Andreas Gillström