{"id":29171888,"url":"https://github.com/leonadler/immutablets","last_synced_at":"2025-07-01T13:08:50.194Z","repository":{"id":16006507,"uuid":"79121590","full_name":"leonadler/immutablets","owner":"leonadler","description":"Immutable state management for TypeScript","archived":false,"fork":false,"pushed_at":"2023-04-17T20:23:59.000Z","size":785,"stargazers_count":6,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-29T04:04:37.905Z","etag":null,"topics":["angular","angular2","decorators","flux","immutable","immutable-datastructures","redux","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonadler.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":"2017-01-16T13:35:52.000Z","updated_at":"2023-03-05T05:13:27.000Z","dependencies_parsed_at":"2024-11-15T12:46:18.407Z","dependency_job_id":null,"html_url":"https://github.com/leonadler/immutablets","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/leonadler/immutablets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonadler%2Fimmutablets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonadler%2Fimmutablets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonadler%2Fimmutablets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonadler%2Fimmutablets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonadler","download_url":"https://codeload.github.com/leonadler/immutablets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonadler%2Fimmutablets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262788710,"owners_count":23364396,"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":["angular","angular2","decorators","flux","immutable","immutable-datastructures","redux","typescript"],"created_at":"2025-07-01T13:08:49.367Z","updated_at":"2025-07-01T13:08:50.172Z","avatar_url":"https://github.com/leonadler.png","language":"TypeScript","readme":"# Performant immutable structures for TypeScript.\n\n[![npm version](https://badge.fury.io/js/immutablets.svg)](https://www.npmjs.com/package/immutablets)\n[![travis build status](https://travis-ci.org/leonadler/immutablets.svg)](https://travis-ci.org/leonadler/immutablets/)\n\nDesigned for use with rxjs observables and Angular, but works without dependencies.\n\n\n## What is an immutable application state?\n\nIn short: If an object A equals object B, all properties of A are equal to the same property of B.\nSince most applications read data way more than modifying it, getting notified of changes\ninstead of comparing values to previous values is way more efficient.\n\nThis plays nicely with angulars change detection, which compares by reference (===) and assumes\nthat any input that receives the same value as before was not changed.\n\n\n## Getting started\n\n```Bash\nnpm install immutablets\n```\n\nDefine your application state as a class decorated with `@Immutable`:\n\n```TypeScript\nimport { Immutable } from 'immutablets';\n\n@Immutable()\nclass ApplicationState {\n    folders: { [id: number]: Folder };\n    files: { [id: number]: File };\n    currentFolder: number;\n\n    openFolder(folderId: number) {\n        this.currentFolder = folderId;\n    }\n\n    filesLoaded(folderId: number, files: File[]) {\n        this.folders = { ...this.folders, [folderId]: { ...this.folders[folderId], files } };\n    }\n}\n```\n\nObserve the application state for changes:\n\n```TypeScript\n@Component({\n    template: `\n        \u003cfile-list [files]=\"(currentFolder | async)?.files\"\u003e\n        \u003c/file-list\u003e`,\n    changeDetection: ChangeDetectionStrategy.OnPush\n})\nclass FolderDetailsComponent {\n    currentFolder: Observable\u003cFolder\u003e;\n    constructor(private appState: ApplicationState) {\n        this.currentFolder = observeChanges(appState, Observable)\n            .map(state =\u003e state.folders[state.currentFolder])\n            .distinctUntilChanged();\n    }\n}\n```\n\n## Write mutation-safe code and get notified when you did not\n\nInstead of forcing you to use a different data structure to store your data, you will be encouraged\nto write mutation-safe code with plain javascript objects and arrays.\n\n### Checking your code for object mutations\n\nIf any method call changes properties of an existing reference\ninstead of creating a new object, a MethodNonImmutableError will be thrown:\n\n```TypeScript\n@Immutable()\nclass BadFolderListImplementation {\n    private folders: Folder[];\n    add(newFolder: Folder) {\n        this.folders.push(newFolder);\n        //           ^ push changes the array, therefore\n        //             a MethodNonImmutableError is thrown.\n    }\n}\n```\n\nWhen the method creates a new object instead of changing an existing one, no error is thrown:\n\n```TypeScript\n    add(newFolder: Folder) {\n        this.folders = [...this.folders, newFolder];\n    }\n```\n\n## Documentation\n\n(work in progress)\n\n* [How to use](docs/how-to-use.md)\n* [@Immutable](docs/immutable-decorator.md)\n* [ImmutableStateStore](docs/immutable-state-store.md)\n* [Utility functions](docs/utility-functions.md)\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonadler%2Fimmutablets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonadler%2Fimmutablets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonadler%2Fimmutablets/lists"}