@dmop/puru 0.1.10 → 0.1.12
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 +137 -2
- package/README.md +124 -164
- package/dist/index.cjs +810 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +341 -8
- package/dist/index.d.ts +341 -8
- package/dist/index.js +798 -48
- package/dist/index.js.map +1 -1
- package/llms-full.txt +175 -8
- package/llms.txt +10 -6
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -9,9 +9,9 @@ type StructuredCloneValue = void | null | undefined | string | number | boolean
|
|
|
9
9
|
type ChannelValue = Exclude<StructuredCloneValue, null>;
|
|
10
10
|
interface PuruConfig {
|
|
11
11
|
maxThreads: number;
|
|
12
|
-
strategy:
|
|
12
|
+
strategy: "fifo" | "work-stealing";
|
|
13
13
|
idleTimeout: number;
|
|
14
|
-
adapter:
|
|
14
|
+
adapter: "auto" | "node" | "bun" | "inline";
|
|
15
15
|
concurrency: number;
|
|
16
16
|
}
|
|
17
17
|
interface SpawnResult<T> {
|
|
@@ -44,6 +44,28 @@ interface Channel<T extends ChannelValue> {
|
|
|
44
44
|
/** Resolves with the next value, or `null` if the channel is closed. */
|
|
45
45
|
recv(): Promise<T | null>;
|
|
46
46
|
close(): void;
|
|
47
|
+
/** Number of values currently buffered. Like Go's `len(ch)`. */
|
|
48
|
+
readonly len: number;
|
|
49
|
+
/** Buffer capacity. Like Go's `cap(ch)`. */
|
|
50
|
+
readonly cap: number;
|
|
51
|
+
/** Returns a send-only view of this channel. Like Go's `chan<- T`. */
|
|
52
|
+
sendOnly(): SendOnly<T>;
|
|
53
|
+
/** Returns a receive-only view of this channel. Like Go's `<-chan T`. */
|
|
54
|
+
recvOnly(): RecvOnly<T>;
|
|
55
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
56
|
+
}
|
|
57
|
+
/** Send-only view of a channel. Like Go's `chan<- T`. */
|
|
58
|
+
interface SendOnly<T extends ChannelValue> {
|
|
59
|
+
send(value: T): Promise<void>;
|
|
60
|
+
close(): void;
|
|
61
|
+
readonly len: number;
|
|
62
|
+
readonly cap: number;
|
|
63
|
+
}
|
|
64
|
+
/** Receive-only view of a channel. Like Go's `<-chan T`. */
|
|
65
|
+
interface RecvOnly<T extends ChannelValue> {
|
|
66
|
+
recv(): Promise<T | null>;
|
|
67
|
+
readonly len: number;
|
|
68
|
+
readonly cap: number;
|
|
47
69
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
48
70
|
}
|
|
49
71
|
/**
|
|
@@ -76,6 +98,79 @@ interface Channel<T extends ChannelValue> {
|
|
|
76
98
|
*/
|
|
77
99
|
declare function chan<T extends ChannelValue>(capacity?: number): Channel<T>;
|
|
78
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Hierarchical cancellation, deadlines, and request-scoped values — modeled after Go's `context` package.
|
|
103
|
+
*
|
|
104
|
+
* Context is the glue that makes cancellation and timeouts composable. Derive child
|
|
105
|
+
* contexts from a parent: when the parent is cancelled, all children cancel automatically.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* // Timeout a group of tasks
|
|
109
|
+
* const [ctx, cancel] = withTimeout(background(), 5000)
|
|
110
|
+
* const wg = new WaitGroup()
|
|
111
|
+
* wg.spawn(() => longRunningWork())
|
|
112
|
+
* ctx.done().then(() => wg.cancel())
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Nested deadlines
|
|
116
|
+
* const [parent, cancelParent] = withCancel(background())
|
|
117
|
+
* const [child, _] = withTimeout(parent, 1000)
|
|
118
|
+
* // child cancels after 1s OR when cancelParent() is called — whichever comes first
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // Request-scoped values
|
|
122
|
+
* const reqCtx = withValue(background(), 'requestId', 'abc-123')
|
|
123
|
+
* reqCtx.value('requestId') // 'abc-123'
|
|
124
|
+
*/
|
|
125
|
+
/** Returned by `ctx.err` when the context was explicitly cancelled. */
|
|
126
|
+
declare class CancelledError extends Error {
|
|
127
|
+
constructor(message?: string);
|
|
128
|
+
}
|
|
129
|
+
/** Returned by `ctx.err` when the context's deadline has passed. */
|
|
130
|
+
declare class DeadlineExceededError extends Error {
|
|
131
|
+
constructor();
|
|
132
|
+
}
|
|
133
|
+
type ContextError = CancelledError | DeadlineExceededError;
|
|
134
|
+
interface Context {
|
|
135
|
+
/** AbortSignal that fires when this context is cancelled or its deadline expires. */
|
|
136
|
+
readonly signal: AbortSignal;
|
|
137
|
+
/** The deadline for this context, or `null` if none was set. */
|
|
138
|
+
readonly deadline: Date | null;
|
|
139
|
+
/** The cancellation error, or `null` if the context is still active. */
|
|
140
|
+
readonly err: ContextError | null;
|
|
141
|
+
/** Retrieves a value stored in this context or any of its ancestors. */
|
|
142
|
+
value<T = unknown>(key: symbol | string): T | undefined;
|
|
143
|
+
/** Returns a promise that resolves when the context is cancelled. */
|
|
144
|
+
done(): Promise<void>;
|
|
145
|
+
}
|
|
146
|
+
type CancelFunc = (reason?: string) => void;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the root context. It is never cancelled, has no deadline, and carries no values.
|
|
149
|
+
* All other contexts should derive from this.
|
|
150
|
+
*/
|
|
151
|
+
declare function background(): Context;
|
|
152
|
+
/**
|
|
153
|
+
* Returns a child context and a cancel function. Calling `cancel()` cancels the child
|
|
154
|
+
* and all contexts derived from it. The child also cancels when the parent does.
|
|
155
|
+
*/
|
|
156
|
+
declare function withCancel(parent: Context): [Context, CancelFunc];
|
|
157
|
+
/**
|
|
158
|
+
* Returns a child context that automatically cancels at the given `deadline`.
|
|
159
|
+
* If the parent has an earlier deadline, that deadline is inherited.
|
|
160
|
+
* The returned cancel function can cancel early and clears the timer.
|
|
161
|
+
*/
|
|
162
|
+
declare function withDeadline(parent: Context, deadline: Date): [Context, CancelFunc];
|
|
163
|
+
/**
|
|
164
|
+
* Returns a child context that automatically cancels after `ms` milliseconds.
|
|
165
|
+
* Equivalent to `withDeadline(parent, new Date(Date.now() + ms))`.
|
|
166
|
+
*/
|
|
167
|
+
declare function withTimeout(parent: Context, ms: number): [Context, CancelFunc];
|
|
168
|
+
/**
|
|
169
|
+
* Returns a child context carrying a key-value pair.
|
|
170
|
+
* Values are retrieved with `ctx.value(key)` and looked up through the ancestor chain.
|
|
171
|
+
*/
|
|
172
|
+
declare function withValue<T = unknown>(parent: Context, key: symbol | string, value: T): Context;
|
|
173
|
+
|
|
79
174
|
/**
|
|
80
175
|
* Run a function in a worker thread. Returns a handle with the result promise and a cancel function.
|
|
81
176
|
*
|
|
@@ -118,9 +213,10 @@ declare function chan<T extends ChannelValue>(capacity?: number): Channel<T>;
|
|
|
118
213
|
* }, { channels: { ch } })
|
|
119
214
|
*/
|
|
120
215
|
declare function spawn<T extends StructuredCloneValue, TChannels extends Record<string, Channel<ChannelValue>> = Record<never, never>>(fn: (() => T | Promise<T>) | ((channels: TChannels) => T | Promise<T>), opts?: {
|
|
121
|
-
priority?:
|
|
216
|
+
priority?: "low" | "normal" | "high";
|
|
122
217
|
concurrent?: boolean;
|
|
123
218
|
channels?: TChannels;
|
|
219
|
+
ctx?: Context;
|
|
124
220
|
}): SpawnResult<T>;
|
|
125
221
|
|
|
126
222
|
type SpawnChannels$1 = Record<string, Channel<ChannelValue>>;
|
|
@@ -157,6 +253,8 @@ type SpawnChannels$1 = Record<string, Channel<ChannelValue>>;
|
|
|
157
253
|
declare class WaitGroup<T extends StructuredCloneValue = StructuredCloneValue> {
|
|
158
254
|
private tasks;
|
|
159
255
|
private controller;
|
|
256
|
+
private ctx?;
|
|
257
|
+
constructor(ctx?: Context);
|
|
160
258
|
/**
|
|
161
259
|
* An `AbortSignal` shared across all tasks in this group.
|
|
162
260
|
* Pass it into spawned functions so they can stop early when `cancel()` is called.
|
|
@@ -223,11 +321,23 @@ declare class ErrGroup<T extends StructuredCloneValue = StructuredCloneValue> {
|
|
|
223
321
|
private controller;
|
|
224
322
|
private firstError;
|
|
225
323
|
private hasError;
|
|
324
|
+
private ctx?;
|
|
325
|
+
private limit;
|
|
326
|
+
private inFlight;
|
|
327
|
+
private waiting;
|
|
328
|
+
constructor(ctx?: Context);
|
|
226
329
|
get signal(): AbortSignal;
|
|
330
|
+
/**
|
|
331
|
+
* Set the maximum number of tasks that can run concurrently.
|
|
332
|
+
* Like Go's `errgroup.SetLimit()`. Must be called before any `spawn()`.
|
|
333
|
+
* A value of 0 (default) means unlimited.
|
|
334
|
+
*/
|
|
335
|
+
setLimit(n: number): void;
|
|
227
336
|
spawn<TChannels extends SpawnChannels = Record<never, never>>(fn: (() => T | Promise<T>) | ((channels: TChannels) => T | Promise<T>), opts?: {
|
|
228
337
|
concurrent?: boolean;
|
|
229
338
|
channels?: TChannels;
|
|
230
339
|
}): void;
|
|
340
|
+
private doSpawn;
|
|
231
341
|
wait(): Promise<T[]>;
|
|
232
342
|
cancel(): void;
|
|
233
343
|
}
|
|
@@ -269,6 +379,169 @@ declare class Mutex {
|
|
|
269
379
|
withLock<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
270
380
|
get isLocked(): boolean;
|
|
271
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Async read-write mutex. Multiple readers can hold the lock simultaneously,
|
|
384
|
+
* but writers get exclusive access. Modeled after Go's `sync.RWMutex`.
|
|
385
|
+
*
|
|
386
|
+
* Use this instead of `Mutex` when reads vastly outnumber writes — concurrent
|
|
387
|
+
* readers improve throughput without sacrificing write safety.
|
|
388
|
+
*
|
|
389
|
+
* Like `Mutex`, this operates on the main thread only. For cross-thread
|
|
390
|
+
* coordination, use channels instead.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* const rw = new RWMutex()
|
|
394
|
+
*
|
|
395
|
+
* // Multiple readers can run concurrently
|
|
396
|
+
* const data = await rw.withRLock(async () => {
|
|
397
|
+
* return await db.get('config')
|
|
398
|
+
* })
|
|
399
|
+
*
|
|
400
|
+
* // Writers get exclusive access
|
|
401
|
+
* await rw.withLock(async () => {
|
|
402
|
+
* await db.set('config', newValue)
|
|
403
|
+
* })
|
|
404
|
+
*/
|
|
405
|
+
declare class RWMutex {
|
|
406
|
+
private readers;
|
|
407
|
+
private writing;
|
|
408
|
+
private readQueue;
|
|
409
|
+
private writeQueue;
|
|
410
|
+
rLock(): Promise<void>;
|
|
411
|
+
rUnlock(): void;
|
|
412
|
+
lock(): Promise<void>;
|
|
413
|
+
unlock(): void;
|
|
414
|
+
withRLock<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
415
|
+
withLock<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
416
|
+
get isLocked(): boolean;
|
|
417
|
+
private wakeReaders;
|
|
418
|
+
private wakeWriter;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Weighted counting semaphore. Limits concurrent access to a resource where
|
|
423
|
+
* each acquisition can have a different cost. Modeled after Go's
|
|
424
|
+
* `golang.org/x/sync/semaphore.Weighted`.
|
|
425
|
+
*
|
|
426
|
+
* A `Mutex` is equivalent to `new Semaphore(1)` — one holder at a time.
|
|
427
|
+
* A `Semaphore` generalizes this to N units, with variable-weight acquisitions.
|
|
428
|
+
*
|
|
429
|
+
* Like `Mutex`, this operates on the main thread only. For cross-thread
|
|
430
|
+
* coordination, use channels instead.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* // Limit to 10 concurrent DB connections
|
|
434
|
+
* const sem = new Semaphore(10)
|
|
435
|
+
*
|
|
436
|
+
* await sem.acquire() // take 1 slot
|
|
437
|
+
* try {
|
|
438
|
+
* await db.query(...)
|
|
439
|
+
* } finally {
|
|
440
|
+
* sem.release()
|
|
441
|
+
* }
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* // Weighted: heavy queries cost more
|
|
445
|
+
* const sem = new Semaphore(10)
|
|
446
|
+
*
|
|
447
|
+
* await sem.acquire(5) // heavy query takes 5 slots
|
|
448
|
+
* sem.release(5)
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* // withAcquire — recommended (auto-releases on error)
|
|
452
|
+
* const result = await sem.withAcquire(async () => {
|
|
453
|
+
* return await fetch(url)
|
|
454
|
+
* })
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* // Non-blocking check
|
|
458
|
+
* if (sem.tryAcquire(3)) {
|
|
459
|
+
* try { ... } finally { sem.release(3) }
|
|
460
|
+
* }
|
|
461
|
+
*/
|
|
462
|
+
declare class Semaphore {
|
|
463
|
+
private max;
|
|
464
|
+
private cur;
|
|
465
|
+
private queue;
|
|
466
|
+
constructor(n: number);
|
|
467
|
+
/**
|
|
468
|
+
* Acquire `n` permits, waiting if necessary until they are available.
|
|
469
|
+
* Acquires are served in FIFO order.
|
|
470
|
+
*/
|
|
471
|
+
acquire(n?: number): Promise<void>;
|
|
472
|
+
/**
|
|
473
|
+
* Try to acquire `n` permits without blocking.
|
|
474
|
+
* Returns `true` if successful, `false` if not enough permits are available.
|
|
475
|
+
*/
|
|
476
|
+
tryAcquire(n?: number): boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Release `n` permits, potentially waking queued acquirers.
|
|
479
|
+
*/
|
|
480
|
+
release(n?: number): void;
|
|
481
|
+
/**
|
|
482
|
+
* Acquire `n` permits, run `fn`, then release automatically — even if `fn` throws.
|
|
483
|
+
*/
|
|
484
|
+
withAcquire<T>(fn: () => T | Promise<T>, n?: number): Promise<T>;
|
|
485
|
+
/** Number of permits currently available. */
|
|
486
|
+
get available(): number;
|
|
487
|
+
/** Total capacity of the semaphore. */
|
|
488
|
+
get capacity(): number;
|
|
489
|
+
private wake;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Condition variable for async coordination. Modeled after Go's `sync.Cond`.
|
|
494
|
+
*
|
|
495
|
+
* A `Cond` is associated with a `Mutex`. Goroutines (async tasks) can:
|
|
496
|
+
* - `wait()` — atomically release the lock and suspend until signaled, then re-acquire the lock
|
|
497
|
+
* - `signal()` — wake one waiting task
|
|
498
|
+
* - `broadcast()` — wake all waiting tasks
|
|
499
|
+
*
|
|
500
|
+
* Always check the condition in a loop — spurious wakeups are possible if
|
|
501
|
+
* multiple waiters compete for the lock after `broadcast()`.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* const mu = new Mutex()
|
|
505
|
+
* const cond = new Cond(mu)
|
|
506
|
+
* let ready = false
|
|
507
|
+
*
|
|
508
|
+
* // Waiter
|
|
509
|
+
* await mu.lock()
|
|
510
|
+
* while (!ready) {
|
|
511
|
+
* await cond.wait()
|
|
512
|
+
* }
|
|
513
|
+
* console.log('ready!')
|
|
514
|
+
* mu.unlock()
|
|
515
|
+
*
|
|
516
|
+
* // Signaler (from another async context)
|
|
517
|
+
* await mu.lock()
|
|
518
|
+
* ready = true
|
|
519
|
+
* cond.signal()
|
|
520
|
+
* mu.unlock()
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* // Broadcast to wake all waiters
|
|
524
|
+
* await mu.lock()
|
|
525
|
+
* ready = true
|
|
526
|
+
* cond.broadcast()
|
|
527
|
+
* mu.unlock()
|
|
528
|
+
*/
|
|
529
|
+
declare class Cond {
|
|
530
|
+
private mu;
|
|
531
|
+
private waiters;
|
|
532
|
+
constructor(mu: Mutex);
|
|
533
|
+
/**
|
|
534
|
+
* Atomically releases the mutex, suspends the caller until `signal()` or `broadcast()`
|
|
535
|
+
* is called, then re-acquires the mutex before returning.
|
|
536
|
+
*
|
|
537
|
+
* Must be called while holding the mutex.
|
|
538
|
+
*/
|
|
539
|
+
wait(): Promise<void>;
|
|
540
|
+
/** Wake one waiting task (if any). */
|
|
541
|
+
signal(): void;
|
|
542
|
+
/** Wake all waiting tasks. */
|
|
543
|
+
broadcast(): void;
|
|
544
|
+
}
|
|
272
545
|
|
|
273
546
|
/**
|
|
274
547
|
* Run a function exactly once, even if called concurrently.
|
|
@@ -302,7 +575,9 @@ declare class Once<T = void> {
|
|
|
302
575
|
reset(): void;
|
|
303
576
|
}
|
|
304
577
|
|
|
305
|
-
type
|
|
578
|
+
type RecvCase<T = StructuredCloneValue> = [Promise<T>, (value: T) => void];
|
|
579
|
+
type SendCase = [Promise<void>, () => void];
|
|
580
|
+
type SelectCase<T = StructuredCloneValue> = RecvCase<T> | SendCase;
|
|
306
581
|
/**
|
|
307
582
|
* Options for `select()`.
|
|
308
583
|
*
|
|
@@ -318,10 +593,13 @@ interface SelectOptions {
|
|
|
318
593
|
* Each case is a `[promise, handler]` tuple. The handler for the first settled
|
|
319
594
|
* promise is called with its value. All other handlers are ignored.
|
|
320
595
|
*
|
|
596
|
+
* **Recv cases:** `[ch.recv(), (value) => ...]` — handler receives the value.
|
|
597
|
+
* **Send cases:** `[ch.send(value), () => ...]` — handler is called when the send completes.
|
|
598
|
+
*
|
|
321
599
|
* If `opts.default` is provided, `select` becomes non-blocking: if no promise
|
|
322
600
|
* is already resolved, the default runs immediately (Go's `select { default: ... }`).
|
|
323
601
|
*
|
|
324
|
-
* Commonly used with `ch.recv()`, `after()`, and `spawn().result`.
|
|
602
|
+
* Commonly used with `ch.recv()`, `ch.send()`, `after()`, and `spawn().result`.
|
|
325
603
|
*
|
|
326
604
|
* @example
|
|
327
605
|
* // Block until a channel message arrives or timeout after 5s
|
|
@@ -338,6 +616,13 @@ interface SelectOptions {
|
|
|
338
616
|
* )
|
|
339
617
|
*
|
|
340
618
|
* @example
|
|
619
|
+
* // Select with send case — try to send or timeout
|
|
620
|
+
* await select([
|
|
621
|
+
* [ch.send(value), () => console.log('sent!')],
|
|
622
|
+
* [after(1000), () => console.log('send timed out')],
|
|
623
|
+
* ])
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
341
626
|
* // Race two worker results against a deadline
|
|
342
627
|
* const { result: fast } = spawn(() => quickSearch(query))
|
|
343
628
|
* const { result: deep } = spawn(() => deepSearch(query))
|
|
@@ -417,6 +702,54 @@ declare class Ticker {
|
|
|
417
702
|
*/
|
|
418
703
|
declare function ticker(ms: number): Ticker;
|
|
419
704
|
|
|
705
|
+
/**
|
|
706
|
+
* A one-shot timer that can be stopped and reset. Like Go's `time.Timer`.
|
|
707
|
+
*
|
|
708
|
+
* Unlike `after()` which is fire-and-forget, `Timer` gives you control:
|
|
709
|
+
* - `stop()` cancels a pending timer
|
|
710
|
+
* - `reset(ms)` reschedules without allocating a new object
|
|
711
|
+
*
|
|
712
|
+
* The `channel` property is a promise that resolves when the timer fires.
|
|
713
|
+
* After `stop()`, the promise never resolves. After `reset()`, a new `channel`
|
|
714
|
+
* promise is created.
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* // Basic timeout with ability to cancel
|
|
718
|
+
* const t = new Timer(5000)
|
|
719
|
+
* await select([
|
|
720
|
+
* [ch.recv(), (v) => { t.stop(); handle(v) }],
|
|
721
|
+
* [t.channel, () => console.log('timed out')],
|
|
722
|
+
* ])
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* // Reset a timer (e.g., debounce pattern)
|
|
726
|
+
* const t = new Timer(300)
|
|
727
|
+
* onInput(() => t.reset(300))
|
|
728
|
+
* await t.channel // fires 300ms after last input
|
|
729
|
+
*/
|
|
730
|
+
declare class Timer {
|
|
731
|
+
private timer;
|
|
732
|
+
private _stopped;
|
|
733
|
+
/** Promise that resolves when the timer fires. Replaced on `reset()`. */
|
|
734
|
+
channel: Promise<void>;
|
|
735
|
+
constructor(ms: number);
|
|
736
|
+
private schedule;
|
|
737
|
+
/**
|
|
738
|
+
* Stop the timer. Returns `true` if the timer was pending (stopped before firing),
|
|
739
|
+
* `false` if it had already fired or was already stopped.
|
|
740
|
+
*
|
|
741
|
+
* After stopping, the current `channel` promise will never resolve.
|
|
742
|
+
*/
|
|
743
|
+
stop(): boolean;
|
|
744
|
+
/**
|
|
745
|
+
* Reset the timer to fire after `ms` milliseconds.
|
|
746
|
+
* If the timer was pending, it is stopped first. Creates a new `channel` promise.
|
|
747
|
+
*/
|
|
748
|
+
reset(ms: number): void;
|
|
749
|
+
/** Whether the timer has fired or been stopped. */
|
|
750
|
+
get stopped(): boolean;
|
|
751
|
+
}
|
|
752
|
+
|
|
420
753
|
/**
|
|
421
754
|
* Define a reusable task that runs in a worker thread.
|
|
422
755
|
*
|
|
@@ -501,9 +834,9 @@ declare function resize(maxThreads: number): void;
|
|
|
501
834
|
*/
|
|
502
835
|
declare function shutdown(): Promise<void>;
|
|
503
836
|
|
|
504
|
-
type Runtime =
|
|
505
|
-
type Capability =
|
|
837
|
+
type Runtime = "node" | "deno" | "bun" | "browser";
|
|
838
|
+
type Capability = "full-threads" | "single-thread";
|
|
506
839
|
declare function detectRuntime(): Runtime;
|
|
507
840
|
declare function detectCapability(): Capability;
|
|
508
841
|
|
|
509
|
-
export { type Capability, type Channel, ErrGroup, Mutex, Once, type PoolStats, type PuruConfig, type Runtime, type SelectOptions, type SpawnResult, Ticker, WaitGroup, after, chan, configure, detectCapability, detectRuntime, resize, select, shutdown, spawn, stats, task, ticker };
|
|
842
|
+
export { type CancelFunc, CancelledError, type Capability, type Channel, Cond, type Context, type ContextError, DeadlineExceededError, ErrGroup, Mutex, Once, type PoolStats, type PuruConfig, RWMutex, type RecvOnly, type Runtime, type SelectOptions, Semaphore, type SendOnly, type SpawnResult, Ticker, Timer, WaitGroup, after, background, chan, configure, detectCapability, detectRuntime, resize, select, shutdown, spawn, stats, task, ticker, withCancel, withDeadline, withTimeout, withValue };
|