value-replace

1.0.0 • Public • Published

value-replace Build Status

Replace object values with String.prototype.replace

Install

$ npm install --save value-replace

Usage

const valueReplace = require('value-replace');
const obj = {
	foo: 'bar'
};

valueReplace(obj, 'bar', 'baz');
//=> {foo: 'baz'}

valueReplace(obj, 'ba', str => str.toUpperCase());
//=> {foo: 'BAr'}

API

valueReplace(input, search, replace)

Returns a new object.

input

Required
Type: object

The object which values will be replaced.

search

Required
Type: string or regexp

Search for matching substring that will be replaced.

replace

Required
Type: string or function

Replacing the matching substring.

Related

  • array-replace - Replace array values with String.prototype.replace
  • key-replace - Replace object key with String.prototype.replace

License

MIT © Andreas Gillström

/value-replace/

    Package Sidebar

    Install

    npm i value-replace

    Weekly Downloads

    3

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • gillstrom