node-persist
Advanced tools
Comparing version 3.1.3 to 4.0.0
{ | ||
"name": "node-persist", | ||
"version": "3.1.3", | ||
"version": "4.0.0", | ||
"description": "Super-easy (and fast) persistent data structures in Node.js, modeled after HTML5 localStorage", | ||
@@ -5,0 +5,0 @@ "main": "./src/node-persist.js", |
@@ -48,4 +48,4 @@ /* | ||
const md5 = function (key) { | ||
return crypto.createHash('md5').update(key).digest('hex'); | ||
const sha256 = function (key) { | ||
return crypto.createHash('sha256').update(key).digest('hex'); | ||
}; | ||
@@ -224,3 +224,3 @@ | ||
getDatumPath: function (key) { | ||
return path.join(this.options.dir, md5(key)); | ||
return path.join(this.options.dir, sha256(key)); | ||
}, | ||
@@ -258,4 +258,4 @@ | ||
//check to see if dir is present | ||
fs.exists(dir, (exists) => { | ||
if (exists) { | ||
fs.access(dir, (accessErr) => { | ||
if (!accessErr) { | ||
return resolve(result); | ||
@@ -279,4 +279,4 @@ } else { | ||
//check to see if dir is present | ||
fs.exists(dir, (exists) => { | ||
if (exists) { | ||
fs.access(dir, (accessErr) => { | ||
if (!accessErr) { | ||
//load data | ||
@@ -408,4 +408,4 @@ fs.readdir(dir, async (err, arr) => { | ||
return new Promise((resolve, reject) => { | ||
fs.exists(file, (exists) => { | ||
if (exists) { | ||
fs.access(file, (accessErr) => { | ||
if (!accessErr) { | ||
this.log(`Removing file:${file}`); | ||
@@ -417,3 +417,3 @@ fs.unlink(file, (err) => { | ||
} | ||
let result = {file: file, removed: !err, existed: exists}; | ||
let result = {file: file, removed: !err, existed: !accessErr}; | ||
err && this.log(`Failed to remove file:${file} because it doesn't exist anymore.`); | ||
@@ -424,3 +424,3 @@ resolve(result); | ||
this.log(`Not removing file:${file} because it doesn't exist`); | ||
let result = {file: file, removed: false, existed: exists}; | ||
let result = {file: file, removed: false, existed: false}; | ||
resolve(result); | ||
@@ -427,0 +427,0 @@ } |
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
36547