{"id":24568730,"url":"https://github.com/biw/seal-store","last_synced_at":"2025-07-24T14:04:58.450Z","repository":{"id":65493532,"uuid":"123785434","full_name":"biw/seal-store","owner":"biw","description":"Zero dependency state store where state object is immutable by any means other than a `setState` function","archived":false,"fork":false,"pushed_at":"2018-03-27T04:07:44.000Z","size":144,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T06:36:56.916Z","etag":null,"topics":["es6","immutable","javascript","seal-store","state-management","state-store"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/biw.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":"2018-03-04T12:15:42.000Z","updated_at":"2021-12-14T09:38:36.000Z","dependencies_parsed_at":"2023-01-26T03:01:05.665Z","dependency_job_id":null,"html_url":"https://github.com/biw/seal-store","commit_stats":null,"previous_names":["719ben/seal-store"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Fseal-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Fseal-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Fseal-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Fseal-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biw","download_url":"https://codeload.github.com/biw/seal-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243978535,"owners_count":20378054,"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":["es6","immutable","javascript","seal-store","state-management","state-store"],"created_at":"2025-01-23T14:55:14.036Z","updated_at":"2025-03-17T05:27:07.752Z","avatar_url":"https://github.com/biw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# seal-store\n\n[![Build Status][build-badge]][build]\n[![version][version-badge]][package]\n[![MIT License][license-badge]][license]\n[![twitter][twitter-badge]][twitter]\n\n[![Nice Seal Drawing][sealImage]][sealImageLink]\n\n\nA simple framework agnostic state store where the `state` object is immutable by any means other than a `setState` function.\n\n```js\nimport initState from 'seal-store'\n\nconst { state, setState } = initState({\n  saxPlayingSeal: 'looking good',\n})\n\nstate.saxPlayingSeal = 'looking bad' // =\u003e throws TypeError\n\nconsole.log(state.saxPlayingSeal) // looking good\n\nsetState({ saxPlayingSeal: 'looking good but getting dizzy' })\n\nconsole.log(state.saxPlayingSeal) // looking good but is getting dizzy\n```\n\nProperties of the state object must be defined in the `initState` and cannot be removed.\n\n```js\nconst { state, setState } = initState({\n  saxPlayingSeal: 'looking good',\n})\n\nsetState({ fish: 'in water' }) // =\u003e throws TypeError\n```\n\nThis rule is true infinitely deep.\n```js\nconst { state, setState } = initState({\n  secondLevel: { thirdLevel: { fourthLevel: { 'saxPlayingSeal': 'looking good' } } }\n})\n\nsetState({ secondLevel: { thirdLevel: { fourthLevel: { fish: 'in water' } } } }) // =\u003e throws TypeError\n```\n\nThere is one exception to adding/removing properties: arrays can shrink or grow. However, in any objects inside of them (other than arrays) properties cannot be added/removed.\n```js\nconst { state, setState } = initState({\n  sealsInDocs: [{ name: 'spinningSeal' }],\n})\n\nsetState({ sealsInReadme: [...state.sealsInReadme, { name: 'happySeal' }] }) // this is fine\n\nsetState({ sealsInReadme: [] }) // this is also fine\n```\n\n`seal-store` also comes with the ability to add a callback when any key in the state is updated.\n```js\nconst stateHasBeenUpdated = (newState) =\u003e { console.log('the state has updated') }\n\nconst { state, setState } = initState({\n  updated: false,\n}, stateHasBeenUpdated)\n\nsetState({ updated: true }) // =\u003e 'the state has been updated'\n```\n\nUnlike other state stores, `seal-store` doesn't need spread syntax (`{ ...items }`) for changes that apply to child objects\n\n```js\nconst { state, setState } = initState({\n  secondLevel: {\n    updated: false,\n    stillHere: true,\n  },\n})\n\nsetState({ secondLevel: { updated: true } })\n\nconsole.log(state) // =\u003e { secondLevel: { updated: true, stillHere: true } }\n```\n\n\n## Install\n\n```sh\nyarn add seal-store\n```\nor\n```sh\nnpm add --save seal-store\n```\nor as a script tag\n```html\n\u003cscript src=\"https://unpkg.com/seal-store/dist/seal-store.umd.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"application/javascript\"\u003e\n  const { state, setState } = window.sealStore({ 'saxPlayingSeal': 'looking good' })\n\u003c/script\u003e\n```\n\n## `proxy` Support\n\n`seal-store` uses `proxy` objects. If you need to provide IE support, you'll need a [proxy polyfill](https://github.com/GoogleChrome/proxy-polyfill). You can look at the full compatibility table on [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy).\n\n## LICENSE\n\nMIT © [Ben Williams](https://719ben.com)\n\n[sealImageLink]: https://www.youtube.com/watch?v=X0k7N0ASfp8\n[sealImage]: https://media2.giphy.com/media/ySz02sRVFK372/giphy.gif\n[build-badge]: https://img.shields.io/travis/719Ben/seal-store.svg?style=flat-square\n[build]: https://travis-ci.org/719Ben/seal-store\n[version-badge]: https://img.shields.io/npm/v/seal-store.svg?style=flat-square\n[package]: https://www.npmjs.com/package/seal-store\n[license-badge]: https://img.shields.io/npm/l/seal-store.svg?style=flat-square\n[license]: https://github.com/719ben/seal-store/blob/master/LICENSE\n[twitter-badge]: https://img.shields.io/twitter/follow/719ben.svg?style=flat-square\u0026logo=twitter\u0026label=Follow\n[twitter]: https://twitter.com/719ben\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiw%2Fseal-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiw%2Fseal-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiw%2Fseal-store/lists"}