Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bchr02 committed Oct 14, 2016
1 parent b4b92a7 commit 757ed03
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# [filejson](https://github.com/bchr02/filejson)
Use a JSON encoded file to automatically save a JavaScript value to disk whenever that value changes. A value can be a Javascript: string, number, boolean, null, object, or an array. The value can be structured in an array or an object to allow for more complex data stores. These structures can also be nested. As a result, you can use this module as a simple document store for storing semi structured data.

[![NPM](https://nodei.co/npm/filejson.png?downloads=true&stars=true)](https://nodei.co/npm/filejson/)

Use a JSON encoded file to automatically save a JavaScript value to disk whenever that value changes. A value can be a Javascript: string, number, boolean, null, object, or an array. The value can be structured in an array or an object to allow for more complex data stores. These structures can also be nested. As a result, you can use this module as a simple document store for storing semi structured data.

## Requirements
[ECMAScript 6 Reflect and Proxy objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) support, which is found natively in Node.js >= 6. If you are using a version of Node.js < 6, use a polyfill, such as [harmony-reflect](https://github.com/tvcutsem/harmony-reflect). Proxy support is key for this module working so eloquently. Other non-Proxy based modules require function calls each time you wish to save an object. Unlike those, [filejson](https://github.com/bchr02/filejson) is as easy as ```file.contents = "my new value"``` or ```file.contents = {"msg": "Hello World"}``` and the changes are automatically saved to disk.

Expand Down
5 changes: 5 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ function Filejson(cfg) {
}
};

if( target == self && key != "contents") {
// When target is at the root object but we are not updating the "contents" property then just store the value (the default action).
return Reflect.set(target, key, value, receiver);
}

if( !self.cfg.filename ) {
throw new Error("You must specify a filename");
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filejson",
"version": "1.0.8",
"version": "1.0.9",
"description": "Use a JSON encoded file to automatically save a JavaScript value to disk whenever that value changes.",
"main": "app.js",
"scripts": {
Expand Down

0 comments on commit 757ed03

Please sign in to comment.