Comparing version 1.0.0 to 2.0.0
2.0.0 / 2018-03-08 | ||
================== | ||
* refactor: use async await | ||
1.0.0 / 2017-10-23 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -14,3 +14,3 @@ 'use strict'; | ||
* disk store | ||
* | ||
* | ||
* @constructor | ||
@@ -34,12 +34,12 @@ * @param {Object} options | ||
* get(relativePath) { | ||
async get(relativePath) { | ||
const filepath = path.join(this.cacheDir, relativePath); | ||
const isExists = yield fs.exists(filepath); | ||
const isExists = await fs.exists(filepath); | ||
if (!isExists) { | ||
return null; | ||
} | ||
return yield fs.readFile(filepath); | ||
return await fs.readFile(filepath); | ||
} | ||
* set(relativePath, data) { | ||
async set(relativePath, data) { | ||
const filepath = path.join(this.cacheDir, relativePath); | ||
@@ -49,12 +49,12 @@ // make sure following operations are atomic | ||
const tmpfile = path.join(this.tmpdir, uuid()); | ||
yield [ | ||
await Promise.all([ | ||
mkdirp(dir), | ||
mkdirp(this.tmpdir), | ||
]; | ||
]); | ||
yield fs.writeFile(tmpfile, data); | ||
await fs.writeFile(tmpfile, data); | ||
try { | ||
yield fs.rename(tmpfile, filepath); | ||
await fs.rename(tmpfile, filepath); | ||
} catch (err) { | ||
yield rimraf(tmpfile); | ||
await rimraf(tmpfile); | ||
throw err; | ||
@@ -64,5 +64,5 @@ } | ||
* delete(relativePath) { | ||
async delete(relativePath) { | ||
const filepath = path.join(this.cacheDir, relativePath); | ||
yield fs.unlink(filepath); | ||
await fs.unlink(filepath); | ||
} | ||
@@ -69,0 +69,0 @@ } |
{ | ||
"name": "diskstore", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "a local cache implement", | ||
@@ -41,3 +41,2 @@ "main": "lib/index.js", | ||
"autod": "^2.10.1", | ||
"co": "^4.6.0", | ||
"coffee": "^4.1.0", | ||
@@ -51,7 +50,7 @@ "egg-bin": "^4.3.5", | ||
"engines": { | ||
"node": ">= 6.0.0" | ||
"node": ">= 8.0.0" | ||
}, | ||
"ci": { | ||
"version": "6, 8" | ||
"version": "8, 9" | ||
} | ||
} |
@@ -52,2 +52,3 @@ # diskstore | ||
}); | ||
yield diskStore.set('a/b/c', 'c'); | ||
@@ -54,0 +55,0 @@ let data = yield diskStore.get('a/b/c'); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6291
7
65
1