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.
Files changed (272) hide show
  1. package/README.md +927 -658
  2. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.js +12 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.js +14 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.js +9 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.js +11 -0
  6. package/dist/context/context-view.d.ts +31 -0
  7. package/dist/context/context-view.d.ts.map +1 -0
  8. package/dist/context/context-view.js +58 -0
  9. package/dist/context/context-view.js.map +1 -0
  10. package/dist/context/context.d.ts +46 -0
  11. package/dist/context/context.d.ts.map +1 -0
  12. package/dist/context/context.js +125 -0
  13. package/dist/context/context.js.map +1 -0
  14. package/dist/context/types.d.ts +7 -0
  15. package/dist/context/types.d.ts.map +1 -0
  16. package/dist/core/boolean-disposable.d.ts +19 -0
  17. package/dist/core/boolean-disposable.d.ts.map +1 -0
  18. package/dist/core/boolean-disposable.js +37 -0
  19. package/dist/core/boolean-disposable.js.map +1 -0
  20. package/dist/core/composite-disposable.d.ts +21 -0
  21. package/dist/core/composite-disposable.d.ts.map +1 -0
  22. package/dist/core/composite-disposable.js +64 -0
  23. package/dist/core/composite-disposable.js.map +1 -0
  24. package/dist/core/demand.d.ts +9 -0
  25. package/dist/core/demand.d.ts.map +1 -0
  26. package/dist/core/demand.js +21 -0
  27. package/dist/core/demand.js.map +1 -0
  28. package/dist/core/disposables.d.ts +12 -0
  29. package/dist/core/disposables.d.ts.map +1 -0
  30. package/dist/core/disposables.js +37 -0
  31. package/dist/core/disposables.js.map +1 -0
  32. package/dist/core/teardown.d.ts +4 -0
  33. package/dist/core/teardown.d.ts.map +1 -0
  34. package/dist/core/types.d.ts +14 -0
  35. package/dist/core/types.d.ts.map +1 -0
  36. package/dist/errors/classes.d.ts +37 -0
  37. package/dist/errors/classes.d.ts.map +1 -0
  38. package/dist/errors/classes.js +53 -0
  39. package/dist/errors/classes.js.map +1 -0
  40. package/dist/errors/exceptions.d.ts +15 -0
  41. package/dist/errors/exceptions.d.ts.map +1 -0
  42. package/dist/errors/helpers.d.ts +9 -0
  43. package/dist/errors/helpers.d.ts.map +1 -0
  44. package/dist/errors/helpers.js +18 -0
  45. package/dist/errors/helpers.js.map +1 -0
  46. package/dist/index.d.ts +17 -2556
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +8 -2
  49. package/dist/internal/abort.d.ts +5 -0
  50. package/dist/internal/abort.d.ts.map +1 -0
  51. package/dist/internal/abort.js +36 -0
  52. package/dist/internal/abort.js.map +1 -0
  53. package/dist/internal/async-queue.d.ts +48 -0
  54. package/dist/internal/async-queue.d.ts.map +1 -0
  55. package/dist/internal/async-queue.js +187 -0
  56. package/dist/internal/async-queue.js.map +1 -0
  57. package/dist/internal/iterable-terminal.d.ts +12 -0
  58. package/dist/internal/iterable-terminal.d.ts.map +1 -0
  59. package/dist/internal/iterable-terminal.js +49 -0
  60. package/dist/internal/iterable-terminal.js.map +1 -0
  61. package/dist/internal/iterable-transform.d.ts +24 -0
  62. package/dist/internal/iterable-transform.d.ts.map +1 -0
  63. package/dist/internal/iterable-transform.js +159 -0
  64. package/dist/internal/iterable-transform.js.map +1 -0
  65. package/dist/internal/iterable.d.ts +23 -0
  66. package/dist/internal/iterable.d.ts.map +1 -0
  67. package/dist/internal/iterable.js +81 -0
  68. package/dist/internal/iterable.js.map +1 -0
  69. package/dist/internal/microtask.d.ts +7 -0
  70. package/dist/internal/microtask.d.ts.map +1 -0
  71. package/dist/internal/microtask.js +19 -0
  72. package/dist/internal/microtask.js.map +1 -0
  73. package/dist/publisher/browser-sources.d.ts +15 -0
  74. package/dist/publisher/browser-sources.d.ts.map +1 -0
  75. package/dist/publisher/browser-sources.js +92 -0
  76. package/dist/publisher/browser-sources.js.map +1 -0
  77. package/dist/publisher/flux-entrypoint.d.ts +7 -0
  78. package/dist/publisher/flux-entrypoint.d.ts.map +1 -0
  79. package/dist/publisher/flux-entrypoint.js +11 -0
  80. package/dist/publisher/flux-entrypoint.js.map +1 -0
  81. package/dist/publisher/flux.d.ts +121 -0
  82. package/dist/publisher/flux.d.ts.map +1 -0
  83. package/dist/publisher/flux.js +767 -0
  84. package/dist/publisher/flux.js.map +1 -0
  85. package/dist/publisher/helpers.d.ts +19 -0
  86. package/dist/publisher/helpers.d.ts.map +1 -0
  87. package/dist/publisher/helpers.js +84 -0
  88. package/dist/publisher/helpers.js.map +1 -0
  89. package/dist/publisher/mono-entrypoint.d.ts +7 -0
  90. package/dist/publisher/mono-entrypoint.d.ts.map +1 -0
  91. package/dist/publisher/mono-entrypoint.js +11 -0
  92. package/dist/publisher/mono-entrypoint.js.map +1 -0
  93. package/dist/publisher/mono.d.ts +72 -0
  94. package/dist/publisher/mono.d.ts.map +1 -0
  95. package/dist/publisher/mono.js +373 -0
  96. package/dist/publisher/mono.js.map +1 -0
  97. package/dist/publisher/operators/aggregate.d.ts +35 -0
  98. package/dist/publisher/operators/aggregate.d.ts.map +1 -0
  99. package/dist/publisher/operators/aggregate.js +217 -0
  100. package/dist/publisher/operators/aggregate.js.map +1 -0
  101. package/dist/publisher/operators/compat/flux.d.ts +56 -0
  102. package/dist/publisher/operators/compat/flux.d.ts.map +1 -0
  103. package/dist/publisher/operators/compat/flux.js +156 -0
  104. package/dist/publisher/operators/compat/flux.js.map +1 -0
  105. package/dist/publisher/operators/compat/mono.d.ts +82 -0
  106. package/dist/publisher/operators/compat/mono.d.ts.map +1 -0
  107. package/dist/publisher/operators/compat/mono.js +125 -0
  108. package/dist/publisher/operators/compat/mono.js.map +1 -0
  109. package/dist/publisher/operators/coordination.d.ts +82 -0
  110. package/dist/publisher/operators/coordination.d.ts.map +1 -0
  111. package/dist/publisher/operators/coordination.js +345 -0
  112. package/dist/publisher/operators/coordination.js.map +1 -0
  113. package/dist/publisher/operators/error.d.ts +17 -0
  114. package/dist/publisher/operators/error.d.ts.map +1 -0
  115. package/dist/publisher/operators/error.js +48 -0
  116. package/dist/publisher/operators/error.js.map +1 -0
  117. package/dist/publisher/operators/flatten.d.ts +19 -0
  118. package/dist/publisher/operators/flatten.d.ts.map +1 -0
  119. package/dist/publisher/operators/flatten.js +127 -0
  120. package/dist/publisher/operators/flatten.js.map +1 -0
  121. package/dist/publisher/operators/lifecycle.d.ts +103 -0
  122. package/dist/publisher/operators/lifecycle.d.ts.map +1 -0
  123. package/dist/publisher/operators/lifecycle.js +263 -0
  124. package/dist/publisher/operators/lifecycle.js.map +1 -0
  125. package/dist/publisher/operators/lift.d.ts +42 -0
  126. package/dist/publisher/operators/lift.d.ts.map +1 -0
  127. package/dist/publisher/operators/lift.js +343 -0
  128. package/dist/publisher/operators/lift.js.map +1 -0
  129. package/dist/publisher/operators/mono-parity.d.ts +109 -0
  130. package/dist/publisher/operators/mono-parity.d.ts.map +1 -0
  131. package/dist/publisher/operators/mono-parity.js +144 -0
  132. package/dist/publisher/operators/mono-parity.js.map +1 -0
  133. package/dist/publisher/operators/mono.d.ts +30 -0
  134. package/dist/publisher/operators/mono.d.ts.map +1 -0
  135. package/dist/publisher/operators/mono.js +37 -0
  136. package/dist/publisher/operators/mono.js.map +1 -0
  137. package/dist/publisher/operators/register.d.ts +20 -0
  138. package/dist/publisher/operators/register.d.ts.map +1 -0
  139. package/dist/publisher/operators/register.js +23 -0
  140. package/dist/publisher/operators/register.js.map +1 -0
  141. package/dist/publisher/operators/selection.d.ts +25 -0
  142. package/dist/publisher/operators/selection.d.ts.map +1 -0
  143. package/dist/publisher/operators/selection.js +108 -0
  144. package/dist/publisher/operators/selection.js.map +1 -0
  145. package/dist/publisher/operators/side-effect.d.ts +15 -0
  146. package/dist/publisher/operators/side-effect.d.ts.map +1 -0
  147. package/dist/publisher/operators/side-effect.js +81 -0
  148. package/dist/publisher/operators/side-effect.js.map +1 -0
  149. package/dist/publisher/operators/terminal.d.ts +16 -0
  150. package/dist/publisher/operators/terminal.d.ts.map +1 -0
  151. package/dist/publisher/operators/terminal.js +47 -0
  152. package/dist/publisher/operators/terminal.js.map +1 -0
  153. package/dist/publisher/operators/time.d.ts +20 -0
  154. package/dist/publisher/operators/time.d.ts.map +1 -0
  155. package/dist/publisher/operators/time.js +92 -0
  156. package/dist/publisher/operators/time.js.map +1 -0
  157. package/dist/publisher/operators/transform.d.ts +31 -0
  158. package/dist/publisher/operators/transform.d.ts.map +1 -0
  159. package/dist/publisher/operators/transform.js +75 -0
  160. package/dist/publisher/operators/transform.js.map +1 -0
  161. package/dist/publisher/operators/windowing.d.ts +28 -0
  162. package/dist/publisher/operators/windowing.d.ts.map +1 -0
  163. package/dist/publisher/operators/windowing.js +148 -0
  164. package/dist/publisher/operators/windowing.js.map +1 -0
  165. package/dist/publisher/publisher.d.ts +11 -0
  166. package/dist/publisher/publisher.d.ts.map +1 -0
  167. package/dist/publisher/types.d.ts +51 -0
  168. package/dist/publisher/types.d.ts.map +1 -0
  169. package/dist/schedulers/animation-frame-scheduler.d.ts +11 -0
  170. package/dist/schedulers/animation-frame-scheduler.d.ts.map +1 -0
  171. package/dist/schedulers/animation-frame-scheduler.js +30 -0
  172. package/dist/schedulers/animation-frame-scheduler.js.map +1 -0
  173. package/dist/schedulers/base-scheduler.d.ts +28 -0
  174. package/dist/schedulers/base-scheduler.d.ts.map +1 -0
  175. package/dist/schedulers/base-scheduler.js +77 -0
  176. package/dist/schedulers/base-scheduler.js.map +1 -0
  177. package/dist/schedulers/basic-worker.d.ts +22 -0
  178. package/dist/schedulers/basic-worker.d.ts.map +1 -0
  179. package/dist/schedulers/basic-worker.js +71 -0
  180. package/dist/schedulers/basic-worker.js.map +1 -0
  181. package/dist/schedulers/delay-scheduler.d.ts +12 -0
  182. package/dist/schedulers/delay-scheduler.d.ts.map +1 -0
  183. package/dist/schedulers/delay-scheduler.js +17 -0
  184. package/dist/schedulers/delay-scheduler.js.map +1 -0
  185. package/dist/schedulers/disposed.d.ts +4 -0
  186. package/dist/schedulers/disposed.d.ts.map +1 -0
  187. package/dist/schedulers/disposed.js +14 -0
  188. package/dist/schedulers/disposed.js.map +1 -0
  189. package/dist/schedulers/duration.d.ts +8 -0
  190. package/dist/schedulers/duration.d.ts.map +1 -0
  191. package/dist/schedulers/duration.js +11 -0
  192. package/dist/schedulers/duration.js.map +1 -0
  193. package/dist/schedulers/executor-scheduler.d.ts +13 -0
  194. package/dist/schedulers/executor-scheduler.d.ts.map +1 -0
  195. package/dist/schedulers/executor-scheduler.js +43 -0
  196. package/dist/schedulers/executor-scheduler.js.map +1 -0
  197. package/dist/schedulers/immediate-scheduler.d.ts +15 -0
  198. package/dist/schedulers/immediate-scheduler.d.ts.map +1 -0
  199. package/dist/schedulers/immediate-scheduler.js +24 -0
  200. package/dist/schedulers/immediate-scheduler.js.map +1 -0
  201. package/dist/schedulers/index.d.ts +7 -0
  202. package/dist/schedulers/index.d.ts.map +1 -0
  203. package/dist/schedulers/index.js +2 -0
  204. package/dist/schedulers/interval-scheduler.d.ts +12 -0
  205. package/dist/schedulers/interval-scheduler.d.ts.map +1 -0
  206. package/dist/schedulers/interval-scheduler.js +17 -0
  207. package/dist/schedulers/interval-scheduler.js.map +1 -0
  208. package/dist/schedulers/macro-scheduler.d.ts +19 -0
  209. package/dist/schedulers/macro-scheduler.d.ts.map +1 -0
  210. package/dist/schedulers/macro-scheduler.js +30 -0
  211. package/dist/schedulers/macro-scheduler.js.map +1 -0
  212. package/dist/schedulers/microtask-scheduler.d.ts +11 -0
  213. package/dist/schedulers/microtask-scheduler.d.ts.map +1 -0
  214. package/dist/schedulers/microtask-scheduler.js +34 -0
  215. package/dist/schedulers/microtask-scheduler.js.map +1 -0
  216. package/dist/schedulers/schedulers.d.ts +39 -0
  217. package/dist/schedulers/schedulers.d.ts.map +1 -0
  218. package/dist/schedulers/schedulers.js +83 -0
  219. package/dist/schedulers/schedulers.js.map +1 -0
  220. package/dist/schedulers/timeout-scheduler.d.ts +11 -0
  221. package/dist/schedulers/timeout-scheduler.d.ts.map +1 -0
  222. package/dist/schedulers/types.d.ts +35 -0
  223. package/dist/schedulers/types.d.ts.map +1 -0
  224. package/dist/signal/signal-type.d.ts +26 -0
  225. package/dist/signal/signal-type.d.ts.map +1 -0
  226. package/dist/signal/signal-type.js +31 -0
  227. package/dist/signal/signal-type.js.map +1 -0
  228. package/dist/signal/signal.d.ts +33 -0
  229. package/dist/signal/signal.d.ts.map +1 -0
  230. package/dist/signal/signal.js +70 -0
  231. package/dist/signal/signal.js.map +1 -0
  232. package/dist/sinks/index.d.ts +7 -0
  233. package/dist/sinks/index.d.ts.map +1 -0
  234. package/dist/sinks/index.js +2 -0
  235. package/dist/sinks/many.d.ts +66 -0
  236. package/dist/sinks/many.d.ts.map +1 -0
  237. package/dist/sinks/many.js +193 -0
  238. package/dist/sinks/many.js.map +1 -0
  239. package/dist/sinks/one.d.ts +41 -0
  240. package/dist/sinks/one.d.ts.map +1 -0
  241. package/dist/sinks/one.js +144 -0
  242. package/dist/sinks/one.js.map +1 -0
  243. package/dist/sinks/specs.d.ts +25 -0
  244. package/dist/sinks/specs.d.ts.map +1 -0
  245. package/dist/sinks/specs.js +126 -0
  246. package/dist/sinks/specs.js.map +1 -0
  247. package/dist/sinks/subscribers.d.ts +16 -0
  248. package/dist/sinks/subscribers.d.ts.map +1 -0
  249. package/dist/sinks/subscribers.js +32 -0
  250. package/dist/sinks/subscribers.js.map +1 -0
  251. package/dist/sinks/types.d.ts +137 -0
  252. package/dist/sinks/types.d.ts.map +1 -0
  253. package/dist/sinks/types.js +58 -0
  254. package/dist/sinks/types.js.map +1 -0
  255. package/dist/subscription/core-subscriber.d.ts +12 -0
  256. package/dist/subscription/core-subscriber.d.ts.map +1 -0
  257. package/dist/subscription/iterable-subscription.d.ts +64 -0
  258. package/dist/subscription/iterable-subscription.d.ts.map +1 -0
  259. package/dist/subscription/iterable-subscription.js +281 -0
  260. package/dist/subscription/iterable-subscription.js.map +1 -0
  261. package/dist/subscription/reactive-streams.d.ts +8 -0
  262. package/dist/subscription/reactive-streams.d.ts.map +1 -0
  263. package/dist/subscription/reactive-streams.js +0 -0
  264. package/dist/subscription/subscriber.d.ts +17 -0
  265. package/dist/subscription/subscriber.d.ts.map +1 -0
  266. package/dist/subscription/subscription.d.ts +12 -0
  267. package/dist/subscription/subscription.d.ts.map +1 -0
  268. package/package.json +100 -33
  269. package/dist/index.d.mts +0 -2557
  270. package/dist/index.js.map +0 -1
  271. package/dist/index.mjs +0 -2
  272. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,263 @@
1
+ import { Schedulers } from "../../schedulers/schedulers.js";
2
+ import { scheduleDelay } from "../helpers.js";
3
+ import { Flux } from "../flux.js";
4
+ import { liftOneToOne, subscriberContext } from "./lift.js";
5
+ import { Signal } from "../../signal/signal.js";
6
+ //#region src/publisher/operators/lifecycle.ts
7
+ Flux.prototype.cache = function cache(_ttl, _scheduler) {
8
+ const source = this;
9
+ let values;
10
+ let failure;
11
+ let loaded;
12
+ return new Flux(async function* (signal, context) {
13
+ loaded ?? (loaded = (async () => {
14
+ const nextValues = [];
15
+ try {
16
+ for await (const value of source.iterate(signal, context)) nextValues.push(value);
17
+ values = nextValues;
18
+ } catch (error) {
19
+ failure = error;
20
+ }
21
+ })());
22
+ await loaded;
23
+ if (failure !== void 0) throw failure;
24
+ yield* values ?? [];
25
+ });
26
+ };
27
+ Flux.prototype.cancelOn = function cancelOn(_scheduler) {
28
+ return this;
29
+ };
30
+ Flux.prototype.checkpoint = function checkpoint(_description, _forceStackTrace) {
31
+ return this;
32
+ };
33
+ Flux.prototype.contextCapture = function contextCapture() {
34
+ return this;
35
+ };
36
+ Flux.prototype.contextWrite = function contextWrite(contextUpdate) {
37
+ const source = this;
38
+ return liftOneToOne(source, (signal, context) => {
39
+ const nextContext = typeof contextUpdate === "function" ? contextUpdate(context) : context.putAll(contextUpdate);
40
+ return source.iterate(signal, nextContext);
41
+ }, (subscriber) => {
42
+ const context = subscriberContext(subscriber);
43
+ const nextContext = typeof contextUpdate === "function" ? contextUpdate(context) : context.putAll(contextUpdate);
44
+ return {
45
+ onNext: passThrough,
46
+ currentContext: () => nextContext
47
+ };
48
+ });
49
+ };
50
+ Flux.prototype.delaySequence = function delaySequence(delay, scheduler) {
51
+ return this.delaySubscription(delay, scheduler);
52
+ };
53
+ Flux.prototype.delaySubscription = function delaySubscription(delay, scheduler) {
54
+ const source = this;
55
+ return new Flux(async function* (signal, context) {
56
+ if (isDuration(delay)) await scheduleDelay(scheduler ?? Schedulers.timeout(), delay, signal);
57
+ else await drain(delay, signal, context);
58
+ for await (const value of source.iterate(signal, context)) yield value;
59
+ });
60
+ };
61
+ Flux.prototype.delayUntil = function delayUntil(triggerProvider) {
62
+ const source = this;
63
+ return new Flux(async function* (signal, context) {
64
+ for await (const value of source.iterate(signal, context)) {
65
+ await drain(triggerProvider(value), signal, context);
66
+ yield value;
67
+ }
68
+ });
69
+ };
70
+ Flux.prototype.doAfterTerminate = function doAfterTerminate(callback) {
71
+ const source = this;
72
+ return new Flux(async function* (signal, context) {
73
+ let terminated = false;
74
+ try {
75
+ for await (const value of source.iterate(signal, context)) yield value;
76
+ terminated = true;
77
+ } finally {
78
+ if (terminated) callback();
79
+ }
80
+ });
81
+ };
82
+ Flux.prototype.doFirst = function doFirst(callback) {
83
+ const source = this;
84
+ return new Flux((signal, context) => {
85
+ callback();
86
+ return source.iterate(signal, context);
87
+ });
88
+ };
89
+ Flux.prototype.doOnCancel = function doOnCancel(callback) {
90
+ const source = this;
91
+ return new Flux((signal, context) => {
92
+ signal.addEventListener("abort", callback, { once: true });
93
+ return source.iterate(signal, context);
94
+ });
95
+ };
96
+ Flux.prototype.doOnDiscard = function doOnDiscard(_type, _callback) {
97
+ return this;
98
+ };
99
+ Flux.prototype.doOnEach = function doOnEach(callback) {
100
+ const source = this;
101
+ return new Flux(async function* (signal, context) {
102
+ try {
103
+ for await (const value of source.iterate(signal, context)) {
104
+ callback(Signal.next(value));
105
+ yield value;
106
+ }
107
+ callback(Signal.complete());
108
+ } catch (error) {
109
+ callback(Signal.error(error));
110
+ throw error;
111
+ }
112
+ });
113
+ };
114
+ Flux.prototype.doOnRequest = function doOnRequest(callback) {
115
+ const source = this;
116
+ return liftOneToOne(source, (signal, context) => {
117
+ callback(Number.POSITIVE_INFINITY);
118
+ return source.iterate(signal, context);
119
+ }, () => ({
120
+ onNext: passThrough,
121
+ onRequest: callback
122
+ }));
123
+ };
124
+ Flux.prototype.doOnSubscribe = function doOnSubscribe(callback) {
125
+ const source = this;
126
+ return liftOneToOne(source, (signal, context) => {
127
+ callback(noopSubscription());
128
+ return source.iterate(signal, context);
129
+ }, () => ({
130
+ onNext: passThrough,
131
+ onSubscribe: callback
132
+ }));
133
+ };
134
+ Flux.prototype.doOnTerminate = function doOnTerminate(callback) {
135
+ const source = this;
136
+ return new Flux(async function* (signal, context) {
137
+ try {
138
+ for await (const value of source.iterate(signal, context)) yield value;
139
+ callback();
140
+ } catch (error) {
141
+ callback();
142
+ throw error;
143
+ }
144
+ });
145
+ };
146
+ Flux.prototype.limitRate = function limitRate(_highTide, _lowTide) {
147
+ return this;
148
+ };
149
+ Flux.prototype.limitRequest = function limitRequest(n) {
150
+ return this.take(n);
151
+ };
152
+ Flux.prototype.log = function log(category = "Flux") {
153
+ return this.doOnEach((signal) => console.debug(category, signal.type, signal.value ?? signal.error));
154
+ };
155
+ Flux.prototype.metrics = function metrics() {
156
+ return this;
157
+ };
158
+ Flux.prototype.name = function name(_name) {
159
+ return this;
160
+ };
161
+ Flux.prototype.onBackpressureBuffer = function onBackpressureBuffer(..._args) {
162
+ return this;
163
+ };
164
+ Flux.prototype.onBackpressureDrop = function onBackpressureDrop(_callback) {
165
+ return this;
166
+ };
167
+ Flux.prototype.onBackpressureError = function onBackpressureError() {
168
+ return this;
169
+ };
170
+ Flux.prototype.onBackpressureLatest = function onBackpressureLatest() {
171
+ return this;
172
+ };
173
+ Flux.prototype.onErrorComplete = function onErrorComplete(predicate = () => true) {
174
+ const source = this;
175
+ return new Flux(async function* (signal, context) {
176
+ try {
177
+ for await (const value of source.iterate(signal, context)) yield value;
178
+ } catch (error) {
179
+ if (!predicate(error)) throw error;
180
+ }
181
+ });
182
+ };
183
+ Flux.prototype.onErrorContinue = function onErrorContinue(callback) {
184
+ return this.onErrorResume((error) => {
185
+ callback(error, void 0);
186
+ return Flux.empty();
187
+ });
188
+ };
189
+ Flux.prototype.onErrorStop = function onErrorStop() {
190
+ return this;
191
+ };
192
+ Flux.prototype.onTerminateDetach = function onTerminateDetach() {
193
+ return this;
194
+ };
195
+ Flux.prototype.publish = function publish(transformer) {
196
+ return transformer ? Flux.from(transformer(this.share())) : this.share();
197
+ };
198
+ Flux.prototype.publishNext = function publishNext() {
199
+ return this.next();
200
+ };
201
+ Flux.prototype.replay = function replay(..._args) {
202
+ return this.cache();
203
+ };
204
+ Flux.prototype.share = function share() {
205
+ return this;
206
+ };
207
+ Flux.prototype.shareNext = function shareNext() {
208
+ return this.next();
209
+ };
210
+ Flux.prototype.tag = function tag(_key, _value) {
211
+ return this;
212
+ };
213
+ Flux.prototype.tap = function tap(listener) {
214
+ const source = this;
215
+ return new Flux(async function* (signal, context) {
216
+ const actual = typeof listener === "function" ? listener() : listener;
217
+ signal.addEventListener("abort", () => actual.onCancel?.(), { once: true });
218
+ try {
219
+ for await (const value of source.iterate(signal, context)) {
220
+ actual.onNext?.(value);
221
+ actual.onSignal?.(Signal.next(value));
222
+ yield value;
223
+ }
224
+ actual.onComplete?.();
225
+ actual.onSignal?.(Signal.complete());
226
+ } catch (error) {
227
+ actual.onError?.(error);
228
+ actual.onSignal?.(Signal.error(error));
229
+ throw error;
230
+ }
231
+ });
232
+ };
233
+ Flux.prototype.toStream = function toStream() {
234
+ return this;
235
+ };
236
+ /** Returns true when a value can be treated as a duration input. */
237
+ function isDuration(value) {
238
+ return typeof value === "number" || typeof value === "object" && value !== null && !isPublisherLike(value);
239
+ }
240
+ /** Returns true when a value looks like a publisher or iterable source. */
241
+ function isPublisherLike(value) {
242
+ return typeof value.subscribe === "function" || typeof value.then === "function" || typeof value[Symbol.iterator] === "function" || typeof value[Symbol.asyncIterator] === "function";
243
+ }
244
+ /** Consumes a publisher input and ignores all emitted values. */
245
+ async function drain(source, signal, context) {
246
+ for await (const _ of Flux.from(source).iterate(signal, context));
247
+ }
248
+ /** Creates a no-op subscription object for doOnSubscribe callbacks. */
249
+ function noopSubscription() {
250
+ return {
251
+ /** Ignores request accounting for synthetic subscriptions. */
252
+ request() {},
253
+ /** Ignores cancellation for synthetic subscriptions. */
254
+ cancel() {}
255
+ };
256
+ }
257
+ /** Returns an operator value unchanged. */
258
+ function passThrough(value) {
259
+ return value;
260
+ }
261
+ //#endregion
262
+
263
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","names":[],"sources":["../../../src/publisher/operators/lifecycle.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Reactor lifecycle, context, logging and browser backpressure compatibility operators.\n */\nimport {Context} from \"@/context/context.js\";\nimport {ContextView} from \"@/context/context-view.js\";\nimport {Flux} from \"@/publisher/flux.js\";\nimport {scheduleDelay} from \"@/publisher/helpers.js\";\nimport {liftOneToOne, subscriberContext} from \"@/publisher/operators/lift.js\";\nimport type {PublisherInput} from \"@/publisher/types.js\";\nimport {Schedulers} from \"@/schedulers/schedulers.js\";\nimport type {DurationInput, Scheduler} from \"@/schedulers/types.js\";\nimport {Signal} from \"@/signal/signal.js\";\nimport type {Subscription} from \"@/subscription/subscription.js\";\n\n/** Listener shape accepted by the lightweight `tap` compatibility operator. */\nexport interface FluxTapListener<T> {\n /** Invoked for each next value. */\n onNext?(value: T): void;\n\n /** Invoked when the sequence fails. */\n onError?(error: unknown): void;\n\n /** Invoked when the sequence completes. */\n onComplete?(): void;\n\n /** Invoked when the sequence is cancelled. */\n onCancel?(): void;\n\n /** Invoked for materialized next, error and complete signals. */\n onSignal?(signal: Signal<T>): void;\n}\n\ndeclare module \"@/publisher/flux.js\" {\n /** Lifecycle, context and browser backpressure compatibility operators added to Flux. */\n interface Flux<T> {\n /** Replays the collected source values to later subscribers. */\n cache(ttl?: DurationInput, scheduler?: Scheduler): Flux<T>;\n\n /** Schedules cancellation on the provided scheduler when supported by the source. */\n cancelOn(scheduler: Scheduler): Flux<T>;\n\n /** Adds an assembly checkpoint marker. Browser implementation keeps the source unchanged. */\n checkpoint(description?: string, forceStackTrace?: boolean): Flux<T>;\n\n /** Captures ambient context when an integration provides it. Browser implementation keeps the source unchanged. */\n contextCapture(): Flux<T>;\n\n /** Writes subscriber context for upstream operators. */\n contextWrite(context: ContextView | Context | ((context: Context) => Context)): Flux<T>;\n\n /** Delays subscribing to the source. */\n delaySequence(delay: DurationInput, scheduler?: Scheduler): Flux<T>;\n\n /** Delays subscribing to the source by time or until another publisher signals. */\n delaySubscription(delay: DurationInput | PublisherInput<unknown>, scheduler?: Scheduler): Flux<T>;\n\n /** Delays each value until the trigger publisher derived from that value completes. */\n delayUntil(triggerProvider: (value: T) => PublisherInput<unknown>): Flux<T>;\n\n /** Invokes a callback after successful or failed termination. */\n doAfterTerminate(callback: () => void): Flux<T>;\n\n /** Invokes a callback before source iteration starts. */\n doFirst(callback: () => void): Flux<T>;\n\n /** Invokes a callback when the subscription is cancelled. */\n doOnCancel(callback: () => void): Flux<T>;\n\n /** Registers a discard hook. Browser implementation keeps values unchanged. */\n doOnDiscard<R>(type: new (...args: never[]) => R, callback: (value: R) => void): Flux<T>;\n\n /** Invokes a callback for every materialized source signal. */\n doOnEach(callback: (signal: Signal<T>) => void): Flux<T>;\n\n /** Invokes a callback when unbounded demand is requested by the async bridge. */\n doOnRequest(callback: (request: number) => void): Flux<T>;\n\n /** Invokes a callback with a synthetic subscription before source iteration starts. */\n doOnSubscribe(callback: (subscription: Subscription) => void): Flux<T>;\n\n /** Invokes a callback before successful or failed termination. */\n doOnTerminate(callback: () => void): Flux<T>;\n\n /** Keeps request batching metadata. Browser async iteration returns this source unchanged. */\n limitRate(highTide: number, lowTide?: number): Flux<T>;\n\n /** Limits the total number of requested values. */\n limitRequest(n: number): Flux<T>;\n\n /** Logs source signals to the console. */\n log(category?: string): Flux<T>;\n\n /** Keeps metrics compatibility metadata. Browser implementation returns this source unchanged. */\n metrics(): Flux<T>;\n\n /** Keeps a human-readable sequence name. Browser implementation returns this source unchanged. */\n name(name: string): Flux<T>;\n\n /** Buffers on backpressure. Browser async iteration already buffers by pull demand. */\n onBackpressureBuffer(...args: unknown[]): Flux<T>;\n\n /** Drops on backpressure. Browser async iteration keeps pull demand and returns this source unchanged. */\n onBackpressureDrop(callback?: (value: T) => void): Flux<T>;\n\n /** Fails on backpressure. Browser async iteration keeps pull demand and returns this source unchanged. */\n onBackpressureError(): Flux<T>;\n\n /** Keeps only the latest value on backpressure. Browser async iteration returns this source unchanged. */\n onBackpressureLatest(): Flux<T>;\n\n /** Completes instead of failing when the optional predicate accepts the error. */\n onErrorComplete(predicate?: (error: unknown) => boolean): Flux<T>;\n\n /** Continues with completion after invoking an error continuation callback. */\n onErrorContinue(callback: (error: unknown, value: T | undefined) => void): Flux<T>;\n\n /** Stops error continuation mode. Browser implementation returns this source unchanged. */\n onErrorStop(): Flux<T>;\n\n /** Drops terminal-reference retention hints. Browser implementation returns this source unchanged. */\n onTerminateDetach(): Flux<T>;\n\n /** Transforms a shared source or returns a shared source view. */\n publish<R = T>(transformer?: (source: Flux<T>) => PublisherInput<R>): Flux<R>;\n\n /** Returns a Mono with the next value from this source. */\n publishNext(): import(\"@/publisher/mono.js\").Mono<T>;\n\n /** Returns a replaying view of this source. */\n replay(...args: unknown[]): Flux<T>;\n\n /** Returns a shared browser view of this source. */\n share(): Flux<T>;\n\n /** Returns a Mono with the next value from a shared source. */\n shareNext(): import(\"@/publisher/mono.js\").Mono<T>;\n\n /** Stores a metadata tag. Browser implementation returns this source unchanged. */\n tag(key: string, value: string): Flux<T>;\n\n /** Installs listener callbacks for values, terminal signals, and cancellation. */\n tap(listener: FluxTapListener<T> | (() => FluxTapListener<T>)): Flux<T>;\n\n /** Returns an async iterator stream view of this Flux. */\n toStream(): AsyncIterable<T>;\n }\n}\n\nFlux.prototype.cache = function cache<T>(this: Flux<T>, _ttl?: DurationInput, _scheduler?: Scheduler): Flux<T> {\n const source = this;\n let values: T[] | undefined;\n let failure: unknown;\n let loaded: Promise<void> | undefined;\n return new Flux(async function* (signal, context) {\n loaded ??= (async () => {\n const nextValues: T[] = [];\n try {\n for await (const value of source.iterate(signal, context)) {\n nextValues.push(value);\n }\n values = nextValues;\n } catch (error) {\n failure = error;\n }\n })();\n await loaded;\n if (failure !== undefined) {\n throw failure;\n }\n yield* values ?? [];\n });\n};\n\nFlux.prototype.cancelOn = function cancelOn<T>(this: Flux<T>, _scheduler: Scheduler): Flux<T> {\n return this;\n};\n\nFlux.prototype.checkpoint = function checkpoint<T>(\n this: Flux<T>,\n _description?: string,\n _forceStackTrace?: boolean\n): Flux<T> {\n return this;\n};\n\nFlux.prototype.contextCapture = function contextCapture<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.contextWrite = function contextWrite<T>(\n this: Flux<T>,\n contextUpdate: ContextView | Context | ((context: Context) => Context)\n): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n (signal, context) => {\n const nextContext =\n typeof contextUpdate === \"function\"\n ? contextUpdate(context)\n : context.putAll(contextUpdate);\n return source.iterate(signal, nextContext);\n },\n subscriber => {\n const context = subscriberContext(subscriber);\n const nextContext =\n typeof contextUpdate === \"function\"\n ? contextUpdate(context)\n : context.putAll(contextUpdate);\n return {\n onNext: passThrough,\n currentContext: () => nextContext\n };\n }\n );\n};\n\nFlux.prototype.delaySequence = function delaySequence<T>(\n this: Flux<T>,\n delay: DurationInput,\n scheduler?: Scheduler\n): Flux<T> {\n return this.delaySubscription(delay, scheduler);\n};\n\nFlux.prototype.delaySubscription = function delaySubscription<T>(\n this: Flux<T>,\n delay: DurationInput | PublisherInput<unknown>,\n scheduler?: Scheduler\n): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n if (isDuration(delay)) {\n await scheduleDelay(scheduler ?? Schedulers.timeout(), delay, signal);\n } else {\n await drain(delay, signal, context);\n }\n for await (const value of source.iterate(signal, context)) {\n yield value;\n }\n });\n};\n\nFlux.prototype.delayUntil = function delayUntil<T>(\n this: Flux<T>,\n triggerProvider: (value: T) => PublisherInput<unknown>\n): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n for await (const value of source.iterate(signal, context)) {\n await drain(triggerProvider(value), signal, context);\n yield value;\n }\n });\n};\n\nFlux.prototype.doAfterTerminate = function doAfterTerminate<T>(this: Flux<T>, callback: () => void): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n let terminated = false;\n try {\n for await (const value of source.iterate(signal, context)) {\n yield value;\n }\n terminated = true;\n } finally {\n if (terminated) {\n callback();\n }\n }\n });\n};\n\nFlux.prototype.doFirst = function doFirst<T>(this: Flux<T>, callback: () => void): Flux<T> {\n const source = this;\n return new Flux((signal, context) => {\n callback();\n return source.iterate(signal, context);\n });\n};\n\nFlux.prototype.doOnCancel = function doOnCancel<T>(this: Flux<T>, callback: () => void): Flux<T> {\n const source = this;\n return new Flux((signal, context) => {\n signal.addEventListener(\"abort\", callback, {once: true});\n return source.iterate(signal, context);\n });\n};\n\nFlux.prototype.doOnDiscard = function doOnDiscard<T, R>(\n this: Flux<T>,\n _type: new (...args: never[]) => R,\n _callback: (value: R) => void\n): Flux<T> {\n return this;\n};\n\nFlux.prototype.doOnEach = function doOnEach<T>(this: Flux<T>, callback: (signal: Signal<T>) => void): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n try {\n for await (const value of source.iterate(signal, context)) {\n callback(Signal.next(value));\n yield value;\n }\n callback(Signal.complete());\n } catch (error) {\n callback(Signal.error(error));\n throw error;\n }\n });\n};\n\nFlux.prototype.doOnRequest = function doOnRequest<T>(this: Flux<T>, callback: (request: number) => void): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n (signal, context) => {\n callback(Number.POSITIVE_INFINITY);\n return source.iterate(signal, context);\n },\n () => ({\n onNext: passThrough,\n onRequest: callback\n })\n );\n};\n\nFlux.prototype.doOnSubscribe = function doOnSubscribe<T>(\n this: Flux<T>,\n callback: (subscription: Subscription) => void\n): Flux<T> {\n const source = this;\n return liftOneToOne(\n source,\n (signal, context) => {\n callback(noopSubscription());\n return source.iterate(signal, context);\n },\n () => ({\n onNext: passThrough,\n onSubscribe: callback\n })\n );\n};\n\nFlux.prototype.doOnTerminate = function doOnTerminate<T>(this: Flux<T>, callback: () => void): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n try {\n for await (const value of source.iterate(signal, context)) {\n yield value;\n }\n callback();\n } catch (error) {\n callback();\n throw error;\n }\n });\n};\n\nFlux.prototype.limitRate = function limitRate<T>(this: Flux<T>, _highTide: number, _lowTide?: number): Flux<T> {\n return this;\n};\n\nFlux.prototype.limitRequest = function limitRequest<T>(this: Flux<T>, n: number): Flux<T> {\n return this.take(n);\n};\n\nFlux.prototype.log = function log<T>(this: Flux<T>, category = \"Flux\"): Flux<T> {\n return this.doOnEach(signal => console.debug(category, signal.type, signal.value ?? signal.error));\n};\n\nFlux.prototype.metrics = function metrics<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.name = function name<T>(this: Flux<T>, _name: string): Flux<T> {\n return this;\n};\n\nFlux.prototype.onBackpressureBuffer = function onBackpressureBuffer<T>(this: Flux<T>, ..._args: unknown[]): Flux<T> {\n return this;\n};\n\nFlux.prototype.onBackpressureDrop = function onBackpressureDrop<T>(\n this: Flux<T>,\n _callback?: (value: T) => void\n): Flux<T> {\n return this;\n};\n\nFlux.prototype.onBackpressureError = function onBackpressureError<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.onBackpressureLatest = function onBackpressureLatest<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.onErrorComplete = function onErrorComplete<T>(\n this: Flux<T>,\n predicate: (error: unknown) => boolean = () => true\n): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n try {\n for await (const value of source.iterate(signal, context)) {\n yield value;\n }\n } catch (error) {\n if (!predicate(error)) {\n throw error;\n }\n }\n });\n};\n\nFlux.prototype.onErrorContinue = function onErrorContinue<T>(\n this: Flux<T>,\n callback: (error: unknown, value: T | undefined) => void\n): Flux<T> {\n return this.onErrorResume(error => {\n callback(error, undefined);\n return Flux.empty<T>();\n });\n};\n\nFlux.prototype.onErrorStop = function onErrorStop<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.onTerminateDetach = function onTerminateDetach<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.publish = function publish<T, R = T>(\n this: Flux<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\nFlux.prototype.publishNext = function publishNext<T>(this: Flux<T>) {\n return this.next();\n};\n\nFlux.prototype.replay = function replay<T>(this: Flux<T>, ..._args: unknown[]): Flux<T> {\n return this.cache();\n};\n\nFlux.prototype.share = function share<T>(this: Flux<T>): Flux<T> {\n return this;\n};\n\nFlux.prototype.shareNext = function shareNext<T>(this: Flux<T>) {\n return this.next();\n};\n\nFlux.prototype.tag = function tag<T>(this: Flux<T>, _key: string, _value: string): Flux<T> {\n return this;\n};\n\nFlux.prototype.tap = function tap<T>(this: Flux<T>, listener: FluxTapListener<T> | (() => FluxTapListener<T>)): Flux<T> {\n const source = this;\n return new Flux(async function* (signal, context) {\n const actual = typeof listener === \"function\" ? listener() : listener;\n signal.addEventListener(\"abort\", () => actual.onCancel?.(), {once: true});\n try {\n for await (const value of source.iterate(signal, context)) {\n actual.onNext?.(value);\n actual.onSignal?.(Signal.next(value));\n yield value;\n }\n actual.onComplete?.();\n actual.onSignal?.(Signal.complete());\n } catch (error) {\n actual.onError?.(error);\n actual.onSignal?.(Signal.error(error));\n throw error;\n }\n });\n};\n\nFlux.prototype.toStream = function toStream<T>(this: Flux<T>): AsyncIterable<T> {\n return this;\n};\n\n/** Returns true when a value can be treated as a duration input. */\nfunction isDuration(value: unknown): value is DurationInput {\n return typeof value === \"number\" || (typeof value === \"object\" && value !== null && !isPublisherLike(value));\n}\n\n/** Returns true when a value looks like a publisher or iterable source. */\nfunction isPublisherLike(value: object): boolean {\n return (\n typeof (value as { subscribe?: unknown }).subscribe === \"function\" ||\n typeof (value as { then?: unknown }).then === \"function\" ||\n typeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] === \"function\" ||\n typeof (value as { [Symbol.asyncIterator]?: unknown })[Symbol.asyncIterator] === \"function\"\n );\n}\n\n/** Consumes a publisher input and ignores all emitted values. */\nasync function drain(source: PublisherInput<unknown>, signal: AbortSignal, context: Context): Promise<void> {\n for await (const _ of Flux.from(source).iterate(signal, context)) {\n // ignored\n }\n}\n\n/** Creates a no-op subscription object for doOnSubscribe callbacks. */\nfunction noopSubscription(): Subscription {\n return {\n /** Ignores request accounting for synthetic subscriptions. */\n request() {\n // no-op\n },\n /** Ignores cancellation for synthetic subscriptions. */\n cancel() {\n // no-op\n }\n };\n}\n\n/** Returns an operator value unchanged. */\nfunction passThrough<T>(value: T): T {\n return value;\n}\n"],"mappings":";;;;;;AAqJA,KAAK,UAAU,QAAQ,SAAS,MAAwB,MAAsB,YAAiC;CAC3G,MAAM,SAAS;CACf,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,OAAO,IAAI,KAAK,iBAAiB,QAAQ,SAAS;EAC9C,WAAA,UAAY,YAAY;GACpB,MAAM,aAAkB,CAAC;GACzB,IAAI;IACA,WAAW,MAAM,SAAS,OAAO,QAAQ,QAAQ,OAAO,GACpD,WAAW,KAAK,KAAK;IAEzB,SAAS;GACb,SAAS,OAAO;IACZ,UAAU;GACd;EACJ,EAAA,CAAG;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KAAI,CAAC;EACxE,IAAI;GACA,WAAW,MAAM,SAAS,OAAO,QAAQ,QAAQ,OAAO,GAAG;IACvD,OAAO,SAAS,KAAK;IACrB,OAAO,WAAW,OAAO,KAAK,KAAK,CAAC;IACpC,MAAM;GACV;GACA,OAAO,aAAa;GACpB,OAAO,WAAW,OAAO,SAAS,CAAC;EACvC,SAAS,OAAO;GACZ,OAAO,UAAU,KAAK;GACtB,OAAO,WAAW,OAAO,MAAM,KAAK,CAAC;GACrC,MAAM;EACV;CACJ,CAAC;AACL;AAEA,KAAK,UAAU,WAAW,SAAS,WAA6C;CAC5E,OAAO;AACX;;AAGA,SAAS,WAAW,OAAwC;CACxD,OAAO,OAAO,UAAU,YAAa,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,gBAAgB,KAAK;AAC9G;;AAGA,SAAS,gBAAgB,OAAwB;CAC7C,OACI,OAAQ,MAAkC,cAAc,cACxD,OAAQ,MAA6B,SAAS,cAC9C,OAAQ,MAA0C,OAAO,cAAc,cACvE,OAAQ,MAA+C,OAAO,mBAAmB;AAEzF;;AAGA,eAAe,MAAM,QAAiC,QAAqB,SAAiC;CACxG,WAAW,MAAM,KAAK,KAAK,KAAK,MAAM,CAAC,CAAC,QAAQ,QAAQ,OAAO;AAGnE;;AAGA,SAAS,mBAAiC;CACtC,OAAO;;EAEH,UAAU,CAEV;;EAEA,SAAS,CAET;CACJ;AACJ;;AAGA,SAAS,YAAe,OAAa;CACjC,OAAO;AACX"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Internal subscriber-lifting primitives for demand-preserving Flux operators.
4
+ */
5
+ import { Context } from "../../context/context.js";
6
+ import type { SourceFactory } from "../types.js";
7
+ import { Flux } from "../flux.js";
8
+ import type { Subscriber } from "../../subscription/subscriber.js";
9
+ import type { Subscription } from "../../subscription/subscription.js";
10
+ /** Creates the subscriber that an upstream Flux sees for a downstream subscriber. */
11
+ export type SubscriberLifter<T, R> = (subscriber: Subscriber<R>) => Subscriber<T>;
12
+ /** Hooks used by synchronous one-input/one-output operators. */
13
+ export interface OneToOneOperatorHooks<T, R> {
14
+ /** Converts one upstream value into exactly one downstream value. */
15
+ onNext(value: T): R;
16
+ /** Runs before the downstream receives its subscription. */
17
+ onSubscribe?(subscription: Subscription): void;
18
+ /** Runs before an upstream error is forwarded. */
19
+ onError?(error: unknown): void;
20
+ /** Runs before downstream demand is forwarded upstream. */
21
+ onRequest?(request: number): void;
22
+ /** Runs before successful completion is forwarded. */
23
+ onComplete?(): void;
24
+ /** Runs when downstream cancellation is propagated upstream. */
25
+ onCancel?(): void;
26
+ /** Runs after the terminal signal or cancellation has been propagated. */
27
+ onFinally?(signal: "complete" | "error" | "cancel"): void;
28
+ /** Context exposed to the upstream subscriber. */
29
+ currentContext?(): Context;
30
+ }
31
+ /**
32
+ * Lifts a Flux at the Reactive Streams subscriber boundary while keeping an
33
+ * iterable implementation for explicit async-iterator consumption.
34
+ */
35
+ export declare function liftFlux<T, R>(source: Flux<T>, sourceFactory: SourceFactory<R>, lifter: SubscriberLifter<T, R>): Flux<R>;
36
+ /** Creates a one-to-one operator that forwards downstream demand unchanged. */
37
+ export declare function liftOneToOne<T, R>(source: Flux<T>, sourceFactory: SourceFactory<R>, hooksFactory: (subscriber: Subscriber<R>) => OneToOneOperatorHooks<T, R>): Flux<R>;
38
+ /** Creates a filtering operator that replenishes only values dropped from finite demand. */
39
+ export declare function liftFilter<T>(source: Flux<T>, sourceFactory: SourceFactory<T>, predicate: (value: T) => boolean): Flux<T>;
40
+ /** Returns the context exposed by a subscriber, or the shared empty context. */
41
+ export declare function subscriberContext<T>(subscriber: Subscriber<T>): Context;
42
+ //# sourceMappingURL=lift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lift.d.ts","sourceRoot":"","sources":["../../../src/publisher/operators/lift.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE7C,OAA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