1.1.0 • Published 1 year ago

deep-ply v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

deep-ply

A simple javascript library for applying a function deeply.

Installation

npm install deep-ply

Demo

Usage

import { deepPly } from "deep-ply"

const data = {
  id: "1",
  value: "foo",
  items: [
    { id: "1.1", value: "bar", items: [{ id: "1.1.1", value: "qux" }] },
    { id: "1.2", value: "quux" },
  ],
}

const callback = (value, path) => {
  if (path === "/items/0/value") return value.toUpperCase()
  return value
}

deepPly(callback)(data)

// {
//   "id": "1",
//   "value": "foo",
//   "items": [
//     { "id": "1.1", "value": "BAR", "items": [{ "id": "1.1.1", "value": "qux" }] },
//     { "id": "1.2", "value": "quux" }
//   ]
// }
1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago