@dmop/puru 0.1.2 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +41 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A thread pool with Go-style concurrency primitives for JavaScript — spawn tasks off the main thread with channels, WaitGroup, select, and more. No worker files, no boilerplate.
4
4
 
5
- Works on **Node.js** and **Bun**.
5
+ Works on **Node.js** and **Bun**. Deno support coming soon.
6
6
 
7
7
  *puru (プール) means "pool" in Japanese.*
8
8
 
@@ -10,6 +10,8 @@ Works on **Node.js** and **Bun**.
10
10
 
11
11
  ```bash
12
12
  npm install @dmop/puru
13
+ # or
14
+ bun add @dmop/puru
13
15
  ```
14
16
 
15
17
  ## Quick Start
@@ -356,7 +358,7 @@ npm run bench # all benchmarks (Node.js)
356
358
  npm run bench:bun # all benchmarks (Bun)
357
359
  ```
358
360
 
359
- ### CPU-Bound Parallelism (Node.js)
361
+ ### CPU-Bound Parallelism
360
362
 
361
363
  | Benchmark | Without puru | With puru | Speedup |
362
364
  | --- | --: | --: | --: |
@@ -365,7 +367,19 @@ npm run bench:bun # all benchmarks (Bun)
365
367
  | Matrix multiply (200x200 x8) | 140 ms | 39 ms | **3.6x** |
366
368
  | Data processing (100K items x8) | 221 ms | 67 ms | **3.3x** |
367
369
 
368
- ### Channels Fan-Out Pipeline (Node.js)
370
+ <details>
371
+ <summary>Bun results</summary>
372
+
373
+ | Benchmark | Without puru | With puru | Speedup |
374
+ | --- | --: | --: | --: |
375
+ | Fibonacci (fib(38) x8) | 2,208 ms | 380 ms | **5.8x** |
376
+ | Prime counting (2M range) | 201 ms | 50 ms | **4.0x** |
377
+ | Matrix multiply (200x200 x8) | 197 ms | 57 ms | **3.5x** |
378
+ | Data processing (100K items x8) | 214 ms | 109 ms | **2.0x** |
379
+
380
+ </details>
381
+
382
+ ### Channels Fan-Out Pipeline
369
383
 
370
384
  200 items with CPU-heavy transform, 4 parallel transform workers:
371
385
 
@@ -375,7 +389,18 @@ npm run bench:bun # all benchmarks (Bun)
375
389
  | Main-thread channels only | 174 ms | 1.0x |
376
390
  | **puru fan-out (4 workers)** | **51 ms** | **3.4x faster** |
377
391
 
378
- ### Concurrent Async (Node.js)
392
+ <details>
393
+ <summary>Bun results</summary>
394
+
395
+ | Approach | Time | vs Sequential |
396
+ | --- | --: | --: |
397
+ | Sequential (no channels) | 59 ms | baseline |
398
+ | Main-thread channels only | 60 ms | 1.0x |
399
+ | **puru fan-out (4 workers)** | **22 ms** | **2.7x faster** |
400
+
401
+ </details>
402
+
403
+ ### Concurrent Async
379
404
 
380
405
  100 async tasks with simulated I/O + CPU:
381
406
 
@@ -385,6 +410,17 @@ npm run bench:bun # all benchmarks (Bun)
385
410
  | Promise.all (main thread) | 20 ms | 58x faster |
386
411
  | **puru concurrent** | **16 ms** | **73x faster** |
387
412
 
413
+ <details>
414
+ <summary>Bun results</summary>
415
+
416
+ | Approach | Time | vs Sequential |
417
+ | --- | --: | --: |
418
+ | Sequential | 1,110 ms | baseline |
419
+ | Promise.all (main thread) | 16 ms | 68x faster |
420
+ | **puru concurrent** | **13 ms** | **87x faster** |
421
+
422
+ </details>
423
+
388
424
  Both Promise.all and puru concurrent are fast — but puru runs everything **off the main thread**, keeping your server responsive under load.
389
425
 
390
426
  > Spawn overhead is ~0.1-0.5 ms. Use `spawn` for tasks > 5ms. For trivial operations, call directly.
@@ -395,6 +431,7 @@ Both Promise.all and puru concurrent are fast — but puru runs everything **off
395
431
  | --- | --- | --- |
396
432
  | Node.js >= 18 | Full | `worker_threads` |
397
433
  | Bun | Full | Web Workers (file-based) |
434
+ | Deno | Planned | — |
398
435
  | Cloudflare Workers | Error | No thread support |
399
436
  | Vercel Edge | Error | No thread support |
400
437
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmop/puru",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "puru (プール) — A thread pool with Go-style concurrency primitives for JavaScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",