@abtnode/queue 1.8.3 → 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +14 -2
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -161,11 +161,22 @@ module.exports = function createQueue({ file, onJob, options = {} }) {
|
|
|
161
161
|
|
|
162
162
|
const cancel = async (id) =>
|
|
163
163
|
new Promise((resolve, reject) => {
|
|
164
|
-
store.updateJob(id, { cancelled: true }, (e,
|
|
164
|
+
store.updateJob(id, { cancelled: true }, (e, doc) => {
|
|
165
165
|
if (e) {
|
|
166
166
|
return reject(e);
|
|
167
167
|
}
|
|
168
|
-
return resolve(
|
|
168
|
+
return resolve(doc ? doc.job : null);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const getJob = async (id) =>
|
|
173
|
+
new Promise((resolve, reject) => {
|
|
174
|
+
store.getJob(id, (e, doc) => {
|
|
175
|
+
if (e) {
|
|
176
|
+
return reject(e);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return resolve(doc ? doc.job : null);
|
|
169
180
|
});
|
|
170
181
|
});
|
|
171
182
|
|
|
@@ -197,6 +208,7 @@ module.exports = function createQueue({ file, onJob, options = {} }) {
|
|
|
197
208
|
return Object.assign(queueEvents, {
|
|
198
209
|
store,
|
|
199
210
|
push,
|
|
211
|
+
get: getJob,
|
|
200
212
|
cancel,
|
|
201
213
|
options: {
|
|
202
214
|
concurrency,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.4",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
23
|
-
"@nedb/core": "^1.3.
|
|
24
|
-
"@nedb/multi": "^1.3.
|
|
22
|
+
"@abtnode/util": "1.8.4",
|
|
23
|
+
"@nedb/core": "^1.3.2",
|
|
24
|
+
"@nedb/multi": "^1.3.2",
|
|
25
25
|
"debug": "^4.3.3",
|
|
26
26
|
"fastq": "^1.8.0",
|
|
27
27
|
"uuid": "7.0.3"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "c42fb1bb84c5eef0f753fd5397d8007c7a6eee19",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"jest": "^27.4.5"
|
|
32
32
|
}
|