memory-sri 1.2.11 → 1.3.2
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/README.md +9 -4
- package/lib/main.js +1 -1
- package/lib/worker.js +2 -3
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -126,12 +126,13 @@ const plus = function (a, b) {
|
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
// register processor
|
|
129
|
-
Memory.process('test', async function () {
|
|
129
|
+
Memory.process('test', async function (data, meta) {
|
|
130
130
|
console.log("Running queued task with:");
|
|
131
|
-
console.log(
|
|
131
|
+
console.log(data);
|
|
132
|
+
console.log(meta);
|
|
132
133
|
// do your background work
|
|
133
|
-
let a =
|
|
134
|
-
let b =
|
|
134
|
+
let a = data.price;
|
|
135
|
+
let b = data.value;
|
|
135
136
|
let c = plus(a, b);
|
|
136
137
|
console.log(`total: ${c}`);
|
|
137
138
|
});
|
|
@@ -257,3 +258,7 @@ app.listen(PORT, () => {
|
|
|
257
258
|
- **Background Task Processing**: A separate worker process reads tasks from the queue and runs the function.
|
|
258
259
|
|
|
259
260
|
- **Test jest**: Jest tests verify core functionality, TTL sorting, and correct task recording.
|
|
261
|
+
|
|
262
|
+
### Repositories
|
|
263
|
+
- [memory-repo-express](https://github.com/Santipap-Eiam/memory-repo-express)
|
|
264
|
+
- [memory-repo-ts](https://github.com/Santipap-Eiam/memory-repo-ts)
|
package/lib/main.js
CHANGED
package/lib/worker.js
CHANGED
|
@@ -37,7 +37,7 @@ Task.addTaskBE = function addTaskService(taskFn, data, timeout) {
|
|
|
37
37
|
logData(`Task must be a function`);
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
if(timeout !== 0){
|
|
40
|
+
if (timeout !== 0) {
|
|
41
41
|
taskIdBE += 1;
|
|
42
42
|
}
|
|
43
43
|
tasksBE.push({ id: taskIdBE, run: taskFn });
|
|
@@ -67,8 +67,7 @@ async function runTask(name) {
|
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
69
|
task.attempts += 1;
|
|
70
|
-
const result = await fn.
|
|
71
|
-
data: task.data,
|
|
70
|
+
const result = await fn(task.data, {
|
|
72
71
|
id: task.id,
|
|
73
72
|
name: task.name,
|
|
74
73
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memory-sri",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Powerful yet simple memory and queue manager for building efficient Node.js apps.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npx jest ---coverage=false --detectOpenHandles --forceExit",
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"queue",
|
|
20
20
|
"data-structure",
|
|
21
21
|
"memory",
|
|
22
|
-
"node"
|
|
22
|
+
"node",
|
|
23
|
+
"backend"
|
|
23
24
|
],
|
|
24
25
|
"main": "./index",
|
|
25
26
|
"types": "./index.d.ts",
|
|
26
27
|
"typings": "./index.d.ts",
|
|
27
28
|
"repository": {
|
|
28
29
|
"type": "git",
|
|
29
|
-
"url": "https://github.com/Santipap-
|
|
30
|
+
"url": "https://github.com/Santipap-Eiam/memory-repo-ts.git"
|
|
30
31
|
}
|
|
31
32
|
}
|