{"id":14987517,"url":"https://github.com/mutativejs/zustand-mutative","last_synced_at":"2025-04-13T02:21:00.180Z","repository":{"id":240433813,"uuid":"799238441","full_name":"mutativejs/zustand-mutative","owner":"mutativejs","description":"A Mutative middleware for Zustand enhances the efficiency of immutable state updates.","archived":false,"fork":false,"pushed_at":"2024-12-30T16:06:03.000Z","size":202,"stargazers_count":90,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T09:09:29.289Z","etag":null,"topics":["immutability","immutable","mutative","zustand"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mutativejs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-11T14:43:36.000Z","updated_at":"2025-03-13T08:45:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"26ce52d7-b7a5-4493-887c-d597956a09fb","html_url":"https://github.com/mutativejs/zustand-mutative","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"5491146746de6ce4ee3d9831afdb7455a3aa34a7"},"previous_names":["mutativejs/zustand-mutative"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutativejs%2Fzustand-mutative","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutativejs%2Fzustand-mutative/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutativejs%2Fzustand-mutative/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutativejs%2Fzustand-mutative/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mutativejs","download_url":"https://codeload.github.com/mutativejs/zustand-mutative/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654667,"owners_count":21140340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["immutability","immutable","mutative","zustand"],"created_at":"2024-09-24T14:14:52.049Z","updated_at":"2025-04-13T02:21:00.147Z","avatar_url":"https://github.com/mutativejs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zustand-mutative\n\n![Node CI](https://github.com/mutativejs/zustand-mutative/workflows/Node%20CI/badge.svg)\n[![npm](https://img.shields.io/npm/v/zustand-mutative.svg)](https://www.npmjs.com/package/zustand-mutative)\n![license](https://img.shields.io/npm/l/zustand-mutative)\n\nA [Mutative](https://github.com/unadlib/mutative) middleware for Zustand enhances the efficiency of immutable state updates.\n\nWith the Mutative middleware, you can simplify the handling of immutable data in Zustand in a mutable way, allowing you to use immutable state more conveniently.\n\n`zustand-mutative` is 2-6x faster than zustand with spread operation, more than 10x faster than `zustand/middleware/immer`. [Read more about the performance comparison in Mutative](https://mutative.js.org/docs/getting-started/performance).\n\n## Benchmarks\n\nMeasure(ops/sec) to update 50K arrays and 1K objects, bigger is better([view source](./scripts/benchmark.ts)). [Mutative v1.1.0 vs Immer v10.1.1]\n\n![Benchmark](benchmark.jpg)\n\n```\nZustand with Mutative - Update big array and object x 5,169 ops/sec ±2.09% (85 runs sampled)\nZustand with Immer - Update big array and object x 251 ops/sec ±0.40% (92 runs sampled)\n\nThe fastest method is Zustand with Mutative - Update big array and object\n```\n\n## Installation\n\nIn order to use the Mutative middleware in Zustand, you will need to install Mutative and Zustand as a direct dependency.\n\n```bash\nnpm install zustand-mutative zustand mutative\n# Or use any package manager of your choice.\n```\n\n## Usage\n\n```typescript\nimport { create } from 'zustand';\nimport { mutative } from 'zustand-mutative';\n\ntype State = {\n  count: number;\n};\n\ntype Actions = {\n  increment: (qty: number) =\u003e void;\n  decrement: (qty: number) =\u003e void;\n};\n\nexport const useCountStore = create\u003cState \u0026 Actions\u003e()(\n  mutative((set) =\u003e ({\n    count: 0,\n    increment: (qty: number) =\u003e\n      set((state) =\u003e {\n        state.count += qty;\n      }),\n    decrement: (qty: number) =\u003e\n      set((state) =\u003e {\n        state.count -= qty;\n      }),\n  }))\n);\n```\n\n### Mutative Options\n\n- [Strict mode](https://mutative.js.org/docs/advanced-guides/strict-mode)\n- [Auto Freeze](https://mutative.js.org/docs/advanced-guides/auto-freeze)\n- [Marking data structure](https://mutative.js.org/docs/advanced-guides/mark)\n\n\n## Credits\n`zustand-mutative` is inspired by `zustand/middleware/immer`. \n\n## License\n`zustand-mutative` is [MIT licensed](https://github.com/mutativejs/zustand-mutative/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutativejs%2Fzustand-mutative","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmutativejs%2Fzustand-mutative","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutativejs%2Fzustand-mutative/lists"}