{"id":23286682,"url":"https://github.com/allnulled/universal-store","last_synced_at":"2025-04-06T15:34:04.492Z","repository":{"id":268370906,"uuid":"904135407","full_name":"allnulled/universal-store","owner":"allnulled","description":"Universal Store is a state manager for browser and node.js.","archived":false,"fork":false,"pushed_at":"2024-12-22T21:10:08.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T05:32:57.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allnulled.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-16T10:14:12.000Z","updated_at":"2024-12-22T21:10:11.000Z","dependencies_parsed_at":"2024-12-16T11:24:17.246Z","dependency_job_id":"f045b4f2-bf29-4de7-9624-ec67bd3ce091","html_url":"https://github.com/allnulled/universal-store","commit_stats":null,"previous_names":["allnulled/universal-store"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Funiversal-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Funiversal-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Funiversal-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Funiversal-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allnulled","download_url":"https://codeload.github.com/allnulled/universal-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247503526,"owners_count":20949453,"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":[],"created_at":"2024-12-20T02:14:03.978Z","updated_at":"2025-04-06T15:34:04.464Z","avatar_url":"https://github.com/allnulled.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# universal-store\n\nGestor de estado para navegador y node.js.\n\n## Instalación\n\n### Descargar la librería\n\n```\nnpm install -s @allnulled/universal-store\n```\n\n### Importar la librería\n\n#### Modos de importar la librería\n\nDado que usa otras librerías, y pueden quererse usar desde otros módulos o no, puedes usar el archivo:\n\n  - `store.js`: este fichero tiene todas las APIs necesarias. Incluye:\n     - [`ufs`](https://github.com/allnulled/universal-file-system) o [`universal-file-system`](https://github.com/allnulled/universal-file-system)\n  - `store.unbundled.js`: este fichero solo tiene la parte que le es propia, y sobreentiende que cargarás las otras librerías necesarias por tu propia cuenta.\n\n**NOTA:** Por defecto, se usa `store.unbundled.js`.\n\n#### En node.js\n\nPuedes usar `require` o `import` indistintamente para importar el módulo.\n\n#### En browser\n\n```html\n\u003cscript src=\"node_modules/@allnulled/universal-store/dist/store.js\"\u003e\u003c/script\u003e\n```\n\nO alternativamente:\n\n```html\n\u003cscript src=\"node_modules/@allnulled/universal-store/dist/lib/ufs.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"node_modules/@allnulled/universal-store/dist/store.unbundled.js\"\u003e\u003c/script\u003e\n```\n\n## API\n\n### Crear una store\n\nPara crear una store, desde node.js puedes:\n\n```js\nconst store = require(\"@allnulled/universal-store\").create();\n```\n\nSi estás en browser y no usas módulos, o si estás en node.js y no quieres usar require, puedes:\n\n```js\nconst store = UniversalStore.create();\n```\n\n### Usar una store\n\nLos métodos de la API disponibles por defecto son:\n\n```js\nstore.get(\"property/id\");\nstore.set(\"property/id\", 1);\nstore.watch(\"property/id\", function(event, property_path, value) {});\nstore.unwatch(\"property/id\", previous_function);\nstore.delete(\"property/id\");\nstore.push(\"property/id/to/array\", 1);\nstore.pop(\"property/id/to/array\");\nstore.unshift(\"property/id/to/array\", 1);\nstore.shift(\"property/id/to/array\");\nstore.add(\"property/id/to/object\", \"key\", 1);\nstore.remove(\"property/id/to/object\", \"key\");\nstore.splice(\"property/id/to/array\", 5, 10, ...[1, 1, 1]);\nstore.extend(\"property/id/to/object\", { more: \"props\" });\nstore.modify(\"property/id\", function(value) { return \"new value\"; });\nstore.hydrate(\"file_to_read_from.json\");\nstore.dehydrate(\"file_to_write_to.json\");\n```\n\nTodos son métodos síncronos y no tienen alternativa.\n\nLos métodos `hydrate` y `dehydrate` están polyfileados con la librería `ufs` o `universal-file-system`, de [allnulled](https://github.com/allnulled/universal-file-system) también. Así que puedes persistir el estado del store tanto en node.js como en el browser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Funiversal-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallnulled%2Funiversal-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Funiversal-store/lists"}