JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34
  • Score
    100M100P100Q60033F

deep replace objects using property string, regex, fn match

Package Exports

  • deep-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 (deep-replace) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

🕳 deep-replace

NPM version MIT License fliphub flipfam

deep replace objects using property string, regex, fn match

📦 usage

yarn add deep-replace
npm i deep-replace --save
const deepReplace = require('deep-replace')

📘 examples

const {match} = require('deep-replace')

// obj, valueTest, propertyTest, decoratorFn
const fixture = {
  value: 'string',
  nested: {
    again: {
      again: 'string',
      object: {},
      array: [],
    },
  },
}

const valueTest = (value) => typeof value === 'string'
const propertyTest = null
const decorator = ({val, obj, prop}) => {
  obj[prop] = val + ' added me!'
}

match(object, valueTest, propertyTest, decorator)

// comes out as
// fixture.nested.again.again === 'string added me!'
// fixture.value === 'string added me!'