visit-json
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

visit-json.js

npm latest package Test

import visitJson, { REMOVE } from "visit-json"
// or
import * as json from "visit-json"
const { visit: visitJson, REMOVE } = json

const object = {
  a: {
    b: [
      2,
      "3",
    ],
  },
}
const newObject = visitJson(object, value => {
  if (typeof value === "number") {
    return value + 2
  }

  return REMOVE
})

console.log(newObject)
// {
//   a: {
//     b: [
//       4,
//     ],
//   },
// }

Package Sidebar

Install

npm i visit-json

Weekly Downloads

6

Version

0.2.2

License

MIT

Unpacked Size

12.4 kB

Total Files

10

Last publish

Collaborators

  • tai-kun