@nlozgachev/pipelined 0.65.0 → 0.66.0
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 +52 -52
- package/dist/{Core-BDXRLmMa.cjs → Core-6SkC-fh5.cjs} +286 -206
- package/dist/{Core-BHN87zoB.mjs → Core-D7_9dZpV.mjs} +281 -201
- package/dist/core.cjs +2 -2
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +2 -2
- package/dist/data.cjs +60 -19
- package/dist/data.d.cts +23 -7
- package/dist/data.d.ts +23 -7
- package/dist/data.mjs +60 -19
- package/dist/{index-DCK_VPog.d.cts → index-8A9NqJTq.d.cts} +189 -152
- package/dist/{index-B07Wr815.d.ts → index-CY4ZLbjM.d.ts} +189 -152
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ propagation, unhandled async rejections, race conditions, and verbose nested spr
|
|
|
19
19
|
|
|
20
20
|
`pipelined` provides discriminated unions and pure combinators to model these conditions explicitly:
|
|
21
21
|
`Maybe` for absence, `Result` for typed failures, `Validation` for multi-error accumulation,
|
|
22
|
-
`Task.Result` for lazy infallible async, `Op` for declarative request concurrency, and `
|
|
23
|
-
typed event
|
|
22
|
+
`Task.Result` for lazy infallible async, `Op` for declarative request concurrency, and `EventBus`
|
|
23
|
+
for typed event dispatching and sequence funnels.
|
|
24
24
|
|
|
25
25
|
The library has zero external dependencies, <11 KB core gzipped (<17 KB total), and compiles to dual
|
|
26
26
|
ESM and CommonJS distributions.
|
|
@@ -382,14 +382,14 @@ form.addEventListener("submit", (e) => {
|
|
|
382
382
|
The system supports a variety of built-in strategies — `restartable`, `exclusive`, `debounced`,
|
|
383
383
|
`throttled`, `queue`, `buffered`, `concurrent`, `keyed`, and `once`.
|
|
384
384
|
|
|
385
|
-
###
|
|
385
|
+
### Typed event dispatching, sequence funnels, and queue safety
|
|
386
386
|
|
|
387
387
|
Decoupling event producers from stateful event consumers often leads to untyped event emitters or
|
|
388
|
-
recursive call stack crashes during event cascades. `
|
|
389
|
-
typed message schemas, multi-step sequence pattern matching, and causal FIFO queue dispatching:
|
|
388
|
+
recursive call stack crashes during event cascades. `EventBus` models in-memory event dispatching
|
|
389
|
+
with typed message schemas, multi-step sequence pattern matching, and causal FIFO queue dispatching:
|
|
390
390
|
|
|
391
391
|
```ts
|
|
392
|
-
import {
|
|
392
|
+
import { EventBus } from "@nlozgachev/pipelined/core";
|
|
393
393
|
|
|
394
394
|
type UserFlowMessages = {
|
|
395
395
|
sessionStarted: { sessionId: string };
|
|
@@ -398,11 +398,11 @@ type UserFlowMessages = {
|
|
|
398
398
|
flowCancelled: { reason: string };
|
|
399
399
|
};
|
|
400
400
|
|
|
401
|
-
const
|
|
401
|
+
const flowBus = EventBus.make<UserFlowMessages>();
|
|
402
402
|
|
|
403
403
|
// Pattern-match the complete multi-step funnel
|
|
404
|
-
const sub =
|
|
405
|
-
|
|
404
|
+
const sub = EventBus.listen(
|
|
405
|
+
flowBus,
|
|
406
406
|
["sessionStarted", "stepCompleted", "flowFinished"],
|
|
407
407
|
{ ordered: true, reset: "flowCancelled" },
|
|
408
408
|
).reduce(
|
|
@@ -415,18 +415,18 @@ const sub = Stream.listen(
|
|
|
415
415
|
{ completedFlows: 0 },
|
|
416
416
|
);
|
|
417
417
|
|
|
418
|
-
// Emit typed messages to the
|
|
419
|
-
|
|
418
|
+
// Emit typed messages to the event bus
|
|
419
|
+
EventBus.emit(flowBus, {
|
|
420
420
|
kind: "sessionStarted",
|
|
421
421
|
value: { sessionId: "sess-101" },
|
|
422
422
|
});
|
|
423
423
|
|
|
424
|
-
|
|
424
|
+
EventBus.emit(flowBus, {
|
|
425
425
|
kind: "stepCompleted",
|
|
426
426
|
value: { stepName: "onboarding" },
|
|
427
427
|
});
|
|
428
428
|
|
|
429
|
-
|
|
429
|
+
EventBus.emit(flowBus, {
|
|
430
430
|
kind: "flowFinished",
|
|
431
431
|
value: { totalTimeMs: 4200 },
|
|
432
432
|
});
|
|
@@ -434,7 +434,7 @@ Stream.emit(flowStream, {
|
|
|
434
434
|
sub.getState(); // { completedFlows: 1 }
|
|
435
435
|
```
|
|
436
436
|
|
|
437
|
-
`
|
|
437
|
+
`EventBus` executes cascading events iteratively using an internal queue with O(1) stack overhead,
|
|
438
438
|
completely preventing stack overflow crashes and out-of-order re-entrant execution.
|
|
439
439
|
|
|
440
440
|
### Deep immutable updates without spread boilerplate
|
|
@@ -504,44 +504,44 @@ if (Result.is.ok(email)) {
|
|
|
504
504
|
|
|
505
505
|
## Quick Reference
|
|
506
506
|
|
|
507
|
-
| Problem to Solve
|
|
508
|
-
|
|
|
509
|
-
| Optional values without `null` / `undefined` checks
|
|
510
|
-
| Synchronous typed errors without `try`/`catch`
|
|
511
|
-
| Multi-field form and batch validation error accumulation
|
|
512
|
-
| Lazy async workflows with automatic `AbortSignal`
|
|
513
|
-
| Infallible async return container for tasks
|
|
514
|
-
| Eliminating impossible UI loading/error/data states
|
|
515
|
-
| Managing request race conditions, retries, and locks
|
|
516
|
-
| In-memory event
|
|
517
|
-
| Deep nested immutable updates without spread boilerplate
|
|
518
|
-
| Implicit dependency injection without prop drilling
|
|
519
|
-
| Pure state transitions, tokenizers, and parsers
|
|
520
|
-
| Deterministic bracket cleanup (DB pools, file locks)
|
|
521
|
-
| Deferred computation memoized on first access
|
|
522
|
-
| Pure calculation audit trails and decision logging
|
|
523
|
-
| Inclusive-OR data modeling and two-way sync diffs
|
|
524
|
-
| Deep structural equality & React component memoization
|
|
525
|
-
| Multi-column table sorting with tiebreakers
|
|
526
|
-
| Composable boolean filter pipelines & authorization policies
|
|
527
|
-
| Runtime type narrowing & custom type guard composition
|
|
528
|
-
| Merging configurations & metric structures (Monoids)
|
|
529
|
-
| Strongly-typed immutable pair manipulation
|
|
530
|
-
| Point-free, bounds-safe array transformations
|
|
531
|
-
| Type-safe object manipulation & key migration
|
|
532
|
-
| Insertion-ordered maps with non-string keys
|
|
533
|
-
| Immutable sets & role/permission algebra
|
|
534
|
-
| String sanitization, numeric conversion & slug parsing
|
|
535
|
-
| Boundary clamping & division-by-zero protection
|
|
536
|
-
| Financial ledger arithmetic without float precision drift
|
|
537
|
-
| Safe JSON parsing & circular reference protection
|
|
538
|
-
| Nominal typing & security boundary gates
|
|
539
|
-
| Explicit, unit-safe time spans & timeout policies
|
|
540
|
-
| Left-to-right value pipeline execution
|
|
541
|
-
| Left-to-right and right-to-left function composition
|
|
542
|
-
| Currying, uncurrying, and argument flipping
|
|
543
|
-
| Multi-branch argument routing and combining
|
|
544
|
-
| Pure function memoization, predicates & pipeline side-effects
|
|
507
|
+
| Problem to Solve | Module | Import Path |
|
|
508
|
+
| ------------------------------------------------------------------ | ----------------------------- | ----------------------------------- |
|
|
509
|
+
| Optional values without `null` / `undefined` checks | `Maybe` | `@nlozgachev/pipelined/core` |
|
|
510
|
+
| Synchronous typed errors without `try`/`catch` | `Result` | `@nlozgachev/pipelined/core` |
|
|
511
|
+
| Multi-field form and batch validation error accumulation | `Validation` | `@nlozgachev/pipelined/core` |
|
|
512
|
+
| Lazy async workflows with automatic `AbortSignal` | `Task.Result`, `Task` | `@nlozgachev/pipelined/core` |
|
|
513
|
+
| Infallible async return container for tasks | `Deferred` | `@nlozgachev/pipelined/core` |
|
|
514
|
+
| Eliminating impossible UI loading/error/data states | `RemoteData` | `@nlozgachev/pipelined/core` |
|
|
515
|
+
| Managing request race conditions, retries, and locks | `Op` | `@nlozgachev/pipelined/core` |
|
|
516
|
+
| In-memory typed event dispatching, sequence funnels & queue safety | `EventBus` | `@nlozgachev/pipelined/core` |
|
|
517
|
+
| Deep nested immutable updates without spread boilerplate | `Lens`, `Optional` | `@nlozgachev/pipelined/core` |
|
|
518
|
+
| Implicit dependency injection without prop drilling | `Reader` | `@nlozgachev/pipelined/core` |
|
|
519
|
+
| Pure state transitions, tokenizers, and parsers | `State` | `@nlozgachev/pipelined/core` |
|
|
520
|
+
| Deterministic bracket cleanup (DB pools, file locks) | `Resource` | `@nlozgachev/pipelined/core` |
|
|
521
|
+
| Deferred computation memoized on first access | `Lazy` | `@nlozgachev/pipelined/core` |
|
|
522
|
+
| Pure calculation audit trails and decision logging | `Logged` | `@nlozgachev/pipelined/core` |
|
|
523
|
+
| Inclusive-OR data modeling and two-way sync diffs | `These` | `@nlozgachev/pipelined/core` |
|
|
524
|
+
| Deep structural equality & React component memoization | `Equality` | `@nlozgachev/pipelined/core` |
|
|
525
|
+
| Multi-column table sorting with tiebreakers | `Ordering` | `@nlozgachev/pipelined/core` |
|
|
526
|
+
| Composable boolean filter pipelines & authorization policies | `Predicate` | `@nlozgachev/pipelined/core` |
|
|
527
|
+
| Runtime type narrowing & custom type guard composition | `Refinement` | `@nlozgachev/pipelined/core` |
|
|
528
|
+
| Merging configurations & metric structures (Monoids) | `Combinable` | `@nlozgachev/pipelined/core` |
|
|
529
|
+
| Strongly-typed immutable pair manipulation | `Pair` | `@nlozgachev/pipelined/core` |
|
|
530
|
+
| Point-free, bounds-safe array transformations | `Arr`, `Arr.NonEmpty` | `@nlozgachev/pipelined/data` |
|
|
531
|
+
| Type-safe object manipulation & key migration | `Rec`, `Rec.NonEmpty` | `@nlozgachev/pipelined/data` |
|
|
532
|
+
| Insertion-ordered maps with non-string keys | `Dict`, `Dict.NonEmpty` | `@nlozgachev/pipelined/data` |
|
|
533
|
+
| Immutable sets & role/permission algebra | `Uniq` | `@nlozgachev/pipelined/data` |
|
|
534
|
+
| String sanitization, numeric conversion & slug parsing | `Str` | `@nlozgachev/pipelined/data` |
|
|
535
|
+
| Boundary clamping & division-by-zero protection | `Num` | `@nlozgachev/pipelined/data` |
|
|
536
|
+
| Financial ledger arithmetic without float precision drift | `BigNum` | `@nlozgachev/pipelined/data` |
|
|
537
|
+
| Safe JSON parsing & circular reference protection | `Json` | `@nlozgachev/pipelined/data` |
|
|
538
|
+
| Nominal typing & security boundary gates | `Brand` | `@nlozgachev/pipelined/types` |
|
|
539
|
+
| Explicit, unit-safe time spans & timeout policies | `Duration`, `RetryPolicy` | `@nlozgachev/pipelined/types` |
|
|
540
|
+
| Left-to-right value pipeline execution | `pipe` | `@nlozgachev/pipelined/composition` |
|
|
541
|
+
| Left-to-right and right-to-left function composition | `flow`, `compose` | `@nlozgachev/pipelined/composition` |
|
|
542
|
+
| Currying, uncurrying, and argument flipping | `curry`, `uncurry`, `flip` | `@nlozgachev/pipelined/composition` |
|
|
543
|
+
| Multi-branch argument routing and combining | `converge`, `juxt`, `on` | `@nlozgachev/pipelined/composition` |
|
|
544
|
+
| Pure function memoization, predicates & pipeline side-effects | `memoize`, `tap`, `not`, `fn` | `@nlozgachev/pipelined/composition` |
|
|
545
545
|
|
|
546
546
|
---
|
|
547
547
|
|