@dmop/puru 0.1.11 → 0.1.13
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/AGENTS.md +2 -2
- package/README.md +11 -2
- package/dist/index.cjs +348 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -6
- package/dist/index.d.ts +77 -6
- package/dist/index.js +347 -52
- package/dist/index.js.map +1 -1
- package/llms-full.txt +2 -2
- package/llms.txt +1 -1
- package/package.json +4 -1
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# puru — Guide for AI Assistants
|
|
2
2
|
|
|
3
|
-
puru is a thread pool library for JavaScript with Go-style concurrency primitives (channels, WaitGroup, ErrGroup, select, context, Mutex, RWMutex, Cond, Timer). It runs functions off the main thread with no worker files and no boilerplate.
|
|
3
|
+
puru is a zero-dependency thread pool library for JavaScript with Go-style concurrency primitives (channels, WaitGroup, ErrGroup, select, context, Mutex, RWMutex, Cond, Timer). It runs functions off the main thread with no worker files and no boilerplate.
|
|
4
4
|
|
|
5
5
|
Full API reference: https://raw.githubusercontent.com/dmop/puru/main/llms-full.txt
|
|
6
6
|
|
|
@@ -117,7 +117,7 @@ const eg = new ErrGroup()
|
|
|
117
117
|
eg.spawn(() => fetch('https://api.example.com/users/1').then((r) => r.json()), { concurrent: true })
|
|
118
118
|
eg.spawn(() => fetch('https://api.example.com/users/1/orders').then((r) => r.json()), { concurrent: true })
|
|
119
119
|
|
|
120
|
-
const [user, orders] = await eg.wait() // throws on first error,
|
|
120
|
+
const [user, orders] = await eg.wait() // throws on first error, terminates remaining workers
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
### ErrGroup with concurrency limit
|
package/README.md
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@dmop/puru)
|
|
4
4
|
[](https://www.npmjs.com/package/@dmop/puru)
|
|
5
5
|
[](https://bundlephobia.com/package/@dmop/puru)
|
|
6
|
+
[](https://www.npmjs.com/package/@dmop/puru?activeTab=dependencies)
|
|
6
7
|
[](LICENSE)
|
|
7
8
|
|
|
8
|
-
**Go-style concurrency for JavaScript.** Worker threads with channels, WaitGroup, select, and context — no worker files, no boilerplate.
|
|
9
|
+
**Go-style concurrency for JavaScript.** Worker threads with channels, WaitGroup, select, and context — zero dependencies, no worker files, no boilerplate.
|
|
9
10
|
|
|
10
11
|
```ts
|
|
11
12
|
import { spawn } from '@dmop/puru'
|
|
@@ -57,7 +58,11 @@ const { result } = spawn(() => {
|
|
|
57
58
|
return fibonacci(40)
|
|
58
59
|
})
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
try {
|
|
62
|
+
console.log(await result)
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error(err)
|
|
65
|
+
}
|
|
61
66
|
```
|
|
62
67
|
|
|
63
68
|
</td>
|
|
@@ -68,8 +73,12 @@ One file. No message plumbing. Automatic pooling.
|
|
|
68
73
|
|
|
69
74
|
## Install
|
|
70
75
|
|
|
76
|
+
Zero runtime dependencies — just the library itself.
|
|
77
|
+
|
|
71
78
|
```bash
|
|
72
79
|
npm install @dmop/puru
|
|
80
|
+
# or
|
|
81
|
+
bun add @dmop/puru
|
|
73
82
|
```
|
|
74
83
|
|
|
75
84
|
## Quick Start
|