https://github.com/capaj/object-fsify
file system persisted variables as simple as it ever will be
https://github.com/capaj/object-fsify
Last synced: 12 months ago
JSON representation
file system persisted variables as simple as it ever will be
- Host: GitHub
- URL: https://github.com/capaj/object-fsify
- Owner: capaj
- License: mit
- Created: 2018-04-24T10:23:47.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-30T00:40:56.000Z (about 8 years ago)
- Last Synced: 2025-06-13T22:05:18.806Z (about 1 year ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# object-fsify
file system persisted variables as simple as it ever will be with the help of ES6 Proxies magic.
```javascript
// myAwesomeNodejsScript.js
const a = objectFsify([], 'myArray.json')
a.push(10)
// myArray.json is now '[10]')
a.push(20)
// myArray.json is now '[10, 20]')
a.push(33)
// myArray.json is now '[10,20,33]')
// of course it works the same with objects
const a = objectFsify({} 'myObject.json')
a.b = 10
// myObject.json is now '{b: 10}')
```
When you run the script `myAwesomeNodejsScript.js` again, all the numbers will be there twice in the array as you would expect-file is loaded up when you initialise the `a` variable.
## options
```javascript
{
async: true, // default false, true makes fs operation async
indent: 2 // default is none, 2 makes JSON file indents 2 spaces
}
```