{"id":17134685,"url":"https://github.com/robojones/save-on-change","last_synced_at":"2026-05-08T04:33:49.357Z","repository":{"id":133113399,"uuid":"79356211","full_name":"robojones/save-on-change","owner":"robojones","description":"Automatically save objects into JSON files","archived":false,"fork":false,"pushed_at":"2017-02-04T11:56:39.000Z","size":7,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-22T19:05:51.667Z","etag":null,"topics":["automatically","autosave","file","json","nodejs","save"],"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/robojones.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-18T15:55:16.000Z","updated_at":"2021-06-14T12:15:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a37a3e0-13f3-47d4-aaaf-5c64a17a530b","html_url":"https://github.com/robojones/save-on-change","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"f1149b7694edee8c6f55e5b694f548b173a2a1ee"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robojones/save-on-change","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Fsave-on-change","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Fsave-on-change/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Fsave-on-change/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Fsave-on-change/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robojones","download_url":"https://codeload.github.com/robojones/save-on-change/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Fsave-on-change/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261348641,"owners_count":23145308,"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":["automatically","autosave","file","json","nodejs","save"],"created_at":"2024-10-14T19:45:29.780Z","updated_at":"2026-05-08T04:33:44.331Z","avatar_url":"https://github.com/robojones.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# save-on-change\r\n\r\nThis module allows you to read and write JSON files.\r\nIt overwrites the JSON file as soon as you change the object in your Node.js application.\r\nWhen you are restarting your Node.js app, the object will automatically be loaded from the JSON file.\r\n\r\n## Example\r\n```javascript\r\nconst autoSave = require('save-on-change')\r\n\r\n// load a JSON file\r\nconst a = autoSave('config.json')\r\n\r\n// change anything\r\na.hello = true\r\na.foo = 'baz'\r\n```\r\nThe file `config.json` should now contain:\r\n```json\r\n{\"hello\": true, \"foo\": \"baz\"}\r\n```\r\n\r\n## Installation\r\n```\r\nnpm i save-on-change --save\r\n```\r\n\r\n## Function: autoSave(filename[, onSave])\r\n- __filename__ \\\u003cString\\\u003e filename of the JSON file\r\n- __onSave__ \\\u003cFunction\\\u003e function that gets called every time the object gets saved\r\n\r\n__returns__ object representing the parsed contents of the file (Parser: JSON.parse())\r\n\r\nIf the JSON file does not exist, an empty object is returned.\r\nOnce you modify the object, the file will be created or overwritten.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobojones%2Fsave-on-change","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobojones%2Fsave-on-change","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobojones%2Fsave-on-change/lists"}