{"id":17342705,"url":"https://github.com/wkornewald/ts-immutable-struct","last_synced_at":"2026-02-07T21:32:31.837Z","repository":{"id":57380803,"uuid":"95320867","full_name":"wkornewald/ts-immutable-struct","owner":"wkornewald","description":"TypeScript package for using immutable.js with type-safe cursors and a central event system (as a Redux alternative)","archived":false,"fork":false,"pushed_at":"2020-07-17T11:24:34.000Z","size":87,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T12:53:48.308Z","etag":null,"topics":["cursor","cursors","events","immutable","immutablejs","typescript"],"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/wkornewald.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}},"created_at":"2017-06-24T20:24:49.000Z","updated_at":"2020-09-04T04:08:41.000Z","dependencies_parsed_at":"2022-09-26T16:41:18.528Z","dependency_job_id":null,"html_url":"https://github.com/wkornewald/ts-immutable-struct","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/wkornewald/ts-immutable-struct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkornewald%2Fts-immutable-struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkornewald%2Fts-immutable-struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkornewald%2Fts-immutable-struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkornewald%2Fts-immutable-struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wkornewald","download_url":"https://codeload.github.com/wkornewald/ts-immutable-struct/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkornewald%2Fts-immutable-struct/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29208712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T20:33:12.493Z","status":"ssl_error","status_checked_at":"2026-02-07T20:30:47.381Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cursor","cursors","events","immutable","immutablejs","typescript"],"created_at":"2024-10-15T16:06:42.370Z","updated_at":"2026-02-07T21:32:31.824Z","avatar_url":"https://github.com/wkornewald.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-immutable-struct\n\n[![npm version](https://badge.fury.io/js/ts-immutable-struct.svg)](https://badge.fury.io/js/ts-immutable-struct)\n[![NPM downloads](https://img.shields.io/npm/dm/ts-immutable-struct.svg?style=flat)](https://npmjs.org/package/ts-immutable-struct)\n[![Build Status](https://travis-ci.org/wkornewald/ts-immutable-struct.svg?branch=master)](https://travis-ci.org/wkornewald/ts-immutable-struct)\n\n`ts-immutable-struct` is a TypeScript package for using `immutable.js` with type-safe cursors\nand simple event tracking to allow distinguishing between user-initiated state changes and\ninternal state changes (e.g. to sync state).\n\nThe emphasis here is on type-safety.\n\nThis package is inspired by [immstruct](https://github.com/omniscientjs/immstruct), but uses references for everything.\n\nReact users will want to combine this with [ts-react-struct](https://github.com/wkornewald/ts-react-struct), so\n`shouldComponentUpdate()` works with `ts-immutable-struct` cursors.\n\n## Getting started\n\nInstall the package:\n```sh\nnpm install --save ts-immutable-struct\n```\n\nInitialize the global state struct:\n```typescript\nimport {Struct} from 'ts-immutable-struct'\n\nlet data = Struct({\n  a: 5,\n  b: 'hey',\n  c: null as string | null,\n  d: [1, 2, 3],\n  e: [true, true, false],\n  f: ['a', 'b', 'c'],\n  g: [{a: 40, b: ['d']}, {a: 50, b: ['e']}],\n  l: [[60]],\n  o: {f: 65},\n  da: new Date(),\n})\n\ndata.observe((event, oldVal, newVal) =\u003e {\n  // Handle state changes (oldVal and newVal are both cursors, so you'll need to deref())\n})\n```\n\nNote that `Struct()` will internally convert the given argument to an immutable.js object using `immutable.fromJS()`.\n\nHere's how to traverse and mutate the `Struct` state:\n```typescript\n// retrieve a value\nlet a = data.get('a').deref()\n\n// update a value\ndata.get('g').get(0).get('a').val(99)\n\n// alternative\ndata.get('g').get(0).get('a').update(x =\u003e x + 1)\n\n// update the underlying immutable.js value\ndata.get('g').get(0).update(x =\u003e x.set('a', 99))\n```\n\nEverything here is type-checked. A wrong property name or type results in a compile-time error.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkornewald%2Fts-immutable-struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwkornewald%2Fts-immutable-struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkornewald%2Fts-immutable-struct/lists"}