informa-db.js
Advanced tools
Comparing version 2.0.1 to 2.1.0
24
index.js
@@ -23,2 +23,26 @@ const fs = require('fs'); | ||
genProxy(data) { | ||
return new Proxy(data, { | ||
set: (obj, prop, val) => { | ||
obj[prop] = val; | ||
if (this.saveOnChange) { | ||
this.update(); | ||
} | ||
return true; | ||
}, | ||
deleteProperty: (obj, prop) => { | ||
delete obj[prop]; | ||
if (this.saveOnChange) { | ||
this.update(); | ||
} | ||
return true; | ||
}, | ||
get: (obj, prop) => ( | ||
typeof obj[prop] === 'object' && obj[prop] | ||
? this.genProxy(obj[prop]) | ||
: obj[prop] | ||
), | ||
}); | ||
} | ||
/** | ||
@@ -25,0 +49,0 @@ * async Updates the file/db from this.readOnlyValue |
{ | ||
"name": "informa-db.js", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "DataBases made easier", | ||
@@ -9,2 +9,7 @@ "main": "index.js", | ||
"repository": "https://github.com/informathemusic/informa-db.js", | ||
"keywords": [ | ||
"file-based database", | ||
"json", | ||
"backend" | ||
], | ||
"publishConfig": { | ||
@@ -11,0 +16,0 @@ "registry": "https://registry.npmjs.org/" |
23
utils.js
@@ -6,25 +6,2 @@ module.exports = { | ||
}, | ||
genProxy(data) { | ||
return new Proxy(data, { | ||
set: (obj, prop, val) => { | ||
obj[prop] = val; | ||
if (this.saveOnChange) { | ||
this.update(); | ||
} | ||
return true; | ||
}, | ||
deleteProperty: (obj, prop) => { | ||
delete obj[prop]; | ||
if (this.saveOnChange) { | ||
this.update(); | ||
} | ||
return true; | ||
}, | ||
get: (obj, prop) => ( | ||
typeof obj[prop] === 'object' && obj[prop] | ||
? this.genProxy(obj[prop]) | ||
: obj[prop] | ||
), | ||
}); | ||
}, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7288
6