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

0.1.0 • Public • Published

tdeep

A simple way to update deep objects in immutable environments like React or Zustand. Comes with powerful TypeScript!

Installation

npm install --save tdeep
yarn add tdeep
pnpm add tdeep

Usage

import { setState } from "react";
import { tdeep } from "tdeep";

function App() {
  const [data, setData] = useState({
    my: {
      quite: {
        nested: {
          object: true,
          array: [1, 2, 3],
        },
      },
    },
  });

  // ...

  setData(tdeep("my.quite.nested.object", false));
  setData(tdeep("my.quite.nested.object", (value) => !value));
  setData(tdeep("my.quite.nested.array.0", 42));
  setData(tdeep("my.quite.nested.array", [3, 2, 1]));
}

Readme

Keywords

none

Package Sidebar

Install

npm i tdeep

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

9.56 kB

Total Files

6

Last publish

Collaborators

  • juanm04