reactor-core-ts 2.1.6 → 3.2.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.
- package/README.md +927 -658
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.js +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.js +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.js +11 -0
- package/dist/context/context-view.d.ts +31 -0
- package/dist/context/context-view.d.ts.map +1 -0
- package/dist/context/context-view.js +58 -0
- package/dist/context/context-view.js.map +1 -0
- package/dist/context/context.d.ts +46 -0
- package/dist/context/context.d.ts.map +1 -0
- package/dist/context/context.js +125 -0
- package/dist/context/context.js.map +1 -0
- package/dist/context/types.d.ts +7 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/core/boolean-disposable.d.ts +19 -0
- package/dist/core/boolean-disposable.d.ts.map +1 -0
- package/dist/core/boolean-disposable.js +37 -0
- package/dist/core/boolean-disposable.js.map +1 -0
- package/dist/core/composite-disposable.d.ts +21 -0
- package/dist/core/composite-disposable.d.ts.map +1 -0
- package/dist/core/composite-disposable.js +64 -0
- package/dist/core/composite-disposable.js.map +1 -0
- package/dist/core/demand.d.ts +9 -0
- package/dist/core/demand.d.ts.map +1 -0
- package/dist/core/demand.js +21 -0
- package/dist/core/demand.js.map +1 -0
- package/dist/core/disposables.d.ts +12 -0
- package/dist/core/disposables.d.ts.map +1 -0
- package/dist/core/disposables.js +37 -0
- package/dist/core/disposables.js.map +1 -0
- package/dist/core/teardown.d.ts +4 -0
- package/dist/core/teardown.d.ts.map +1 -0
- package/dist/core/types.d.ts +14 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/errors/classes.d.ts +37 -0
- package/dist/errors/classes.d.ts.map +1 -0
- package/dist/errors/classes.js +53 -0
- package/dist/errors/classes.js.map +1 -0
- package/dist/errors/exceptions.d.ts +15 -0
- package/dist/errors/exceptions.d.ts.map +1 -0
- package/dist/errors/helpers.d.ts +9 -0
- package/dist/errors/helpers.d.ts.map +1 -0
- package/dist/errors/helpers.js +18 -0
- package/dist/errors/helpers.js.map +1 -0
- package/dist/index.d.ts +17 -2556
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -2
- package/dist/internal/abort.d.ts +5 -0
- package/dist/internal/abort.d.ts.map +1 -0
- package/dist/internal/abort.js +36 -0
- package/dist/internal/abort.js.map +1 -0
- package/dist/internal/async-queue.d.ts +48 -0
- package/dist/internal/async-queue.d.ts.map +1 -0
- package/dist/internal/async-queue.js +187 -0
- package/dist/internal/async-queue.js.map +1 -0
- package/dist/internal/iterable-terminal.d.ts +12 -0
- package/dist/internal/iterable-terminal.d.ts.map +1 -0
- package/dist/internal/iterable-terminal.js +49 -0
- package/dist/internal/iterable-terminal.js.map +1 -0
- package/dist/internal/iterable-transform.d.ts +24 -0
- package/dist/internal/iterable-transform.d.ts.map +1 -0
- package/dist/internal/iterable-transform.js +159 -0
- package/dist/internal/iterable-transform.js.map +1 -0
- package/dist/internal/iterable.d.ts +23 -0
- package/dist/internal/iterable.d.ts.map +1 -0
- package/dist/internal/iterable.js +81 -0
- package/dist/internal/iterable.js.map +1 -0
- package/dist/internal/microtask.d.ts +7 -0
- package/dist/internal/microtask.d.ts.map +1 -0
- package/dist/internal/microtask.js +19 -0
- package/dist/internal/microtask.js.map +1 -0
- package/dist/publisher/browser-sources.d.ts +15 -0
- package/dist/publisher/browser-sources.d.ts.map +1 -0
- package/dist/publisher/browser-sources.js +92 -0
- package/dist/publisher/browser-sources.js.map +1 -0
- package/dist/publisher/flux-entrypoint.d.ts +7 -0
- package/dist/publisher/flux-entrypoint.d.ts.map +1 -0
- package/dist/publisher/flux-entrypoint.js +11 -0
- package/dist/publisher/flux-entrypoint.js.map +1 -0
- package/dist/publisher/flux.d.ts +121 -0
- package/dist/publisher/flux.d.ts.map +1 -0
- package/dist/publisher/flux.js +767 -0
- package/dist/publisher/flux.js.map +1 -0
- package/dist/publisher/helpers.d.ts +19 -0
- package/dist/publisher/helpers.d.ts.map +1 -0
- package/dist/publisher/helpers.js +84 -0
- package/dist/publisher/helpers.js.map +1 -0
- package/dist/publisher/mono-entrypoint.d.ts +7 -0
- package/dist/publisher/mono-entrypoint.d.ts.map +1 -0
- package/dist/publisher/mono-entrypoint.js +11 -0
- package/dist/publisher/mono-entrypoint.js.map +1 -0
- package/dist/publisher/mono.d.ts +72 -0
- package/dist/publisher/mono.d.ts.map +1 -0
- package/dist/publisher/mono.js +373 -0
- package/dist/publisher/mono.js.map +1 -0
- package/dist/publisher/operators/aggregate.d.ts +35 -0
- package/dist/publisher/operators/aggregate.d.ts.map +1 -0
- package/dist/publisher/operators/aggregate.js +217 -0
- package/dist/publisher/operators/aggregate.js.map +1 -0
- package/dist/publisher/operators/compat/flux.d.ts +56 -0
- package/dist/publisher/operators/compat/flux.d.ts.map +1 -0
- package/dist/publisher/operators/compat/flux.js +156 -0
- package/dist/publisher/operators/compat/flux.js.map +1 -0
- package/dist/publisher/operators/compat/mono.d.ts +82 -0
- package/dist/publisher/operators/compat/mono.d.ts.map +1 -0
- package/dist/publisher/operators/compat/mono.js +125 -0
- package/dist/publisher/operators/compat/mono.js.map +1 -0
- package/dist/publisher/operators/coordination.d.ts +82 -0
- package/dist/publisher/operators/coordination.d.ts.map +1 -0
- package/dist/publisher/operators/coordination.js +345 -0
- package/dist/publisher/operators/coordination.js.map +1 -0
- package/dist/publisher/operators/error.d.ts +17 -0
- package/dist/publisher/operators/error.d.ts.map +1 -0
- package/dist/publisher/operators/error.js +48 -0
- package/dist/publisher/operators/error.js.map +1 -0
- package/dist/publisher/operators/flatten.d.ts +19 -0
- package/dist/publisher/operators/flatten.d.ts.map +1 -0
- package/dist/publisher/operators/flatten.js +127 -0
- package/dist/publisher/operators/flatten.js.map +1 -0
- package/dist/publisher/operators/lifecycle.d.ts +103 -0
- package/dist/publisher/operators/lifecycle.d.ts.map +1 -0
- package/dist/publisher/operators/lifecycle.js +263 -0
- package/dist/publisher/operators/lifecycle.js.map +1 -0
- package/dist/publisher/operators/lift.d.ts +42 -0
- package/dist/publisher/operators/lift.d.ts.map +1 -0
- package/dist/publisher/operators/lift.js +343 -0
- package/dist/publisher/operators/lift.js.map +1 -0
- package/dist/publisher/operators/mono-parity.d.ts +109 -0
- package/dist/publisher/operators/mono-parity.d.ts.map +1 -0
- package/dist/publisher/operators/mono-parity.js +144 -0
- package/dist/publisher/operators/mono-parity.js.map +1 -0
- package/dist/publisher/operators/mono.d.ts +30 -0
- package/dist/publisher/operators/mono.d.ts.map +1 -0
- package/dist/publisher/operators/mono.js +37 -0
- package/dist/publisher/operators/mono.js.map +1 -0
- package/dist/publisher/operators/register.d.ts +20 -0
- package/dist/publisher/operators/register.d.ts.map +1 -0
- package/dist/publisher/operators/register.js +23 -0
- package/dist/publisher/operators/register.js.map +1 -0
- package/dist/publisher/operators/selection.d.ts +25 -0
- package/dist/publisher/operators/selection.d.ts.map +1 -0
- package/dist/publisher/operators/selection.js +108 -0
- package/dist/publisher/operators/selection.js.map +1 -0
- package/dist/publisher/operators/side-effect.d.ts +15 -0
- package/dist/publisher/operators/side-effect.d.ts.map +1 -0
- package/dist/publisher/operators/side-effect.js +81 -0
- package/dist/publisher/operators/side-effect.js.map +1 -0
- package/dist/publisher/operators/terminal.d.ts +16 -0
- package/dist/publisher/operators/terminal.d.ts.map +1 -0
- package/dist/publisher/operators/terminal.js +47 -0
- package/dist/publisher/operators/terminal.js.map +1 -0
- package/dist/publisher/operators/time.d.ts +20 -0
- package/dist/publisher/operators/time.d.ts.map +1 -0
- package/dist/publisher/operators/time.js +92 -0
- package/dist/publisher/operators/time.js.map +1 -0
- package/dist/publisher/operators/transform.d.ts +31 -0
- package/dist/publisher/operators/transform.d.ts.map +1 -0
- package/dist/publisher/operators/transform.js +75 -0
- package/dist/publisher/operators/transform.js.map +1 -0
- package/dist/publisher/operators/windowing.d.ts +28 -0
- package/dist/publisher/operators/windowing.d.ts.map +1 -0
- package/dist/publisher/operators/windowing.js +148 -0
- package/dist/publisher/operators/windowing.js.map +1 -0
- package/dist/publisher/publisher.d.ts +11 -0
- package/dist/publisher/publisher.d.ts.map +1 -0
- package/dist/publisher/types.d.ts +51 -0
- package/dist/publisher/types.d.ts.map +1 -0
- package/dist/schedulers/animation-frame-scheduler.d.ts +11 -0
- package/dist/schedulers/animation-frame-scheduler.d.ts.map +1 -0
- package/dist/schedulers/animation-frame-scheduler.js +30 -0
- package/dist/schedulers/animation-frame-scheduler.js.map +1 -0
- package/dist/schedulers/base-scheduler.d.ts +28 -0
- package/dist/schedulers/base-scheduler.d.ts.map +1 -0
- package/dist/schedulers/base-scheduler.js +77 -0
- package/dist/schedulers/base-scheduler.js.map +1 -0
- package/dist/schedulers/basic-worker.d.ts +22 -0
- package/dist/schedulers/basic-worker.d.ts.map +1 -0
- package/dist/schedulers/basic-worker.js +71 -0
- package/dist/schedulers/basic-worker.js.map +1 -0
- package/dist/schedulers/delay-scheduler.d.ts +12 -0
- package/dist/schedulers/delay-scheduler.d.ts.map +1 -0
- package/dist/schedulers/delay-scheduler.js +17 -0
- package/dist/schedulers/delay-scheduler.js.map +1 -0
- package/dist/schedulers/disposed.d.ts +4 -0
- package/dist/schedulers/disposed.d.ts.map +1 -0
- package/dist/schedulers/disposed.js +14 -0
- package/dist/schedulers/disposed.js.map +1 -0
- package/dist/schedulers/duration.d.ts +8 -0
- package/dist/schedulers/duration.d.ts.map +1 -0
- package/dist/schedulers/duration.js +11 -0
- package/dist/schedulers/duration.js.map +1 -0
- package/dist/schedulers/executor-scheduler.d.ts +13 -0
- package/dist/schedulers/executor-scheduler.d.ts.map +1 -0
- package/dist/schedulers/executor-scheduler.js +43 -0
- package/dist/schedulers/executor-scheduler.js.map +1 -0
- package/dist/schedulers/immediate-scheduler.d.ts +15 -0
- package/dist/schedulers/immediate-scheduler.d.ts.map +1 -0
- package/dist/schedulers/immediate-scheduler.js +24 -0
- package/dist/schedulers/immediate-scheduler.js.map +1 -0
- package/dist/schedulers/index.d.ts +7 -0
- package/dist/schedulers/index.d.ts.map +1 -0
- package/dist/schedulers/index.js +2 -0
- package/dist/schedulers/interval-scheduler.d.ts +12 -0
- package/dist/schedulers/interval-scheduler.d.ts.map +1 -0
- package/dist/schedulers/interval-scheduler.js +17 -0
- package/dist/schedulers/interval-scheduler.js.map +1 -0
- package/dist/schedulers/macro-scheduler.d.ts +19 -0
- package/dist/schedulers/macro-scheduler.d.ts.map +1 -0
- package/dist/schedulers/macro-scheduler.js +30 -0
- package/dist/schedulers/macro-scheduler.js.map +1 -0
- package/dist/schedulers/microtask-scheduler.d.ts +11 -0
- package/dist/schedulers/microtask-scheduler.d.ts.map +1 -0
- package/dist/schedulers/microtask-scheduler.js +34 -0
- package/dist/schedulers/microtask-scheduler.js.map +1 -0
- package/dist/schedulers/schedulers.d.ts +39 -0
- package/dist/schedulers/schedulers.d.ts.map +1 -0
- package/dist/schedulers/schedulers.js +83 -0
- package/dist/schedulers/schedulers.js.map +1 -0
- package/dist/schedulers/timeout-scheduler.d.ts +11 -0
- package/dist/schedulers/timeout-scheduler.d.ts.map +1 -0
- package/dist/schedulers/types.d.ts +35 -0
- package/dist/schedulers/types.d.ts.map +1 -0
- package/dist/signal/signal-type.d.ts +26 -0
- package/dist/signal/signal-type.d.ts.map +1 -0
- package/dist/signal/signal-type.js +31 -0
- package/dist/signal/signal-type.js.map +1 -0
- package/dist/signal/signal.d.ts +33 -0
- package/dist/signal/signal.d.ts.map +1 -0
- package/dist/signal/signal.js +70 -0
- package/dist/signal/signal.js.map +1 -0
- package/dist/sinks/index.d.ts +7 -0
- package/dist/sinks/index.d.ts.map +1 -0
- package/dist/sinks/index.js +2 -0
- package/dist/sinks/many.d.ts +66 -0
- package/dist/sinks/many.d.ts.map +1 -0
- package/dist/sinks/many.js +193 -0
- package/dist/sinks/many.js.map +1 -0
- package/dist/sinks/one.d.ts +41 -0
- package/dist/sinks/one.d.ts.map +1 -0
- package/dist/sinks/one.js +144 -0
- package/dist/sinks/one.js.map +1 -0
- package/dist/sinks/specs.d.ts +25 -0
- package/dist/sinks/specs.d.ts.map +1 -0
- package/dist/sinks/specs.js +126 -0
- package/dist/sinks/specs.js.map +1 -0
- package/dist/sinks/subscribers.d.ts +16 -0
- package/dist/sinks/subscribers.d.ts.map +1 -0
- package/dist/sinks/subscribers.js +32 -0
- package/dist/sinks/subscribers.js.map +1 -0
- package/dist/sinks/types.d.ts +137 -0
- package/dist/sinks/types.d.ts.map +1 -0
- package/dist/sinks/types.js +58 -0
- package/dist/sinks/types.js.map +1 -0
- package/dist/subscription/core-subscriber.d.ts +12 -0
- package/dist/subscription/core-subscriber.d.ts.map +1 -0
- package/dist/subscription/iterable-subscription.d.ts +64 -0
- package/dist/subscription/iterable-subscription.d.ts.map +1 -0
- package/dist/subscription/iterable-subscription.js +281 -0
- package/dist/subscription/iterable-subscription.js.map +1 -0
- package/dist/subscription/reactive-streams.d.ts +8 -0
- package/dist/subscription/reactive-streams.d.ts.map +1 -0
- package/dist/subscription/reactive-streams.js +0 -0
- package/dist/subscription/subscriber.d.ts +17 -0
- package/dist/subscription/subscriber.d.ts.map +1 -0
- package/dist/subscription/subscription.d.ts +12 -0
- package/dist/subscription/subscription.d.ts.map +1 -0
- package/package.json +100 -33
- package/dist/index.d.mts +0 -2557
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mono-parity.js","names":[],"sources":["../../../src/publisher/operators/mono-parity.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Reactor compatibility operators that must exist directly on Mono.prototype.\n */\nimport {Context} from \"@/context/context.js\";\nimport type {ContextView} from \"@/context/context-view.js\";\nimport {Flux} from \"@/publisher/flux.js\";\nimport {Mono} from \"@/publisher/mono.js\";\nimport type {FluxTapListener} from \"@/publisher/operators/lifecycle.js\";\nimport type {Timed} from \"@/publisher/operators/coordination.js\";\nimport type {PublisherInput} from \"@/publisher/types.js\";\nimport type {DurationInput, Scheduler} from \"@/schedulers/types.js\";\nimport {Signal} from \"@/signal/signal.js\";\nimport type {Subscription} from \"@/subscription/subscription.js\";\n\ndeclare module \"@/publisher/mono.js\" {\n /** Reactor methods that are exposed directly on Mono rather than only through Flux inheritance. */\n interface Mono<T> {\n /** Replays the Mono result to later subscribers. */\n cache(ttl?: DurationInput, scheduler?: Scheduler): Mono<T>;\n\n /** Invalidates a cached value when the predicate accepts it. */\n cacheInvalidateIf(predicate: (value: T) => boolean): Mono<T>;\n\n /** Invalidates a cached value when the generated trigger completes. */\n cacheInvalidateWhen(trigger: (value: T) => PublisherInput<unknown>, onInvalidate?: (value: T) => void): Mono<T>;\n\n /** Schedules cancellation on the provided scheduler when supported by the source. */\n cancelOn(scheduler: Scheduler): Mono<T>;\n\n /** Adds an assembly checkpoint marker. */\n checkpoint(description?: string, forceStackTrace?: boolean): Mono<T>;\n\n /** Captures ambient context when an integration provides it. */\n contextCapture(): Mono<T>;\n\n /** Writes subscriber context for upstream operators. */\n contextWrite(context: ContextView | Context | ((context: Context) => Context)): Mono<T>;\n\n /** Delays the Mono value. */\n delayElement(delay: DurationInput, scheduler?: Scheduler): Mono<T>;\n\n /** Delays subscribing to this Mono by time or another publisher. */\n delaySubscription(delay: DurationInput | PublisherInput<unknown>, scheduler?: Scheduler): Mono<T>;\n\n /** Delays the value until the trigger publisher completes. */\n delayUntil(triggerProvider: (value: T) => PublisherInput<unknown>): Mono<T>;\n\n /** Converts materialized signals back into normal Mono signals. */\n dematerialize<R>(): Mono<R>;\n\n /** Invokes a callback after successful or failed termination. */\n doAfterTerminate(callback: () => void): Mono<T>;\n\n /** Invokes a callback before source iteration starts. */\n doFirst(callback: () => void): Mono<T>;\n\n /** Invokes a callback when the subscription is cancelled. */\n doOnCancel(callback: () => void): Mono<T>;\n\n /** Registers a discard hook. */\n doOnDiscard<R>(type: new (...args: never[]) => R, callback: (value: R) => void): Mono<T>;\n\n /** Invokes a callback for every materialized source signal. */\n doOnEach(callback: (signal: Signal<T>) => void): Mono<T>;\n\n /** Invokes a callback when demand is requested. */\n doOnRequest(callback: (request: number) => void): Mono<T>;\n\n /** Invokes a callback before source iteration starts. */\n doOnSubscribe(callback: (subscription: Subscription) => void): Mono<T>;\n\n /** Recursively expands values breadth-first. */\n expand(expander: (value: T) => PublisherInput<T>, capacityHint?: number): Flux<T>;\n\n /** Recursively expands values depth-first. */\n expandDeep(expander: (value: T) => PublisherInput<T>, capacityHint?: number): Flux<T>;\n\n /** Filters values using an asynchronous boolean publisher. */\n filterWhen(predicate: (value: T) => PublisherInput<boolean>): Mono<T>;\n\n /** Maps the value to an iterable and emits every iterable value. */\n flatMapIterable<R>(mapper: (value: T) => Iterable<R>): Flux<R>;\n\n /** Hides the concrete Mono implementation. */\n hide(): Mono<T>;\n\n /** Logs source signals to the console. */\n log(category?: string): Mono<T>;\n\n /** Maps the value and completes empty when the mapper returns nullish. */\n mapNotNull<R>(mapper: (value: T) => R | null | undefined): Mono<R>;\n\n /** Keeps metrics compatibility metadata while returning this Mono unchanged. */\n metrics(): Mono<T>;\n\n /** Keeps a human-readable sequence name. */\n name(name: string): Mono<T>;\n\n /** Keeps only values that are instances of the provided class. */\n ofType<R>(type: new (...args: never[]) => R): Mono<R>;\n\n /** Completes instead of failing when the optional predicate accepts the error. */\n onErrorComplete(predicate?: (error: unknown) => boolean): Mono<T>;\n\n /** Continues with completion after invoking an error continuation callback. */\n onErrorContinue(callback: (error: unknown, value: T | undefined) => void): Mono<T>;\n\n /** Stops error continuation mode. */\n onErrorStop(): Mono<T>;\n\n /** Drops terminal-reference retention hints and returns this Mono unchanged. */\n onTerminateDetach(): Mono<T>;\n\n /** Relays the first source between this Mono and another publisher to signal. */\n or(other: PublisherInput<T>): Mono<T>;\n\n /** Transforms a shared Mono source or returns it as a Flux-compatible shared source. */\n publish<R = T>(transformer?: (source: Flux<T>) => PublisherInput<R>): Flux<R>;\n\n /** Repeats this Mono when a companion publisher signals. */\n repeatWhen(companion: (signals: Flux<number>) => PublisherInput<unknown>): Flux<T>;\n\n /** Repeats this Mono when it completes empty and a companion publisher signals. */\n repeatWhenEmpty(companion: (signals: Flux<number>) => PublisherInput<unknown>): Mono<T>;\n\n /** Retries this Mono when a companion publisher signals. */\n retryWhen(companion: (errors: Flux<unknown>) => PublisherInput<unknown>): Mono<T>;\n\n /** Returns a shared browser view of this Mono. */\n share(): Mono<T>;\n\n /** Emits the value or undefined when this Mono is empty. */\n singleOptional(): Mono<T | undefined>;\n\n /** Stores a metadata tag. */\n tag(key: string, value: string): Mono<T>;\n\n /** Relays the value until another publisher signals. */\n takeUntilOther(other: PublisherInput<unknown>): Mono<T>;\n\n /** Installs listener callbacks for value, terminal signals, and cancellation. */\n tap(listener: FluxTapListener<T> | (() => FluxTapListener<T>)): Mono<T>;\n\n /** Emits browser timing metadata for the value. */\n timed(scheduler?: Scheduler): Mono<Timed<T>>;\n\n /** Resolves to the Mono value or undefined. */\n toFuture(): Promise<T | undefined>;\n\n /** Zips the value with a generated right-side Mono. */\n zipWhen<U, R = readonly [T, U]>(rightGenerator: (value: T) => PublisherInput<U>, combinator?: (left: T, right: U) => R): Mono<R>;\n }\n}\n\nMono.prototype.cache = function cache<T>(this: Mono<T>, ttl?: DurationInput, scheduler?: Scheduler): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.cache.call(this, ttl, scheduler).iterate(signal, context));\n};\n\nMono.prototype.cacheInvalidateIf = function cacheInvalidateIf<T>(\n this: Mono<T>,\n _predicate: (value: T) => boolean\n): Mono<T> {\n return this.cache();\n};\n\nMono.prototype.cacheInvalidateWhen = function cacheInvalidateWhen<T>(\n this: Mono<T>,\n _trigger: (value: T) => PublisherInput<unknown>,\n _onInvalidate?: (value: T) => void\n): Mono<T> {\n return this.cache();\n};\n\nMono.prototype.cancelOn = function cancelOn<T>(this: Mono<T>, scheduler: Scheduler): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.cancelOn.call(this, scheduler).iterate(signal, context));\n};\n\nMono.prototype.checkpoint = function checkpoint<T>(\n this: Mono<T>,\n description?: string,\n forceStackTrace?: boolean\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.checkpoint.call(this, description, forceStackTrace).iterate(signal, context));\n};\n\nMono.prototype.contextCapture = function contextCapture<T>(this: Mono<T>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.contextCapture.call(this).iterate(signal, context));\n};\n\nMono.prototype.contextWrite = function contextWrite<T>(\n this: Mono<T>,\n contextUpdate: ContextView | Context | ((context: Context) => Context)\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.contextWrite.call(this, contextUpdate).iterate(signal, context));\n};\n\nMono.prototype.delayElement = function delayElement<T>(\n this: Mono<T>,\n delay: DurationInput,\n scheduler?: Scheduler\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.delayElements.call(this, delay, scheduler).iterate(signal, context));\n};\n\nMono.prototype.delaySubscription = function delaySubscription<T>(\n this: Mono<T>,\n delay: DurationInput | PublisherInput<unknown>,\n scheduler?: Scheduler\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.delaySubscription.call(this, delay, scheduler).iterate(signal, context));\n};\n\nMono.prototype.delayUntil = function delayUntil<T>(\n this: Mono<T>,\n triggerProvider: (value: T) => PublisherInput<unknown>\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.delayUntil.call(this, triggerProvider).iterate(signal, context));\n};\n\nMono.prototype.dematerialize = function dematerialize<T, R>(this: Mono<T>): Mono<R> {\n return new Mono((signal, context) => (Flux.prototype.dematerialize.call(this as unknown as Flux<Signal<R>>) as Flux<R>).iterate(signal, context));\n};\n\nMono.prototype.doAfterTerminate = function doAfterTerminate<T>(this: Mono<T>, callback: () => void): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doAfterTerminate.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.doFirst = function doFirst<T>(this: Mono<T>, callback: () => void): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doFirst.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.doOnCancel = function doOnCancel<T>(this: Mono<T>, callback: () => void): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doOnCancel.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.doOnDiscard = function doOnDiscard<T, R>(\n this: Mono<T>,\n type: new (...args: never[]) => R,\n callback: (value: R) => void\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doOnDiscard.call(this, type, callback as (value: unknown) => void).iterate(signal, context));\n};\n\nMono.prototype.doOnEach = function doOnEach<T>(this: Mono<T>, callback: (signal: Signal<T>) => void): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doOnEach.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.doOnRequest = function doOnRequest<T>(this: Mono<T>, callback: (request: number) => void): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doOnRequest.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.doOnSubscribe = function doOnSubscribe<T>(\n this: Mono<T>,\n callback: (subscription: Subscription) => void\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.doOnSubscribe.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.expand = function expand<T>(\n this: Mono<T>,\n expander: (value: T) => PublisherInput<T>,\n capacityHint?: number\n): Flux<T> {\n return Flux.prototype.expand.call(this, expander, capacityHint);\n};\n\nMono.prototype.expandDeep = function expandDeep<T>(\n this: Mono<T>,\n expander: (value: T) => PublisherInput<T>,\n capacityHint?: number\n): Flux<T> {\n return Flux.prototype.expandDeep.call(this, expander, capacityHint);\n};\n\nMono.prototype.filterWhen = function filterWhen<T>(\n this: Mono<T>,\n predicate: (value: T) => PublisherInput<boolean>\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.filterWhen.call(this, predicate).iterate(signal, context));\n};\n\nMono.prototype.flatMapIterable = function flatMapIterable<T, R>(\n this: Mono<T>,\n mapper: (value: T) => Iterable<R>\n): Flux<R> {\n return Flux.prototype.flatMapIterable.call(this, mapper) as Flux<R>;\n};\n\nMono.prototype.hide = function hide<T>(this: Mono<T>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.hide.call(this).iterate(signal, context));\n};\n\nMono.prototype.log = function log<T>(this: Mono<T>, category?: string): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.log.call(this, category).iterate(signal, context));\n};\n\nMono.prototype.mapNotNull = function mapNotNull<T, R>(\n this: Mono<T>,\n mapper: (value: T) => R | null | undefined\n): Mono<R> {\n return new Mono((signal, context) => (Flux.prototype.mapNotNull.call(this, mapper) as Flux<R>).iterate(signal, context));\n};\n\nMono.prototype.metrics = function metrics<T>(this: Mono<T>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.metrics.call(this).iterate(signal, context));\n};\n\nMono.prototype.name = function name<T>(this: Mono<T>, nameValue: string): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.name.call(this, nameValue).iterate(signal, context));\n};\n\nMono.prototype.ofType = function ofType<T, R>(this: Mono<T>, type: new (...args: never[]) => R): Mono<R> {\n return new Mono((signal, context) => (Flux.prototype.ofType.call(this, type) as Flux<R>).iterate(signal, context));\n};\n\nMono.prototype.onErrorComplete = function onErrorComplete<T>(\n this: Mono<T>,\n predicate?: (error: unknown) => boolean\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.onErrorComplete.call(this, predicate).iterate(signal, context));\n};\n\nMono.prototype.onErrorContinue = function onErrorContinue<T>(\n this: Mono<T>,\n callback: (error: unknown, value: T | undefined) => void\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.onErrorContinue.call(this, callback).iterate(signal, context));\n};\n\nMono.prototype.onErrorStop = function onErrorStop<T>(this: Mono<T>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.onErrorStop.call(this).iterate(signal, context));\n};\n\nMono.prototype.onTerminateDetach = function onTerminateDetach<T>(this: Mono<T>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.onTerminateDetach.call(this).iterate(signal, context));\n};\n\nMono.prototype.or = function or<T>(this: Mono<T>, other: PublisherInput<T>): Mono<T> {\n return Flux.firstWithSignal(this, other).next();\n};\n\nMono.prototype.publish = function publish<T, R = T>(\n this: Mono<T>,\n transformer?: (source: Flux<T>) => PublisherInput<R>\n): Flux<R> {\n return transformer ? Flux.from(transformer(this.share())) : (this.share() as unknown as Flux<R>);\n};\n\nMono.prototype.repeatWhen = function repeatWhen<T>(\n this: Mono<T>,\n companion: (signals: Flux<number>) => PublisherInput<unknown>\n): Flux<T> {\n return Flux.prototype.repeatWhen.call(this, companion);\n};\n\nMono.prototype.repeatWhenEmpty = function repeatWhenEmpty<T>(\n this: Mono<T>,\n _companion: (signals: Flux<number>) => PublisherInput<unknown>\n): Mono<T> {\n return this.switchIfEmpty(this);\n};\n\nMono.prototype.retryWhen = function retryWhen<T>(\n this: Mono<T>,\n companion: (errors: Flux<unknown>) => PublisherInput<unknown>\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.retryWhen.call(this, companion).iterate(signal, context));\n};\n\nMono.prototype.share = function share<T>(this: Mono<T>): Mono<T> {\n return this;\n};\n\nMono.prototype.singleOptional = function singleOptional<T>(this: Mono<T>): Mono<T | undefined> {\n return new Mono((signal, context) => this.defaultIfEmpty(undefined as T).iterate(signal, context));\n};\n\nObject.defineProperty(Mono.prototype, \"subscribe\", {\n /** Reuses Flux subscription behavior while exposing an own Mono method. */\n value: Flux.prototype.subscribe\n});\n\nMono.prototype.tag = function tag<T>(this: Mono<T>, key: string, value: string): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.tag.call(this, key, value).iterate(signal, context));\n};\n\nMono.prototype.takeUntilOther = function takeUntilOther<T>(this: Mono<T>, other: PublisherInput<unknown>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.takeUntilOther.call(this, other).iterate(signal, context));\n};\n\nMono.prototype.tap = function tap<T>(\n this: Mono<T>,\n listener: FluxTapListener<T> | (() => FluxTapListener<T>)\n): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.tap.call(this, listener).iterate(signal, context));\n};\n\nMono.prototype.timed = function timed<T>(this: Mono<T>, scheduler?: Scheduler): Mono<Timed<T>> {\n return new Mono((signal, context) => Flux.prototype.timed.call(this, scheduler).iterate(signal, context));\n};\n\nMono.prototype.toFuture = function toFuture<T>(this: Mono<T>): Promise<T | undefined> {\n return this.toPromise();\n};\n\nMono.prototype.zipWhen = function zipWhen<T, U, R = readonly [T, U]>(\n this: Mono<T>,\n rightGenerator: (value: T) => PublisherInput<U>,\n combinator?: (left: T, right: U) => R\n): Mono<R> {\n return this.flatMap(value => Mono.zip<[T, U], R>([Mono.just(value), rightGenerator(value)], values =>\n combinator ? combinator(values[0], values[1]) : ([values[0], values[1]] as unknown as R)\n ));\n};\n"],"mappings":";;;AA2JA,KAAK,UAAU,QAAQ,SAAS,MAAwB,KAAqB,WAAgC;CACzG,OAAO,IAAI,MAAM,QAAQ,YAAY,KAAK,UAAU,MAAM,KAAK,MAAM,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,OAAO,CAAC;AACjH;AAEA,KAAK,UAAU,oBAAoB,SAAS,kBAExC,YACO;CACP,OAAO,KAAK,MAAM;AACtB;AAEA,KAAK,UAAU,sBAAsB,SAAS,oBAE1C,UACA,eACO;CACP,OAAO,KAAK,MAAM;AACtB;AAEA,KAAK,UAAU,WAAW,SAAS,SAA2B,WAA+B;CACzF,OAAO,IAAI,MAAM,QAAQ,YAAY,KAAK,UAAU,SAAS,KAAK,MAAM,SAAS,CAAC,CAAC,QAAQ,QAAQ,OAAO,CAAC;AAC/G;AAEA,KAAK,UAAU,aAAa,SAAS,WAEjC,aACA,iBACO;CACP,OAAO,IAAI,MAAM,QAAQ,YAAY,KAAK,UAAU,WAAW,KAAK,MAAM,aAAa,eAAe,CAAC,CAAC,QAAQ,QAAQ,OAAO,CAAC;AACpI;AAEA,KAAK,UAAU,iBAA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{ Mapper, PublisherInput } from "../types.js";
|
|
7
|
+
declare module "../mono.js" {
|
|
8
|
+
/** Core Mono instance operators added to Mono. */
|
|
9
|
+
interface Mono<T> {
|
|
10
|
+
/** Maps the Mono value when one is present. */
|
|
11
|
+
map<R>(mapper: Mapper<T, R>): Mono<R>;
|
|
12
|
+
/** Maps the Mono value to another publisher and keeps at most one resulting value. */
|
|
13
|
+
flatMap<R>(mapper: (value: T) => PublisherInput<R>): Mono<R>;
|
|
14
|
+
/** Maps the Mono value to a publisher and exposes all resulting values as Flux. */
|
|
15
|
+
flatMapMany<R>(mapper: (value: T) => PublisherInput<R>): Flux<R>;
|
|
16
|
+
/** Keeps the Mono value only when it matches the predicate. */
|
|
17
|
+
filter(predicate: (value: T) => boolean): Mono<T>;
|
|
18
|
+
/** Emits `defaultValue` when this Mono completes empty. */
|
|
19
|
+
defaultIfEmpty(defaultValue: T): Mono<T>;
|
|
20
|
+
/** Switches to `alternate` when this Mono completes empty. */
|
|
21
|
+
switchIfEmpty(alternate: PublisherInput<T>): Mono<T>;
|
|
22
|
+
/** Ignores the value and completes when this Mono completes successfully. */
|
|
23
|
+
then(): Mono<void>;
|
|
24
|
+
/** Ignores the value and emits `value` after successful completion. */
|
|
25
|
+
thenReturn<R>(value: R): Mono<R>;
|
|
26
|
+
/** Combines this Mono value with another publisher's value. */
|
|
27
|
+
zipWith<U, R = readonly [T, U]>(other: PublisherInput<U>, combinator?: (left: T, right: U) => R): Mono<R>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=mono.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mono.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/mono.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEjE,OAAO,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G;CACJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Flux } from "../flux.js";
|
|
2
|
+
import { Mono } from "../mono.js";
|
|
3
|
+
//#region src/publisher/operators/mono.ts
|
|
4
|
+
/**
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
* Flux, Mono and operator implementation modules.
|
|
7
|
+
*/
|
|
8
|
+
Mono.prototype.map = function map(mapper) {
|
|
9
|
+
return new Mono((signal, context) => Flux.prototype.map.call(this, mapper).iterate(signal, context));
|
|
10
|
+
};
|
|
11
|
+
Mono.prototype.flatMap = function flatMap(mapper) {
|
|
12
|
+
return new Mono((signal, context) => Flux.prototype.flatMap.call(this, mapper, 1).next().iterate(signal, context));
|
|
13
|
+
};
|
|
14
|
+
Mono.prototype.flatMapMany = function flatMapMany(mapper) {
|
|
15
|
+
return Flux.prototype.flatMap.call(this, mapper, 1);
|
|
16
|
+
};
|
|
17
|
+
Mono.prototype.filter = function filter(predicate) {
|
|
18
|
+
return new Mono((signal, context) => Flux.prototype.filter.call(this, predicate).iterate(signal, context));
|
|
19
|
+
};
|
|
20
|
+
Mono.prototype.defaultIfEmpty = function defaultIfEmpty(defaultValue) {
|
|
21
|
+
return new Mono((signal, context) => Flux.prototype.defaultIfEmpty.call(this, defaultValue).iterate(signal, context));
|
|
22
|
+
};
|
|
23
|
+
Mono.prototype.switchIfEmpty = function switchIfEmpty(alternate) {
|
|
24
|
+
return new Mono((signal, context) => Flux.prototype.switchIfEmpty.call(this, alternate).next().iterate(signal, context));
|
|
25
|
+
};
|
|
26
|
+
Mono.prototype.then = function then() {
|
|
27
|
+
return Flux.prototype.then.call(this);
|
|
28
|
+
};
|
|
29
|
+
Mono.prototype.thenReturn = function thenReturn(value) {
|
|
30
|
+
return Flux.prototype.thenReturn.call(this, value);
|
|
31
|
+
};
|
|
32
|
+
Mono.prototype.zipWith = function zipWith(other, combinator) {
|
|
33
|
+
return Mono.zip([this, other], (values) => combinator ? combinator(values[0], values[1]) : [values[0], values[1]]);
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=mono.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mono.js","names":[],"sources":["../../../src/publisher/operators/mono.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Flux, Mono and operator implementation modules.\n */\nimport {Flux} from \"@/publisher/flux.js\";\nimport {Mono} from \"@/publisher/mono.js\";\nimport type {Mapper, PublisherInput} from \"@/publisher/types.js\";\n\ndeclare module \"@/publisher/mono.js\" {\n /** Core Mono instance operators added to Mono. */\n interface Mono<T> {\n /** Maps the Mono value when one is present. */\n map<R>(mapper: Mapper<T, R>): Mono<R>;\n\n /** Maps the Mono value to another publisher and keeps at most one resulting value. */\n flatMap<R>(mapper: (value: T) => PublisherInput<R>): Mono<R>;\n\n /** Maps the Mono value to a publisher and exposes all resulting values as Flux. */\n flatMapMany<R>(mapper: (value: T) => PublisherInput<R>): Flux<R>;\n\n /** Keeps the Mono value only when it matches the predicate. */\n filter(predicate: (value: T) => boolean): Mono<T>;\n\n /** Emits `defaultValue` when this Mono completes empty. */\n defaultIfEmpty(defaultValue: T): Mono<T>;\n\n /** Switches to `alternate` when this Mono completes empty. */\n switchIfEmpty(alternate: PublisherInput<T>): Mono<T>;\n\n /** Ignores the value and completes when this Mono completes successfully. */\n then(): Mono<void>;\n\n /** Ignores the value and emits `value` after successful completion. */\n thenReturn<R>(value: R): Mono<R>;\n\n /** Combines this Mono value with another publisher's value. */\n zipWith<U, R = readonly [T, U]>(other: PublisherInput<U>, combinator?: (left: T, right: U) => R): Mono<R>;\n }\n}\n\nMono.prototype.map = function map<T, R>(this: Mono<T>, mapper: Mapper<T, R>): Mono<R> {\n return new Mono((signal, context) => (Flux.prototype.map.call(this, mapper) as Flux<R>).iterate(signal, context));\n};\n\nMono.prototype.flatMap = function flatMap<T, R>(\n this: Mono<T>,\n mapper: (value: T) => PublisherInput<R>\n): Mono<R> {\n return new Mono((signal, context) => (Flux.prototype.flatMap.call(this, mapper, 1) as Flux<R>).next().iterate(signal, context));\n};\n\nMono.prototype.flatMapMany = function flatMapMany<T, R>(\n this: Mono<T>,\n mapper: (value: T) => PublisherInput<R>\n): Flux<R> {\n return Flux.prototype.flatMap.call(this, mapper, 1) as Flux<R>;\n};\n\nMono.prototype.filter = function filter<T>(this: Mono<T>, predicate: (value: T) => boolean): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.filter.call(this, predicate).iterate(signal, context));\n};\n\nMono.prototype.defaultIfEmpty = function defaultIfEmpty<T>(this: Mono<T>, defaultValue: T): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.defaultIfEmpty.call(this, defaultValue).iterate(signal, context));\n};\n\nMono.prototype.switchIfEmpty = function switchIfEmpty<T>(this: Mono<T>, alternate: PublisherInput<T>): Mono<T> {\n return new Mono((signal, context) => Flux.prototype.switchIfEmpty.call(this, alternate).next().iterate(signal, context));\n};\n\nMono.prototype.then = function then<T>(this: Mono<T>): Mono<void> {\n return Flux.prototype.then.call(this);\n};\n\nMono.prototype.thenReturn = function thenReturn<T, R>(this: Mono<T>, value: R): Mono<R> {\n return Flux.prototype.thenReturn.call(this, value) as Mono<R>;\n};\n\nMono.prototype.zipWith = function zipWith<T, U, R = readonly [T, U]>(\n this: Mono<T>,\n other: PublisherInput<U>,\n combinator?: (left: T, right: U) => R\n): Mono<R> {\n return Mono.zip<[T, U], R>([this, other], values =>\n combinator ? combinator(values[0], values[1]) : ([values[0], values[1]] as const as R)\n );\n};\n"],"mappings":";;;;;;;AAwCA,KAAK,UAAU,MAAM,SAAS,IAAyB,QAA+B;CAClF,OAAO,IAAI,MAAM,QAAQ,YAAa,KAAK,UAAU,IAAI,KAAK,MAAM,MAAM,CAAC,CAAa,QAAQ,QAAQ,OAAO,CAAC;AACpH;AAEA,KAAK,UAAU,UAAU,SAAS,QAE9B,QACO;CACP,OAAO,IAAI,MAAM,QAAQ,YAAa,KAAK,UAAU,QAAQ,K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ten.js";
|
|
7
|
+
import "./selection.js";
|
|
8
|
+
import "./aggregate.js";
|
|
9
|
+
import "./side-effect.js";
|
|
10
|
+
import "./error.js";
|
|
11
|
+
import "./time.js";
|
|
12
|
+
import "./terminal.js";
|
|
13
|
+
import "./mono.js";
|
|
14
|
+
import "./compat/flux.js";
|
|
15
|
+
import "./compat/mono.js";
|
|
16
|
+
import "./windowing.js";
|
|
17
|
+
import "./lifecycle.js";
|
|
18
|
+
import "./coordination.js";
|
|
19
|
+
import "./mono-parity.js";
|
|
20
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/register.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,+BAA+B,CAAC;AACvC,OAAO,sCAAsC,CAAC;AAC9C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,uCAAuC,CAAC;AAC/C,OAAO,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./transform.js";
|
|
2
|
+
import "./flatten.js";
|
|
3
|
+
import "./selection.js";
|
|
4
|
+
import "./aggregate.js";
|
|
5
|
+
import "./side-effect.js";
|
|
6
|
+
import "./error.js";
|
|
7
|
+
import "./time.js";
|
|
8
|
+
import "./terminal.js";
|
|
9
|
+
import "./mono.js";
|
|
10
|
+
import "./compat/flux.js";
|
|
11
|
+
import "./compat/mono.js";
|
|
12
|
+
import "./windowing.js";
|
|
13
|
+
import "./lifecycle.js";
|
|
14
|
+
import "./coordination.js";
|
|
15
|
+
import "./mono-parity.js";
|
|
16
|
+
//#region src/publisher/operators/register.ts
|
|
17
|
+
/**
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
* Registers Flux and Mono prototype operators.
|
|
20
|
+
*/
|
|
21
|
+
//#endregion
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","names":[],"sources":["../../../src/publisher/operators/register.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Registers Flux and Mono prototype operators.\n */\nimport \"@/publisher/operators/transform.js\";\nimport \"@/publisher/operators/flatten.js\";\nimport \"@/publisher/operators/selection.js\";\nimport \"@/publisher/operators/aggregate.js\";\nimport \"@/publisher/operators/side-effect.js\";\nimport \"@/publisher/operators/error.js\";\nimport \"@/publisher/operators/time.js\";\nimport \"@/publisher/operators/terminal.js\";\nimport \"@/publisher/operators/mono.js\";\nimport \"@/publisher/operators/compat/flux.js\";\nimport \"@/publisher/operators/compat/mono.js\";\nimport \"@/publisher/operators/windowing.js\";\nimport \"@/publisher/operators/lifecycle.js\";\nimport \"@/publisher/operators/coordination.js\";\nimport \"@/publisher/operators/mono-parity.js\";\n"],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PublisherInput } from "../types.js";
|
|
2
|
+
declare module "../flux.js" {
|
|
3
|
+
/** Selection and filtering operators added to Flux. */
|
|
4
|
+
interface Flux<T> {
|
|
5
|
+
/** Emits at most the first `n` source values. */
|
|
6
|
+
take(n: number): Flux<T>;
|
|
7
|
+
/** Emits values while the predicate returns true, then cancels upstream. */
|
|
8
|
+
takeWhile(predicate: (value: T) => boolean): Flux<T>;
|
|
9
|
+
/** Emits values until the predicate returns true, including the matching value. */
|
|
10
|
+
takeUntil(predicate: (value: T) => boolean): Flux<T>;
|
|
11
|
+
/** Drops the first `n` source values. */
|
|
12
|
+
skip(n: number): Flux<T>;
|
|
13
|
+
/** Drops values while the predicate returns true, then relays the rest. */
|
|
14
|
+
skipWhile(predicate: (value: T) => boolean): Flux<T>;
|
|
15
|
+
/** Emits only the first value for each selected key. */
|
|
16
|
+
distinct<K = T>(keySelector?: (value: T) => K): Flux<T>;
|
|
17
|
+
/** Drops adjacent values whose selected key is equal to the previous key. */
|
|
18
|
+
distinctUntilChanged<K = T>(keySelector?: (value: T) => K): Flux<T>;
|
|
19
|
+
/** Emits `defaultValue` when the source completes without values. */
|
|
20
|
+
defaultIfEmpty(defaultValue: T): Flux<T>;
|
|
21
|
+
/** Switches to `alternate` when the source completes without values. */
|
|
22
|
+
switchIfEmpty(alternate: PublisherInput<T>): Flux<T>;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/selection.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD,OAAO,QAAQ,qBAAqB,CAAC;IACjC,uDAAuD;IACvD,UAAU,IAAI,CAAC,CAAC;QACZ,iDAAiD;QACjD,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEzB,4EAA4E;QAC5E,SAAS,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAErD,mFAAmF;QACnF,SAAS,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAErD,yCAAyC;QACzC,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEzB,2EAA2E;QAC3E,SAAS,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAErD,wDAAwD;QACxD,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAExD,6EAA6E;QAC7E,oBAAoB,CAAC,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpE,qEAAqE;QACrE,cAAc,CAAC,YAAY,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEzC,wEAAwE;QACxE,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KACxD;CACJ"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { isAsyncIterable, toAsyncIterator } from "../../internal/iterable.js";
|
|
2
|
+
import { defaultIfEmptyIterable, distinctIterable, distinctUntilChangedIterable, skipIterable, skipWhileIterable, takeUntilIterable, takeWhileIterable } from "../../internal/iterable-transform.js";
|
|
3
|
+
import { identity } from "../helpers.js";
|
|
4
|
+
import { Flux } from "../flux.js";
|
|
5
|
+
//#region src/publisher/operators/selection.ts
|
|
6
|
+
/**
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* Flux, Mono and operator implementation modules.
|
|
9
|
+
*/
|
|
10
|
+
Flux.prototype.take = function take(n) {
|
|
11
|
+
if (!Number.isInteger(n) || n < 0) throw new RangeError("take expects a non-negative integer");
|
|
12
|
+
if (n === 0) return Flux.empty();
|
|
13
|
+
const source = this;
|
|
14
|
+
return new Flux((signal, context) => {
|
|
15
|
+
const controller = new AbortController();
|
|
16
|
+
const abort = () => controller.abort(signal.reason);
|
|
17
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
18
|
+
let values;
|
|
19
|
+
try {
|
|
20
|
+
values = source.iterate(controller.signal, context);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
signal.removeEventListener("abort", abort);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
if (!isAsyncIterable(values)) return (function* () {
|
|
26
|
+
let remaining = n;
|
|
27
|
+
try {
|
|
28
|
+
for (const value of values) {
|
|
29
|
+
yield value;
|
|
30
|
+
remaining -= 1;
|
|
31
|
+
if (remaining === 0) {
|
|
32
|
+
controller.abort();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} finally {
|
|
37
|
+
signal.removeEventListener("abort", abort);
|
|
38
|
+
if (signal.aborted && !controller.signal.aborted) controller.abort(signal.reason);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
return (async function* () {
|
|
42
|
+
const iterator = toAsyncIterator(values);
|
|
43
|
+
let remaining = n;
|
|
44
|
+
let cancelledSource = false;
|
|
45
|
+
try {
|
|
46
|
+
while (!signal.aborted) {
|
|
47
|
+
const result = await iterator.next();
|
|
48
|
+
if (result.done) return;
|
|
49
|
+
yield result.value;
|
|
50
|
+
remaining -= 1;
|
|
51
|
+
if (remaining === 0) {
|
|
52
|
+
cancelledSource = true;
|
|
53
|
+
controller.abort();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} finally {
|
|
58
|
+
signal.removeEventListener("abort", abort);
|
|
59
|
+
if (signal.aborted && !controller.signal.aborted) controller.abort(signal.reason);
|
|
60
|
+
if (cancelledSource || signal.aborted) await iterator.return?.();
|
|
61
|
+
}
|
|
62
|
+
})();
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
Flux.prototype.takeWhile = function takeWhile(predicate) {
|
|
66
|
+
const source = this;
|
|
67
|
+
return new Flux((signal, context) => takeWhileIterable(source.iterate(signal, context), predicate));
|
|
68
|
+
};
|
|
69
|
+
Flux.prototype.takeUntil = function takeUntil(predicate) {
|
|
70
|
+
const source = this;
|
|
71
|
+
return new Flux((signal, context) => takeUntilIterable(source.iterate(signal, context), predicate));
|
|
72
|
+
};
|
|
73
|
+
Flux.prototype.skip = function skip(n) {
|
|
74
|
+
if (!Number.isInteger(n) || n < 0) throw new RangeError("skip expects a non-negative integer");
|
|
75
|
+
if (n === 0) return this;
|
|
76
|
+
const source = this;
|
|
77
|
+
return new Flux((signal, context) => skipIterable(source.iterate(signal, context), n));
|
|
78
|
+
};
|
|
79
|
+
Flux.prototype.skipWhile = function skipWhile(predicate) {
|
|
80
|
+
const source = this;
|
|
81
|
+
return new Flux((signal, context) => skipWhileIterable(source.iterate(signal, context), predicate));
|
|
82
|
+
};
|
|
83
|
+
Flux.prototype.distinct = function distinct(keySelector = identity) {
|
|
84
|
+
const source = this;
|
|
85
|
+
return new Flux((signal, context) => distinctIterable(source.iterate(signal, context), keySelector));
|
|
86
|
+
};
|
|
87
|
+
Flux.prototype.distinctUntilChanged = function distinctUntilChanged(keySelector = identity) {
|
|
88
|
+
const source = this;
|
|
89
|
+
return new Flux((signal, context) => distinctUntilChangedIterable(source.iterate(signal, context), keySelector));
|
|
90
|
+
};
|
|
91
|
+
Flux.prototype.defaultIfEmpty = function defaultIfEmpty(defaultValue) {
|
|
92
|
+
const source = this;
|
|
93
|
+
return new Flux((signal, context) => defaultIfEmptyIterable(source.iterate(signal, context), defaultValue));
|
|
94
|
+
};
|
|
95
|
+
Flux.prototype.switchIfEmpty = function switchIfEmpty(alternate) {
|
|
96
|
+
const source = this;
|
|
97
|
+
return new Flux(async function* (signal, context) {
|
|
98
|
+
let empty = true;
|
|
99
|
+
for await (const value of source.iterate(signal, context)) {
|
|
100
|
+
empty = false;
|
|
101
|
+
yield value;
|
|
102
|
+
}
|
|
103
|
+
if (empty) for await (const value of Flux.from(alternate).iterate(signal, context)) yield value;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","names":[],"sources":["../../../src/publisher/operators/selection.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Flux, Mono and operator implementation modules.\n */\nimport {Flux} from \"@/publisher/flux.js\";\nimport {\n type AnyIterable,\n isAsyncIterable,\n toAsyncIterator\n} from \"@/internal/iterable.js\";\nimport {\n defaultIfEmptyIterable,\n distinctIterable,\n distinctUntilChangedIterable,\n skipIterable,\n skipWhileIterable,\n takeUntilIterable,\n takeWhileIterable\n} from \"@/internal/iterable-transform.js\";\nimport {identity} from \"@/publisher/helpers.js\";\nimport type {PublisherInput} from \"@/publisher/types.js\";\n\ndeclare module \"@/publisher/flux.js\" {\n /** Selection and filtering operators added to Flux. */\n interface Flux<T> {\n /** Emits at most the first `n` source values. */\n take(n: number): Flux<T>;\n\n /** Emits values while the predicate returns true, then cancels upstream. */\n takeWhile(predicate: (value: T) => boolean): Flux<T>;\n\n /** Emits values until the predicate returns true, including the matching value. */\n takeUntil(predicate: (value: T) => boolean): Flux<T>;\n\n /** Drops the first `n` source values. */\n skip(n: number): Flux<T>;\n\n /** Drops values while the predicate returns true, then relays the rest. */\n skipWhile(predicate: (value: T) => boolean): Flux<T>;\n\n /** Emits only the first value for each selected key. */\n distinct<K = T>(keySelector?: (value: T) => K): Flux<T>;\n\n /** Drops adjacent values whose selected key is equal to the previous key. */\n distinctUntilChanged<K = T>(keySelector?: (value: T) => K): Flux<T>;\n\n /** Emits `defaultValue` when the source completes without values. */\n defaultIfEmpty(defaultValue: T): Flux<T>;\n\n /** Switches to `alternate` when the source completes without values. */\n switchIfEmpty(alternate: PublisherInput<T>): Flux<T>;\n }\n}\n\nFlux.prototype.take = function take<T>(this: Flux<T>, n: number): Flux<T> {\n if (!Number.isInteger(n) || n < 0) {\n throw new RangeError(\"take expects a non-negative integer\");\n }\n if (n === 0) {\n return Flux.empty<T>();\n }\n const source = this;\n return new Flux((signal, context) => {\n const controller = new AbortController();\n const abort = () => controller.abort(signal.reason);\n signal.addEventListener(\"abort\", abort, {once: true});\n let values: AnyIterable<T>;\n try {\n values = source.iterate(controller.signal, context);\n } catch (error) {\n signal.removeEventListener(\"abort\", abort);\n throw error;\n }\n if (!isAsyncIterable<T>(values)) {\n return (function* () {\n let remaining = n;\n try {\n for (const value of values) {\n yield value;\n remaining -= 1;\n if (remaining === 0) {\n controller.abort();\n return;\n }\n }\n } finally {\n signal.removeEventListener(\"abort\", abort);\n if (signal.aborted && !controller.signal.aborted) {\n controller.abort(signal.reason);\n }\n }\n })();\n }\n return (async function* () {\n const iterator = toAsyncIterator(values);\n let remaining = n;\n let cancelledSource = false;\n try {\n while (!signal.aborted) {\n const result = await iterator.next();\n if (result.done) {\n return;\n }\n yield result.value;\n remaining -= 1;\n if (remaining === 0) {\n cancelledSource = true;\n controller.abort();\n return;\n }\n }\n } finally {\n signal.removeEventListener(\"abort\", abort);\n if (signal.aborted && !controller.signal.aborted) {\n controller.abort(signal.reason);\n }\n if (cancelledSource || signal.aborted) {\n await iterator.return?.();\n }\n }\n })();\n });\n};\n\nFlux.prototype.takeWhile = function takeWhile<T>(this: Flux<T>, predicate: (value: T) => boolean): Flux<T> {\n const source = this;\n return new Flux((signal, context) => takeWhileIterable(source.iterate(signal, context), predicate));\n};\n\nFlux.prototype.takeUntil = function takeUntil<T>(this: Flux<T>, predicate: (value: T) => boolean): Flux<T> {\n const source = this;\n return new Flux((signal, context) => takeUntilIterable(source.iterate(signal, context), predicate));\n};\n\nFlux.prototype.skip = function skip<T>(this: Flux<T>, n: number): Flux<T> {\n if (!Number.isInteger(n) || n < 0) {\n throw new RangeError(\"skip expects a non-negative integer\");\n }\n if (n === 0) {\n return this;\n }\n const source = this;\n return new Flux((signal, context) => skipIterable(source.iterate(signal, context), n));\n};\n\nFlux.prototype.skipWhile = function skipWhile<T>(this: Flux<T>, predicate: (value: T) => boolean): Flux<T> {\n const source = this;\n return new Flux((signal, context) => skipWhileIterable(source.iterate(signal, context), predicate));\n};\n\nFlux.prototype.distinct = function distinct<T, K = T>(\n this: Flux<T>,\n keySelector: (value: T) => K = identity as (value: T) => K\n): Flux<T> {\n const source = this;\n return new Flux((signal, context) => distinctIterable(source.iterate(signal, context), keySelector));\n};\n\nFlux.prototype.distinctUntilChanged = function distinctUntilChanged<T, K = T>(\n this: Flux<T>,\n keySelector: (value: T) => K = identity as (value: T) => K\n): Flux<T> {\n const source = this;\n return new Flux((signal, context) => distinctUntilChangedIterable(source.iterate(signal, context), keySelector));\n};\n\nFlux.prototype.defaultIfEmpty = function defaultIfEmpty<T>(this: Flux<T>, defaultValue: T): Flux<T> {\n const source = this;\n return new Flux((signal, context) => defaultIfEmptyIterable(source.iterate(signal, context), defaultValue));\n};\n\nFlux.prototype.switchIfEmpty = function switchIfEmpty<T>(this: Flux<T>, alternate: PublisherInput<T>): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n let empty = true;\n for await (const value of source.iterate(signal, context)) {\n empty = false;\n yield value;\n }\n if (empty) {\n for await (const value of Flux.from(alternate).iterate(signal, context)) {\n yield value;\n }\n }\n });\n};\n"],"mappings":";;;;;;;;;AAsDA,KAAK,UAAU,OAAO,SAAS,KAAuB,GAAoB;CACtE,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,GAC5B,MAAM,IAAI,WAAW,qCAAqC;CAE9D,IAAI,MAAM,GACN,OAAO,KAAK,MAAS;CAEzB,MAAM,SAAS;CACf,OAAO,IAAI,MAAM,QAAQ,YAAY;EACjC,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,cAAc,WAAW,MAAM,OAAO,MAAM;EAClD,OAAO,iBAAiB,SAAS,OAAO,EAAC,MAAM,KAAI,CAAC;EACpD,IAAI;EACJ,IAAI;GACA,SAAS,OAAO,QAAQ,WAAW,QAAQ,OAAO;EACtD,SAAS,OAAO;GACZ,OAAO,oBAAoB,SAAS,KAAK;GACzC,MAAM;EACV;EACA,IAAI,CAAC,gBAAmB,MAAM,GAC1B,QAAQ,aAAa;GAC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4
|
+
/** Invokes a callback for each value without changing the sequence. */
|
|
5
|
+
doOnNext(callback: (value: T) => void): Flux<T>;
|
|
6
|
+
/** Invokes a callback when the source fails without recovering the error. */
|
|
7
|
+
doOnError(callback: (error: unknown) => void): Flux<T>;
|
|
8
|
+
/** Invokes a callback after the source completes successfully. */
|
|
9
|
+
doOnComplete(callback: () => void): Flux<T>;
|
|
10
|
+
/** Invokes a callback once after completion, error, or cancellation. */
|
|
11
|
+
doFinally(callback: (signal: "complete" | "error" | "cancel") => void): Flux<T>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=side-effect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side-effect.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/side-effect.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,qBAAqB,CAAC;IACjC,oDAAoD;IACpD,UAAU,IAAI,CAAC,CAAC;QACZ,uEAAuE;QACvE,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEhD,6EAA6E;QAC7E,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEvD,kEAAkE;QAClE,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAE5C,wEAAwE;QACxE,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KACnF;CACJ"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Flux } from "../flux.js";
|
|
2
|
+
import { liftOneToOne } from "./lift.js";
|
|
3
|
+
//#region src/publisher/operators/side-effect.ts
|
|
4
|
+
/**
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
* Flux, Mono and operator implementation modules.
|
|
7
|
+
*/
|
|
8
|
+
Flux.prototype.doOnNext = function doOnNext(callback) {
|
|
9
|
+
const source = this;
|
|
10
|
+
return liftOneToOne(source, async function* (signal, context) {
|
|
11
|
+
for await (const value of source.iterate(signal, context)) {
|
|
12
|
+
callback(value);
|
|
13
|
+
yield value;
|
|
14
|
+
}
|
|
15
|
+
}, () => ({
|
|
16
|
+
/** Runs the side effect and retains the original value. */
|
|
17
|
+
onNext(value) {
|
|
18
|
+
callback(value);
|
|
19
|
+
return value;
|
|
20
|
+
} }));
|
|
21
|
+
};
|
|
22
|
+
Flux.prototype.doOnError = function doOnError(callback) {
|
|
23
|
+
const source = this;
|
|
24
|
+
return liftOneToOne(source, async function* (signal, context) {
|
|
25
|
+
try {
|
|
26
|
+
for await (const value of source.iterate(signal, context)) yield value;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
callback(error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}, () => ({
|
|
32
|
+
onNext: passThrough,
|
|
33
|
+
onError: callback
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
Flux.prototype.doOnComplete = function doOnComplete(callback) {
|
|
37
|
+
const source = this;
|
|
38
|
+
return liftOneToOne(source, async function* (signal, context) {
|
|
39
|
+
for await (const value of source.iterate(signal, context)) yield value;
|
|
40
|
+
callback();
|
|
41
|
+
}, () => ({
|
|
42
|
+
onNext: passThrough,
|
|
43
|
+
onComplete: callback
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
Flux.prototype.doFinally = function doFinally(callback) {
|
|
47
|
+
const source = this;
|
|
48
|
+
return liftOneToOne(source, async function* (signal, context) {
|
|
49
|
+
let terminal = "complete";
|
|
50
|
+
try {
|
|
51
|
+
for await (const value of source.iterate(signal, context)) {
|
|
52
|
+
if (signal.aborted) {
|
|
53
|
+
terminal = "cancel";
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
yield value;
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
terminal = signal.aborted ? "cancel" : "error";
|
|
60
|
+
throw error;
|
|
61
|
+
} finally {
|
|
62
|
+
runFinallyCallback(callback, signal.aborted ? "cancel" : terminal);
|
|
63
|
+
}
|
|
64
|
+
}, () => ({
|
|
65
|
+
onNext: passThrough,
|
|
66
|
+
onFinally: callback
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
/** Returns an operator value unchanged. */
|
|
70
|
+
function passThrough(value) {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
/** Runs a final observer without allowing it to replace sequence termination. */
|
|
74
|
+
function runFinallyCallback(callback, signal) {
|
|
75
|
+
try {
|
|
76
|
+
callback(signal);
|
|
77
|
+
} catch {}
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=side-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side-effect.js","names":[],"sources":["../../../src/publisher/operators/side-effect.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Flux, Mono and operator implementation modules.\n */\nimport {Flux} from \"@/publisher/flux.js\";\nimport {liftOneToOne} from \"@/publisher/operators/lift.js\";\n\ndeclare module \"@/publisher/flux.js\" {\n /** Side-effect callback operators added to Flux. */\n interface Flux<T> {\n /** Invokes a callback for each value without changing the sequence. */\n doOnNext(callback: (value: T) => void): Flux<T>;\n\n /** Invokes a callback when the source fails without recovering the error. */\n doOnError(callback: (error: unknown) => void): Flux<T>;\n\n /** Invokes a callback after the source completes successfully. */\n doOnComplete(callback: () => void): Flux<T>;\n\n /** Invokes a callback once after completion, error, or cancellation. */\n doFinally(callback: (signal: \"complete\" | \"error\" | \"cancel\") => void): Flux<T>;\n }\n}\n\nFlux.prototype.doOnNext = function doOnNext<T>(this: Flux<T>, callback: (value: T) => void): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n async function* (signal, context) {\n for await (const value of source.iterate(signal, context)) {\n callback(value);\n yield value;\n }\n },\n () => ({\n /** Runs the side effect and retains the original value. */\n onNext(value) {\n callback(value);\n return value;\n }\n })\n );\n};\n\nFlux.prototype.doOnError = function doOnError<T>(this: Flux<T>, callback: (error: unknown) => void): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n async function* (signal, context) {\n try {\n for await (const value of source.iterate(signal, context)) {\n yield value;\n }\n } catch (error) {\n callback(error);\n throw error;\n }\n },\n () => ({\n onNext: passThrough,\n onError: callback\n })\n );\n};\n\nFlux.prototype.doOnComplete = function doOnComplete<T>(this: Flux<T>, callback: () => void): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n async function* (signal, context) {\n for await (const value of source.iterate(signal, context)) {\n yield value;\n }\n callback();\n },\n () => ({\n onNext: passThrough,\n onComplete: callback\n })\n );\n};\n\nFlux.prototype.doFinally = function doFinally<T>(\n this: Flux<T>,\n callback: (signal: \"complete\" | \"error\" | \"cancel\") => void\n): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n async function* (signal, context) {\n let terminal: \"complete\" | \"error\" | \"cancel\" = \"complete\";\n try {\n for await (const value of source.iterate(signal, context)) {\n if (signal.aborted) {\n terminal = \"cancel\";\n return;\n }\n yield value;\n }\n } catch (error) {\n terminal = signal.aborted ? \"cancel\" : \"error\";\n throw error;\n } finally {\n runFinallyCallback(callback, signal.aborted ? \"cancel\" : terminal);\n }\n },\n () => ({\n onNext: passThrough,\n onFinally: callback\n })\n );\n};\n\n/** Returns an operator value unchanged. */\nfunction passThrough<T>(value: T): T {\n return value;\n}\n\n/** Runs a final observer without allowing it to replace sequence termination. */\nfunction runFinallyCallback(\n callback: (signal: \"complete\" | \"error\" | \"cancel\") => void,\n signal: \"complete\" | \"error\" | \"cancel\"\n): void {\n try {\n callback(signal);\n } catch {\n // Final observers run after propagation and cannot replace the terminal signal.\n }\n}\n"],"mappings":";;;;;;;AAwBA,K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ACjC,OAAO;AACX;;AAGA,SAAS,mBACL,UACA,QACI;CACJ,IAAI;EACA,SAAS,MAAM;CACnB,QAAQ,CAER;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Mono } from "../mono.js";
|
|
2
|
+
import type { PublisherInput } from "../types.js";
|
|
3
|
+
declare module "../flux.js" {
|
|
4
|
+
/** Terminal continuation and zip operators added to Flux. */
|
|
5
|
+
interface Flux<T> {
|
|
6
|
+
/** Ignores all values and completes when the source completes successfully. */
|
|
7
|
+
then(): Mono<void>;
|
|
8
|
+
/** Waits for this source to complete and then emits values from `other`. */
|
|
9
|
+
thenMany<R>(other: PublisherInput<R>): Flux<R>;
|
|
10
|
+
/** Ignores all values and emits `value` after successful completion. */
|
|
11
|
+
thenReturn<R>(value: R): Mono<R>;
|
|
12
|
+
/** Zips this Flux with another publisher and combines paired values. */
|
|
13
|
+
zipWith<U, R = readonly [T, U]>(other: PublisherInput<U>, combinator?: (left: T, right: U) => R): Flux<R>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/terminal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAEzC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD,OAAO,QAAQ,qBAAqB,CAAC;IACjC,6DAA6D;IAC7D,UAAU,IAAI,CAAC,CAAC;QACZ,+EAA+E;QAC/E,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAEnB,4EAA4E;QAC5E,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAE/C,wEAAwE;QACxE,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEjC,wEAAwE;QACxE,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KAC7G;CACJ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isAsyncIterable } from "../../internal/iterable.js";
|
|
2
|
+
import { Flux } from "../flux.js";
|
|
3
|
+
import { Mono } from "../mono.js";
|
|
4
|
+
//#region src/publisher/operators/terminal.ts
|
|
5
|
+
/**
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* Flux, Mono and operator implementation modules.
|
|
8
|
+
*/
|
|
9
|
+
Flux.prototype.then = function then() {
|
|
10
|
+
const source = this;
|
|
11
|
+
return new Mono((signal, context) => {
|
|
12
|
+
const values = source.iterate(signal, context);
|
|
13
|
+
return isAsyncIterable(values) ? drainThenEmitAsync(values, void 0) : drainThenEmitSync(values, void 0);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
Flux.prototype.thenMany = function thenMany(other) {
|
|
17
|
+
const source = this;
|
|
18
|
+
return new Flux(async function* (signal, context) {
|
|
19
|
+
for await (const _ of source.iterate(signal, context));
|
|
20
|
+
for await (const value of Flux.from(other).iterate(signal, context)) yield value;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Flux.prototype.thenReturn = function thenReturn(value) {
|
|
24
|
+
const source = this;
|
|
25
|
+
return new Mono((signal, context) => {
|
|
26
|
+
const values = source.iterate(signal, context);
|
|
27
|
+
return isAsyncIterable(values) ? drainThenEmitAsync(values, value) : drainThenEmitSync(values, value);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
/** Drains a synchronous source and then emits one completion value. */
|
|
31
|
+
function drainThenEmitSync(values, value) {
|
|
32
|
+
return (function* () {
|
|
33
|
+
for (const _ of values);
|
|
34
|
+
yield value;
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
/** Drains an asynchronous source and then emits one completion value. */
|
|
38
|
+
async function* drainThenEmitAsync(values, value) {
|
|
39
|
+
for await (const _ of values);
|
|
40
|
+
yield value;
|
|
41
|
+
}
|
|
42
|
+
Flux.prototype.zipWith = function zipWith(other, combinator) {
|
|
43
|
+
return Flux.zip([this, other], (values) => combinator ? combinator(values[0], values[1]) : [values[0], values[1]]);
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","names":[],"sources":["../../../src/publisher/operators/terminal.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Flux, Mono and operator implementation modules.\n */\nimport {Flux} from \"@/publisher/flux.js\";\nimport {Mono} from \"@/publisher/mono.js\";\nimport {isAsyncIterable} from \"@/internal/iterable.js\";\nimport type {PublisherInput} from \"@/publisher/types.js\";\n\ndeclare module \"@/publisher/flux.js\" {\n /** Terminal continuation and zip operators added to Flux. */\n interface Flux<T> {\n /** Ignores all values and completes when the source completes successfully. */\n then(): Mono<void>;\n\n /** Waits for this source to complete and then emits values from `other`. */\n thenMany<R>(other: PublisherInput<R>): Flux<R>;\n\n /** Ignores all values and emits `value` after successful completion. */\n thenReturn<R>(value: R): Mono<R>;\n\n /** Zips this Flux with another publisher and combines paired values. */\n zipWith<U, R = readonly [T, U]>(other: PublisherInput<U>, combinator?: (left: T, right: U) => R): Flux<R>;\n }\n}\n\nFlux.prototype.then = function then<T>(this: Flux<T>): Mono<void> {\n const source = this;\n return new Mono((signal, context) => {\n const values = source.iterate(signal, context);\n return isAsyncIterable<T>(values) ? drainThenEmitAsync(values, undefined) : drainThenEmitSync(values, undefined);\n });\n};\n\nFlux.prototype.thenMany = function thenMany<T, R>(this: Flux<T>, other: PublisherInput<R>): Flux<R> {\n const source = this;\n return new Flux(async function* (signal, context) {\n for await (const _ of source.iterate(signal, context)) {\n // ignore values\n }\n for await (const value of Flux.from(other).iterate(signal, context)) {\n yield value;\n }\n });\n};\n\nFlux.prototype.thenReturn = function thenReturn<T, R>(this: Flux<T>, value: R): Mono<R> {\n const source = this;\n return new Mono((signal, context) => {\n const values = source.iterate(signal, context);\n return isAsyncIterable<T>(values) ? drainThenEmitAsync(values, value) : drainThenEmitSync(values, value);\n });\n};\n\n/** Drains a synchronous source and then emits one completion value. */\nfunction drainThenEmitSync<T, R>(values: Iterable<T>, value: R): Iterable<R> {\n return (function* () {\n for (const _ of values) {\n // ignore values\n }\n yield value;\n })();\n}\n\n/** Drains an asynchronous source and then emits one completion value. */\nasync function* drainThenEmitAsync<T, R>(values: AsyncIterable<T>, value: R): AsyncIterable<R> {\n for await (const _ of values) {\n // ignore values\n }\n yield value;\n}\n\nFlux.prototype.zipWith = function zipWith<T, U, R = readonly [T, U]>(\n this: Flux<T>,\n other: PublisherInput<U>,\n combinator?: (left: T, right: U) => R\n): Flux<R> {\n return Flux.zip<[T, U], R>([this, other], values =>\n combinator ? combinator(values[0], values[1]) : ([values[0], values[1]] as const as R)\n );\n};\n"],"mappings":";;;;;;;;AA0BA,KAAK,UAAU,OAAO,SAAS,OAAmC;CAC9D,MAAM,SAAS;CACf,OAAO,IAAI,MAAM,QAAQ,YAAY;EACjC,MAAM,SAAS,OAAO,QAAQ,QAAQ,OAAO;EAC7C,OAAO,gBAAmB,MAAM,IAAI,mBAAmB,QAAQ,MAAS,IAAI,kBAAkB,QAAQ,MAAS;CACnH,CAAC;AACL;AAEA,KAAK,UAAU,WAAW,SAAS,SAA8B,OAAmC;CAChG,MAAM,SAAS;CACf,OAAO,IAAI,KAAK,iBAAiB,QAAQ,SAAS;EAC9C,WAAW,MAAM,KAAK,OAAO,QAAQ,QAAQ,OAAO;EAGpD,WAAW,MAAM,SAAS,KAAK,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ,OAAO,GAC9D,MAAM;CAEd,CAAC;AACL;AAEA,KAAK,UAAU,aAAa,SAAS,WAAgC,OAAmB;CACpF,MAAM,SAAS;CACf,OAAO,IAAI,MAAM,QAAQ,YAAY;EACjC,MAAM,SAAS,OAAO,QAAQ,QAAQ,OAAO;EAC7C,OAAO,gBAAmB,MAAM,IAAI,mBAAmB,QAAQ,KAAK,IAAI,kBAAkB,QAAQ,KAAK;CAC3G,CAAC;AACL;;AAGA,SAAS,kBAAwB,QAAqB,OAAuB;CACzE,QAAQ,aAAa;EACjB,KAAK,MAAM,KAAK;EAGhB,MAAM;CACV,EAAA,CAAG;AACP;;AAGA,gBAAgB,mBAAyB,QAA0B,OAA4B;CAC3F,WAAW,MAAM,KAAK;CAGtB,MAAM;AACV;AAEA,KAAK,UAAU,UAAU,SAAS,QAE9B,OACA,YACO;CACP,OAAO,KAAK,IAAe,CAAC,MAAM,KAAK,IAAG,WACtC,aAAa,WAAW,OAAO,IAAI,OAAO,EAAE,IAAK,CAAC,OAAO,IAAI,OAAO,EAAE,CAC1E;AACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PublisherInput } from "../types.js";
|
|
2
|
+
import type { DurationInput, Scheduler } from "../../schedulers/types.js";
|
|
3
|
+
declare module "../flux.js" {
|
|
4
|
+
/** Time, scheduling and timeout operators added to Flux. */
|
|
5
|
+
interface Flux<T> {
|
|
6
|
+
/** Delays each source value on the provided scheduler before emitting it. */
|
|
7
|
+
delayElements(delay: DurationInput, scheduler?: Scheduler): Flux<T>;
|
|
8
|
+
/** Fails or switches to a fallback when the source does not signal in time. */
|
|
9
|
+
timeout(timeout: DurationInput, fallback?: PublisherInput<T>, scheduler?: Scheduler): Flux<T>;
|
|
10
|
+
/** Reschedules value delivery on the provided scheduler. */
|
|
11
|
+
publishOn(scheduler: Scheduler): Flux<T>;
|
|
12
|
+
/** Schedules subscription work on the provided scheduler. */
|
|
13
|
+
subscribeOn(scheduler: Scheduler): Flux<T>;
|
|
14
|
+
/** Emits each value together with the scheduler timestamp. */
|
|
15
|
+
timestamp(scheduler?: Scheduler): Flux<readonly [number, T]>;
|
|
16
|
+
/** Emits each value together with elapsed scheduler time since the previous value. */
|
|
17
|
+
elapsed(scheduler?: Scheduler): Flux<readonly [number, T]>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/time.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAEpE,OAAO,QAAQ,qBAAqB,CAAC;IACjC,4DAA4D;IAC5D,UAAU,IAAI,CAAC,CAAC;QACZ,6EAA6E;QAC7E,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpE,+EAA+E;QAC/E,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAE9F,4DAA4D;QAC5D,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEzC,6DAA6D;QAC7D,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAE3C,8DAA8D;QAC9D,SAAS,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QAE7D,sFAAsF;QACtF,OAAO,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;KAC9D;CACJ"}
|