some falsey values cause silent failure
passing the following values to ElectronData.set result in no data being written to the json file:
- 0 (number)
- '' (blank string)
- false (boolean)
- null, undefined, NaN (javascript value-absence indicators)
Here's a code example:
let TestData = new ElectronData();
TestData.set('test1',0);
TestData.set('test2','');
TestData.set('test3',false);
TestData.set('test4',null);
TestData.set('test5',undefined);
TestData.set('test6',NaN);
TestData.save();
... which results in data.json containing a blank object: {}
Interestingly enough, the first three values will be recorded if they're passed as new instances of their base types:
let TestData = new ElectronData();
TestData.set('test1',new Number());
TestData.set('test2',new String());
TestData.set('test3',new Boolean());
TestData.save();
result: {"test1":0,"test2":"","test3":false}
I can understand null, undefined, and NaN - the JSON spec doesn't support these special types - but numbers, strings, and booleans are all supported, and their respective falsy values ought to be written as expected. null, undefined, and NaN ought to fail not-so-silently.
First of all: Thank you for notifying this issue. You are absolutely right, silent-failures are horrible.
I fixed this in v1.2.1.
FYI: null is a valid JSON value type. For an overview of supported value types, have a look at json.org
ah shit, I should've updated first. thanks!