{"id":13686106,"url":"https://github.com/privatenumber/reactive-json-file","last_synced_at":"2025-03-23T00:32:53.608Z","repository":{"id":44728101,"uuid":"288619491","full_name":"privatenumber/reactive-json-file","owner":"privatenumber","description":"💎 Reactively sync JSON mutations to disk","archived":false,"fork":false,"pushed_at":"2022-01-28T12:38:32.000Z","size":624,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-18T13:27:47.571Z","etag":null,"topics":["autosave","file","fs","json","reactive","save","vue"],"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/privatenumber.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":"2020-08-19T03:02:03.000Z","updated_at":"2023-10-24T20:31:43.000Z","dependencies_parsed_at":"2022-09-05T22:31:24.312Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/reactive-json-file","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Freactive-json-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Freactive-json-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Freactive-json-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Freactive-json-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/reactive-json-file/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040235,"owners_count":20551297,"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":["autosave","file","fs","json","reactive","save","vue"],"created_at":"2024-08-02T14:01:06.566Z","updated_at":"2025-03-23T00:32:53.239Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# reactive-json-file \u003ca href=\"https://npm.im/reactive-json-file\"\u003e\u003cimg src=\"https://badgen.net/npm/v/reactive-json-file\"\u003e\u003c/a\u003e\n\nSync JSON mutations to disk using reactive magic!\n\nGreat for removing saving-to-disk concerns when updating a JSON object.\n\n```js\nimport { openJson } from 'reactive-json-file'\n\n// Open a JSON file\nconst object = openJson('./data.json')\n\n// No need to save changes to disk, just update the object\nobject.name = 'John Doe'\n```\n\n## :rocket: Install\n```sh\nnpm i reactive-json-file\n```\n\n## ⚙️ API\n### openJson(filePath, options)\nOpen a file (eg. JSON file) and return the object\n\n#### Options\n- `throttle` `\u003cNumber\u003e` - Milliseconds to throttle saves by. Saves are already batched at the end of every event-loop, but this adds time-based throttling.\n- `fs` `\u003cFileSystemInterface\u003e` ([fs](https://nodejs.org/api/fs.html)) - Pass in a custom file-system. Defaults to native Node.js fs\n- `serialize`/`deserialize` `\u003cFunction\u003e` - Functions to serialize/deserialize the object with. eg. to save output to YAML\n\n    ```js\n    import { openJson as openYaml } from 'reactive-json-file'\n    import yaml from 'js-yaml'\n\n    const object = openYaml('./file.yaml', {\n        serialize: data =\u003e yaml.dump(data),\n        deserialize: string =\u003e yaml.load(string)\n    })\n\n    object.message = 'YAML!'\n    ```\n\n### closeJson(object)\nClose a file to disable syncing\n\n## 🙋‍♀️ FAQ\n\n### How does it work?\nArbitrary new changes are detected by using ES6 [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) behind the scenes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Freactive-json-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Freactive-json-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Freactive-json-file/lists"}