1.0.2 • Published 8 years ago

find-and-apply v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

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" }]