{"id":29962066,"url":"https://github.com/foblex/f-mutator","last_synced_at":"2026-07-17T14:34:22.908Z","repository":{"id":306499366,"uuid":"1023028597","full_name":"Foblex/f-mutator","owner":"Foblex","description":"@foblex/mutator is a small TypeScript library built on top of signal() from @angular/core. It allows you to mutate state (create / update / delete), supports undo/redo with history limits, and emits semantic updates via a notifier string.","archived":false,"fork":false,"pushed_at":"2025-07-25T20:46:09.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-26T03:45:21.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Foblex.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,"zenodo":null}},"created_at":"2025-07-20T11:25:46.000Z","updated_at":"2025-07-25T20:46:13.000Z","dependencies_parsed_at":"2025-07-26T03:55:56.093Z","dependency_job_id":null,"html_url":"https://github.com/Foblex/f-mutator","commit_stats":null,"previous_names":["foblex/f-mutator"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Foblex/f-mutator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foblex%2Ff-mutator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foblex%2Ff-mutator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foblex%2Ff-mutator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foblex%2Ff-mutator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Foblex","download_url":"https://codeload.github.com/Foblex/f-mutator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foblex%2Ff-mutator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268629880,"owners_count":24281173,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-03T23:44:11.147Z","updated_at":"2026-07-17T14:34:22.903Z","avatar_url":"https://github.com/Foblex.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @foblex/mutator\n\n\u003e [!IMPORTANT]\n\u003e Building state and history for a Foblex Flow editor? Use the built-in\n\u003e [Managed Flow State plugin](https://flow.foblex.com/examples/state), available in\n\u003e `@foblex/flow` v19.1 through `provideFFlow(withFlowState())`. It provides typed graph\n\u003e records, gesture-aware batching, undo/redo, viewport history, and persistable snapshots.\n\u003e\n\u003e `@foblex/mutator` remains available as a standalone state utility, but new Foblex Flow\n\u003e state integrations should use Managed Flow State.\n\n\u003e Lightweight Angular Signals state engine with deep patching, undo/redo, and semantic notifier.\n\n`@foblex/mutator` is a small TypeScript library built on top of `signal()` from `@angular/core`.  \nIt allows you to mutate state (`create / update / delete`), supports undo/redo with history limits, and emits semantic updates via a notifier string.\n\n|                     |                                   |\n|---------------------|-----------------------------------|\n| **Framework**       | Angular 17 + (Signals)            |\n| **Size**            | \u003c 2 KB min+gzip                   |\n| **Undo limit**      | 50 (customizable via constructor) |\n| **License**         | MIT                               |\n\n---\n\n## 🚀 Quick Start\n\n```bash\nnpm i @foblex/mutator @angular/core\n```\n\n```ts\nimport { effect, inject, Injectable } from '@angular/core';\nimport { Mutator } from '@foblex/mutator';\n\n// 1. Define your state shape\ninterface FlowState {\n  nodes: Record\u003cstring, { x: number; y: number }\u003e;\n}\n\n// 2. Create a store class extending Mutator\n@Injectable({ providedIn: 'root' })\nclass FlowStore extends Mutator\u003cFlowState\u003e {}\n\n// 3. Inject and initialize the store\nconst flow = inject(FlowStore);\nflow.initialize({ nodes: {} });\n\n// 4. React to changes with `effect()`\neffect(() =\u003e {\n  const { version, notifier } = flow.changes();\n  console.log('Changed (v' + version + ') by', notifier);\n  console.table(flow.getSnapshot().nodes);\n});\n\n// 5. Perform operations\nflow.create({ nodes: { n1: { x: 0, y: 0 } } }, 'init');\nflow.update({ nodes: { n1: { x: 100, y: 100 } } }, 'move');\nflow.update({ nodes: { n1: { y: 200 } } }, 'drag');\nflow.undo(); // ⬅️ back to y: 100\nflow.redo(); // ➡️ forward to y: 200\n```\n\n---\n## 🔧 API Reference\n\n| Method                                   | Description                                              |\n|------------------------------------------|----------------------------------------------------------|\n| `initialize(base)`                       | Set initial state and clears history                     |\n| `create(patch, notifier?)`               | Adds new data                                            |\n| `update(patch, notifier?)`               | Updates existing fields (deep merge)                     |\n| `delete(patch, notifier?)`               | Removes keys deeply                                      |\n| `undo() / redo()`                        | Undo / redo one step                                     |\n| `getSnapshot()`                          | Current state (base + stack)                             |\n| `changes: Signal\u003c{ version; notifier }\u003e` | Version + source of change                               |\n| `canUndo / canRedo: Signal\u003cboolean\u003e`     | Live flags for UI buttons                                |\n\n### Types\n\n```ts\ninterface MutatorChange {\n  version: number;\n  notifier: string | null;\n}\n\ntype DeepPartial\u003cT\u003e = {\n  [K in keyof T]?: T[K] extends object ? DeepPartial\u003cT[K]\u003e : T[K];\n};\n```\n\n---\n\n## ⚙️ Undo Limit\n\n```ts\nprovideMutator({\n  limit: 100, // Default is 50\n})\n```\n\n---\n\n## 📄 License\n\nMIT © Foblex\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoblex%2Ff-mutator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoblex%2Ff-mutator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoblex%2Ff-mutator/lists"}