{"id":26448473,"url":"https://github.com/alireza29675/handy-storage","last_synced_at":"2025-07-26T00:05:12.676Z","repository":{"id":27574129,"uuid":"98685812","full_name":"Alireza29675/handy-storage","owner":"Alireza29675","description":"🗃️ Handy Storage is a simple way to store your data in a JSON file","archived":false,"fork":false,"pushed_at":"2023-01-12T09:03:55.000Z","size":549,"stargazers_count":7,"open_issues_count":9,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T13:15:58.200Z","etag":null,"topics":["database","json","storage"],"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/Alireza29675.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":"2017-07-28T20:25:41.000Z","updated_at":"2022-08-07T12:25:08.000Z","dependencies_parsed_at":"2023-01-14T07:02:26.998Z","dependency_job_id":null,"html_url":"https://github.com/Alireza29675/handy-storage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fhandy-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fhandy-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fhandy-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fhandy-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alireza29675","download_url":"https://codeload.github.com/Alireza29675/handy-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244240930,"owners_count":20421553,"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":["database","json","storage"],"created_at":"2025-03-18T14:34:37.835Z","updated_at":"2025-03-18T14:34:38.564Z","avatar_url":"https://github.com/Alireza29675.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca name=\"beginning\"\u003e\u003c/a\u003e\n\n![handy-storage logo](https://user-images.githubusercontent.com/2771377/36355655-d20e813a-14fb-11e8-8c15-4741799c9090.png)\n\n# HandyStorage\n**HandyStorage** is a simple way to store your data in a JSON file\n\n\u003ca name=\"Installation\"\u003e\u003c/a\u003e\n## Installation\n```bash\nnpm install --save handy-storage\n```\n\n\u003ca name=\"Usage\"\u003e\u003c/a\u003e\n## Example of Usage\n```javascript\nconst HandyStorage = require('handy-storage');\n\nconst storage = new HandyStorage({\n    beautify: true\n});\n\nstorage.connect('./information.json');\n\nstorage.setState({\n    name: 'Alireza',\n    lastname: 'Sh',\n    friends: [\n        'Jane',\n        'John'\n    ],\n    visited: storage.state.visited || 0\n})\n\nstorage.setState({\n    visited: storage.state.visited + 1\n})\n```\n\n\u003ca name=\"Refrence\"\u003e\u003c/a\u003e\n\n## Manual Refrence\n\n\u003ca name=\"HandyStorage\"\u003e\u003c/a\u003e\n\n### HandyStorage\n**Kind**: global class\n\n* [HandyStorage](#HandyStorage)\n    * [new HandyStorage([path])](#new_HandyStorage_new)\n    * [.connect(path)](#HandyStorage+connect)\n    * [.state](#HandyStorage+state)\n    * [.setState([changes])](#HandyStorage+setState)\n    * [.save([options])](#HandyStorage+save) ⇒ \u003ccode\u003ePromise\u003c/code\u003e\n\n\u003ca name=\"new_HandyStorage_new\"\u003e\u003c/a\u003e\n\n### new HandyStorage([path], [options])\nRepresents a \"Handy\" storage\n\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| [path] | \u003ccode\u003estring\u003c/code\u003e | Path of JSON file |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e | Additional Configurations |\n| [options.beautify] | \u003ccode\u003eboolean\u003c/code\u003e | Should storage beautify JSON before storing? _(Default: **false**)_ |\n| [options.autoSave] | \u003ccode\u003eboolean\u003c/code\u003e | Should storage auto save when you use **.setState()** method? _(Default: **true**)_ |\n\n\n\u003ca name=\"HandyStorage+connect\"\u003e\u003c/a\u003e\n\n### handyStorage.connect(path)\nConnects storage to a JSON file\n\n**Kind**: instance method of [\u003ccode\u003eHandyStorage\u003c/code\u003e](#HandyStorage)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| path | \u003ccode\u003estring\u003c/code\u003e | Path of JSON file |\n\n\u003ca name=\"HandyStorage+state\"\u003e\u003c/a\u003e\n\n### handyStorage.state\nState object of storage, including all stored data\n\n**Kind**: instance property of [\u003ccode\u003eHandyStorage\u003c/code\u003e](#HandyStorage)\n\n\u003e **Tip 1**: you can change this object and call [.save()](#HandyStorage+save) to store it into JSON file.\n\n\u003e **Tip 2**: try to use [.setState()](#HandyStorage+setState) method instead of changing **.state** directly! it's much safer, also it supports **autoSave** mode.\n\n\u003ca name=\"HandyStorage+setState\"\u003e\u003c/a\u003e\n\n### handyStorage.setState(changes) ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nSets some changes on \"state\" object then saves it into the file\n\n**Kind**: instance method of [\u003ccode\u003eHandyStorage\u003c/code\u003e](#HandyStorage)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| changes | \u003ccode\u003eObject\u003c/code\u003e | State changes |\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - State change callback promise\n\n\n\u003ca name=\"HandyStorage+save\"\u003e\u003c/a\u003e\n\n### handyStorage.save([options]) ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nSaves current state into the connected JSON file\n\n**Kind**: instance method of [\u003ccode\u003eHandyStorage\u003c/code\u003e](#HandyStorage)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e | Additional save configurations |\n| [options.sync] | \u003ccode\u003eboolean\u003c/code\u003e | Should save synchronous? _(Default: **false**)_ |\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Saving state callback promise\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falireza29675%2Fhandy-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falireza29675%2Fhandy-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falireza29675%2Fhandy-storage/lists"}