An open API service indexing awesome lists of open source software.

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

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
}
```