npm.io
1.0.2 • Published 10 years ago

find-and-apply

Licence
ISC
Version
1.0.2
Deps
0
Vulns
0
Weekly
0
Stars
1

find-and-apply

Recursively search any json structure and make changes at a certain leaf.

Install

npm install find-and-apply

Use

const { findAndApply, isObject } = require("find-and-apply")

findAndApply([
  { foo: "bar" },
  { foo: "baz" }
], candidate => (
  isObject(candidate) && candidate.foo === "baz"
), hit => ({
  foo: "banana"
}))

// [{ foo: "bar" }, { foo: "banana" }]