nestworker 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +12 -4
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  ![](https://img.shields.io/badge/dependencies-none-brightgreen.svg)
2
2
  ![](https://img.shields.io/npm/dt/nestworker.svg)
3
+ ![](https://img.shields.io/npm/v/nestworker.svg)
3
4
  ![](https://img.shields.io/npm/l/nestworker.svg)
5
+ ![](https://img.shields.io/github/issues/VaheHak/nestworker.svg)
6
+ ![](https://img.shields.io/github/contributors/VaheHak/nestworker.svg)
7
+ ![](https://img.shields.io/github/last-commit/VaheHak/nestworker.svg)
8
+ ![](https://img.shields.io/github/forks/VaheHak/nestworker.svg)
9
+ ![](https://img.shields.io/github/stars/VaheHak/nestworker.svg)
10
+ ![](https://img.shields.io/github/watchers/VaheHak/nestworker.svg)
11
+
4
12
 
5
13
  # nestworker
6
14
  A simple library that provides an abstraction for the Node.js `worker_threads` module. You can run your function in a dedicated thread by working with Promises.
@@ -11,11 +19,11 @@ import { executeInThread } from 'nestworker';
11
19
 
12
20
  async function calculate(): Promise<void> {
13
21
  const values = await Promise.all([
14
- executeInThread(() => 2 ** 10),
22
+ executeInThread(() => 2 ** 10), // this doesn't block the main thread
15
23
  executeInThread(() => 3 ** 10),
16
24
  ]);
17
25
 
18
- console.log(values);
26
+ console.log(values); // [1024, 59049]
19
27
  }
20
28
 
21
29
  calculate();
@@ -47,7 +55,7 @@ See the [contributing guide](https://github.com/VaheHak/nestworker/blob/master/C
47
55
 
48
56
  ## API
49
57
 
50
- ### executeInThread(task, { args: any[] }
58
+ ### `executeInThread(task, { args: any[] }`
51
59
  Runs the specified function in a separate thread.
52
60
 
53
61
  #### Parameters
@@ -57,7 +65,7 @@ Runs the specified function in a separate thread.
57
65
  - Parameter cann't be a function.
58
66
 
59
67
  ```ts
60
- const task = function([a, b, c]) { ... };
68
+ const task = function(a: number, b: object, c: boolean) { ... };
61
69
  executeInThread(task, { args: [1, {}, true] })
62
70
  ```
63
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestworker",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "A lightweight tool built on top of Node.js worker_threads, enabling multithreading.",
5
5
  "author": "Vahe Hakobyan",
6
6
  "private": false,
@@ -34,7 +34,7 @@
34
34
  "homepage": "https://github.com/VaheHak/nestworker#readme",
35
35
  "repository": {
36
36
  "type": "git",
37
- "url": "git+https://github.com/VaheHak/nestworker.git"
37
+ "url": "https://github.com/VaheHak/nestworker.git"
38
38
  },
39
39
  "dependencies": {
40
40
  "@nestjs/common": "10.3.8"