{"id":16982045,"url":"https://github.com/tenphi/jsync","last_synced_at":"2026-04-12T20:54:47.938Z","repository":{"id":4431816,"uuid":"5569870","full_name":"tenphi/jsync","owner":"tenphi","description":"Module for sync local object variable with *.js or *.coffee file","archived":false,"fork":false,"pushed_at":"2012-11-16T08:30:35.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-30T00:46:26.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","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/tenphi.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":"2012-08-27T11:02:45.000Z","updated_at":"2021-06-14T03:46:41.000Z","dependencies_parsed_at":"2022-08-27T07:20:23.340Z","dependency_job_id":null,"html_url":"https://github.com/tenphi/jsync","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenphi%2Fjsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenphi%2Fjsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenphi%2Fjsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenphi%2Fjsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tenphi","download_url":"https://codeload.github.com/tenphi/jsync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244885515,"owners_count":20526293,"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-10-14T02:07:09.963Z","updated_at":"2026-04-12T20:54:42.905Z","avatar_url":"https://github.com/tenphi.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## jSync - Module for sync local object variable with *.js or *.coffee file\n======\n\n### Installation\n\n```bash\n$ npm install jsync\n```\n\n### Simple usage\n\n```javascript\nvar jsync = require('jsync');\nvar obj = jsync('data.json'); // also you can load *.js, *.cson and *.coffee files\n\n// now object will keep in sync with json-file\n```\n\n### Set interval\n\n```javascript\nvar obj = jsync('data.js', 100); // file check every 100ms\n```\n\n### Set context for eval\n\n```javascript\n// data.js\n{\n\tsomeVariable: this.prop\n}\n```\n\nContext can only be the Object\n\n```javascript\ncontext = { prop: 'value' };\nvar obj = jsync('data.js', context);\nconsole.log(obj); // { someVariable: 'value' }\n```\n\n### Set handler\n\n```javascript\n// data.js\n[1,2,3,4]\n```\n\n```javascript\nfunction handler (err, arr) {\n\tarr.splice(2);\n}\nvar obj = jsync('data.js', handler);\nconsole.log(obj); // [1,2]\n```\n\n### All-in-one call\n\n```javascript\nvar obj = jsync(file, interval, context, handler); // all arguments are optional except `file`\n```\n\n### Cancel sync and remove watcher\n\n```javascript\njsync.cancel(obj);\n```\n\n### Simple read without sync\n\n```javascript\nvar obj = jsync.read('data.js', context);\n```\n\n### Manual sync with or without new context\n\n```javascript\njsync.trigger(obj, newContext);\n```\n\n### Save synced object to file\n\n```javascript\nvar obj = jsync('data.js');\njsync.save(obj/*, fileName, callback */); // if fileName not set it will use 'data.js'\n```\n\nfunction will execute asynchronously if callback is set\n\n### Run some tests\n\n```bash\n$ cd /path/to/jsync/\n$ npm test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenphi%2Fjsync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftenphi%2Fjsync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenphi%2Fjsync/lists"}