memory-sri 1.3.1 → 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 CHANGED
@@ -126,13 +126,12 @@ const plus = function (a, b) {
126
126
  };
127
127
 
128
128
  // register processor
129
- Memory.process('test', async function (data, meta) {
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
  });
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
@@ -12,7 +12,7 @@ let memory = module.exports;
12
12
  /**
13
13
  * version
14
14
  */
15
- memory.version = "1.3.1";
15
+ memory.version = "1.2.11";
16
16
 
17
17
  /**
18
18
  * Memory
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,7 +67,8 @@ async function runTask(name) {
67
67
 
68
68
  try {
69
69
  task.attempts += 1;
70
- const result = await fn(task.data, {
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.1",
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",