memory-sri 1.3.2 → 1.3.3
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 +4 -9
- package/index.d.ts +4 -4
- package/lib/main.js +1 -1
- package/lib/worker.js +3 -2
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -126,13 +126,12 @@ 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 () {
|
|
130
130
|
console.log("Running queued task with:");
|
|
131
|
-
console.log(data);
|
|
132
|
-
console.log(meta);
|
|
131
|
+
console.log(this.data);
|
|
133
132
|
// do your background work
|
|
134
|
-
let a = data.price;
|
|
135
|
-
let b = data.value;
|
|
133
|
+
let a = this.data.price;
|
|
134
|
+
let b = this.data.value;
|
|
136
135
|
let c = plus(a, b);
|
|
137
136
|
console.log(`total: ${c}`);
|
|
138
137
|
});
|
|
@@ -258,7 +257,3 @@ app.listen(PORT, () => {
|
|
|
258
257
|
- **Background Task Processing**: A separate worker process reads tasks from the queue and runs the function.
|
|
259
258
|
|
|
260
259
|
- **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/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function get(identifier: string): any;
|
|
2
|
-
export function ttl(identifier: string): any;
|
|
1
|
+
export function get(identifier: string | number): any;
|
|
2
|
+
export function ttl(identifier: string | number): any;
|
|
3
3
|
export function multiple(): any;
|
|
4
|
-
export function set(identifier: string, data?: any, time?: number): any;
|
|
5
|
-
export function del(identifier: string): any;
|
|
4
|
+
export function set(identifier: string | number, data?: any, time?: number): any;
|
|
5
|
+
export function del(identifier: string | number): any;
|
|
6
6
|
export function delall(): any;
|
|
7
7
|
export function process(name?: any, taskFn?: any): any;
|
|
8
8
|
export function addtask(name?: any, data?: any, retries?: any): any;
|
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
|
|
40
|
+
if(timeout !== 0){
|
|
41
41
|
taskIdBE += 1;
|
|
42
42
|
}
|
|
43
43
|
tasksBE.push({ id: taskIdBE, run: taskFn });
|
|
@@ -67,7 +67,8 @@ async function runTask(name) {
|
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
69
|
task.attempts += 1;
|
|
70
|
-
const result = await fn(
|
|
70
|
+
const result = await fn.call({
|
|
71
|
+
data: task.data,
|
|
71
72
|
id: task.id,
|
|
72
73
|
name: task.name,
|
|
73
74
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memory-sri",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
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,14 +19,13 @@
|
|
|
19
19
|
"queue",
|
|
20
20
|
"data-structure",
|
|
21
21
|
"memory",
|
|
22
|
-
"node"
|
|
23
|
-
"backend"
|
|
22
|
+
"node"
|
|
24
23
|
],
|
|
25
24
|
"main": "./index",
|
|
26
25
|
"types": "./index.d.ts",
|
|
27
26
|
"typings": "./index.d.ts",
|
|
28
27
|
"repository": {
|
|
29
28
|
"type": "git",
|
|
30
|
-
"url": "https://github.com/Santipap-
|
|
29
|
+
"url": "https://github.com/Santipap-Eiamsamlee/memory.git"
|
|
31
30
|
}
|
|
32
31
|
}
|