@okikio/observables 1.0.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 (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +578 -0
  3. package/esm/_dnt.polyfills.d.ts +20 -0
  4. package/esm/_dnt.polyfills.d.ts.map +1 -0
  5. package/esm/_dnt.polyfills.js +12 -0
  6. package/esm/_spec.d.ts +260 -0
  7. package/esm/_spec.d.ts.map +1 -0
  8. package/esm/_spec.js +1 -0
  9. package/esm/_types.d.ts +141 -0
  10. package/esm/_types.d.ts.map +1 -0
  11. package/esm/_types.js +20 -0
  12. package/esm/error.d.ts +331 -0
  13. package/esm/error.d.ts.map +1 -0
  14. package/esm/error.js +408 -0
  15. package/esm/events.d.ts +320 -0
  16. package/esm/events.d.ts.map +1 -0
  17. package/esm/events.js +451 -0
  18. package/esm/helpers/_types.d.ts +188 -0
  19. package/esm/helpers/_types.d.ts.map +1 -0
  20. package/esm/helpers/_types.js +1 -0
  21. package/esm/helpers/mod.d.ts +90 -0
  22. package/esm/helpers/mod.d.ts.map +1 -0
  23. package/esm/helpers/mod.js +90 -0
  24. package/esm/helpers/operations/batch.d.ts +109 -0
  25. package/esm/helpers/operations/batch.d.ts.map +1 -0
  26. package/esm/helpers/operations/batch.js +140 -0
  27. package/esm/helpers/operations/combination.d.ts +162 -0
  28. package/esm/helpers/operations/combination.d.ts.map +1 -0
  29. package/esm/helpers/operations/combination.js +350 -0
  30. package/esm/helpers/operations/conditional.d.ts +211 -0
  31. package/esm/helpers/operations/conditional.d.ts.map +1 -0
  32. package/esm/helpers/operations/conditional.js +280 -0
  33. package/esm/helpers/operations/core.d.ts +198 -0
  34. package/esm/helpers/operations/core.d.ts.map +1 -0
  35. package/esm/helpers/operations/core.js +264 -0
  36. package/esm/helpers/operations/errors.d.ts +277 -0
  37. package/esm/helpers/operations/errors.d.ts.map +1 -0
  38. package/esm/helpers/operations/errors.js +378 -0
  39. package/esm/helpers/operations/mod.d.ts +26 -0
  40. package/esm/helpers/operations/mod.d.ts.map +1 -0
  41. package/esm/helpers/operations/mod.js +25 -0
  42. package/esm/helpers/operations/timing.d.ts +206 -0
  43. package/esm/helpers/operations/timing.d.ts.map +1 -0
  44. package/esm/helpers/operations/timing.js +457 -0
  45. package/esm/helpers/operators.d.ts +520 -0
  46. package/esm/helpers/operators.d.ts.map +1 -0
  47. package/esm/helpers/operators.js +563 -0
  48. package/esm/helpers/pipe.d.ts +118 -0
  49. package/esm/helpers/pipe.d.ts.map +1 -0
  50. package/esm/helpers/pipe.js +129 -0
  51. package/esm/helpers/utils.d.ts +142 -0
  52. package/esm/helpers/utils.d.ts.map +1 -0
  53. package/esm/helpers/utils.js +193 -0
  54. package/esm/mod.d.ts +863 -0
  55. package/esm/mod.d.ts.map +1 -0
  56. package/esm/mod.js +861 -0
  57. package/esm/observable.d.ts +1610 -0
  58. package/esm/observable.d.ts.map +1 -0
  59. package/esm/observable.js +1970 -0
  60. package/esm/package.json +3 -0
  61. package/esm/queue.d.ts +201 -0
  62. package/esm/queue.d.ts.map +1 -0
  63. package/esm/queue.js +273 -0
  64. package/esm/symbol.d.ts +60 -0
  65. package/esm/symbol.d.ts.map +1 -0
  66. package/esm/symbol.js +132 -0
  67. package/package.json +96 -0
  68. package/script/_dnt.polyfills.d.ts +20 -0
  69. package/script/_dnt.polyfills.d.ts.map +1 -0
  70. package/script/_dnt.polyfills.js +13 -0
  71. package/script/_spec.d.ts +260 -0
  72. package/script/_spec.d.ts.map +1 -0
  73. package/script/_spec.js +2 -0
  74. package/script/_types.d.ts +141 -0
  75. package/script/_types.d.ts.map +1 -0
  76. package/script/_types.js +22 -0
  77. package/script/error.d.ts +331 -0
  78. package/script/error.d.ts.map +1 -0
  79. package/script/error.js +414 -0
  80. package/script/events.d.ts +320 -0
  81. package/script/events.d.ts.map +1 -0
  82. package/script/events.js +458 -0
  83. package/script/helpers/_types.d.ts +188 -0
  84. package/script/helpers/_types.d.ts.map +1 -0
  85. package/script/helpers/_types.js +2 -0
  86. package/script/helpers/mod.d.ts +90 -0
  87. package/script/helpers/mod.d.ts.map +1 -0
  88. package/script/helpers/mod.js +106 -0
  89. package/script/helpers/operations/batch.d.ts +109 -0
  90. package/script/helpers/operations/batch.d.ts.map +1 -0
  91. package/script/helpers/operations/batch.js +144 -0
  92. package/script/helpers/operations/combination.d.ts +162 -0
  93. package/script/helpers/operations/combination.d.ts.map +1 -0
  94. package/script/helpers/operations/combination.js +355 -0
  95. package/script/helpers/operations/conditional.d.ts +211 -0
  96. package/script/helpers/operations/conditional.d.ts.map +1 -0
  97. package/script/helpers/operations/conditional.js +286 -0
  98. package/script/helpers/operations/core.d.ts +198 -0
  99. package/script/helpers/operations/core.d.ts.map +1 -0
  100. package/script/helpers/operations/core.js +272 -0
  101. package/script/helpers/operations/errors.d.ts +277 -0
  102. package/script/helpers/operations/errors.d.ts.map +1 -0
  103. package/script/helpers/operations/errors.js +387 -0
  104. package/script/helpers/operations/mod.d.ts +26 -0
  105. package/script/helpers/operations/mod.d.ts.map +1 -0
  106. package/script/helpers/operations/mod.js +41 -0
  107. package/script/helpers/operations/timing.d.ts +206 -0
  108. package/script/helpers/operations/timing.d.ts.map +1 -0
  109. package/script/helpers/operations/timing.js +464 -0
  110. package/script/helpers/operators.d.ts +520 -0
  111. package/script/helpers/operators.d.ts.map +1 -0
  112. package/script/helpers/operators.js +570 -0
  113. package/script/helpers/pipe.d.ts +118 -0
  114. package/script/helpers/pipe.d.ts.map +1 -0
  115. package/script/helpers/pipe.js +132 -0
  116. package/script/helpers/utils.d.ts +142 -0
  117. package/script/helpers/utils.d.ts.map +1 -0
  118. package/script/helpers/utils.js +200 -0
  119. package/script/mod.d.ts +863 -0
  120. package/script/mod.d.ts.map +1 -0
  121. package/script/mod.js +877 -0
  122. package/script/observable.d.ts +1610 -0
  123. package/script/observable.d.ts.map +1 -0
  124. package/script/observable.js +1984 -0
  125. package/script/package.json +3 -0
  126. package/script/queue.d.ts +201 -0
  127. package/script/queue.d.ts.map +1 -0
  128. package/script/queue.js +286 -0
  129. package/script/symbol.d.ts +60 -0
  130. package/script/symbol.d.ts.map +1 -0
  131. package/script/symbol.js +135 -0
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.every = every;
4
+ exports.some = some;
5
+ exports.find = find;
6
+ exports.unique = unique;
7
+ /**
8
+ * Predicate and decision-oriented operators for Observable streams.
9
+ *
10
+ * This entrypoint exports the operators that answer questions about a stream or
11
+ * gate values based on a condition. These are the Observable equivalents of
12
+ * array helpers such as `every()`, `some()`, and `find()`, plus utilities that
13
+ * stop early once a decision has been reached.
14
+ *
15
+ * Reach for this module when you care about whether a stream contains a match,
16
+ * whether every value passes a rule, or when processing should stop as soon as
17
+ * the answer is known.
18
+ *
19
+ * @module
20
+ */
21
+ require("../../_dnt.polyfills.js");
22
+ const operators_js_1 = require("../operators.js");
23
+ /**
24
+ * Checks if every item in the stream passes a test.
25
+ *
26
+ * Like `Array.prototype.every()`, it stops and returns `false` on the first
27
+ * failure. If the stream completes without any failures, it returns `true`.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { pipe, every, from } from "./helpers/mod.ts";
32
+ *
33
+ * // Array behavior
34
+ * const allEven = [2, 4, 6].every(n => n % 2 === 0); // true
35
+ * const someOdd = [2, 4, 5].every(n => n % 2 === 0); // false
36
+ *
37
+ * // Stream behavior
38
+ * const allEvenStream = from([2, 4, 6]);
39
+ * const result1 = await pipe(allEvenStream, every(n => n % 2 === 0)).toPromise(); // true
40
+ *
41
+ * const someOddStream = from([2, 4, 5]);
42
+ * const result2 = await pipe(someOddStream, every(n => n % 2 === 0)).toPromise(); // false
43
+ * ```
44
+ *
45
+ * ## Practical Use Case
46
+ *
47
+ * Use `every` to verify that all items in a stream meet a certain condition,
48
+ * such as ensuring all uploaded files are of the correct type or that all
49
+ * API responses were successful.
50
+ *
51
+ * ## Key Insight
52
+ *
53
+ * `every` provides a definitive boolean answer for the entire stream, making
54
+ * it a final, summary operation.
55
+ *
56
+ * @typeParam T - Type of values from the source stream
57
+ * @param predicate - Function to test each value
58
+ * @returns A stream operator that tests all values
59
+ */
60
+ function every(predicate) {
61
+ return (0, operators_js_1.createStatefulOperator)({
62
+ name: "every",
63
+ createState: () => ({ index: 0, finished: false }),
64
+ transform(chunk, state, controller) {
65
+ if (state.finished)
66
+ return;
67
+ const result = predicate(chunk, state.index++);
68
+ // If the predicate fails, emit false and complete
69
+ if (!result) {
70
+ state.finished = true;
71
+ controller.enqueue(false);
72
+ controller.terminate();
73
+ }
74
+ },
75
+ // If the stream completes and we haven't emitted yet, emit true
76
+ flush(state, controller) {
77
+ if (!state.finished) {
78
+ controller.enqueue(true);
79
+ }
80
+ },
81
+ });
82
+ }
83
+ /**
84
+ * Checks if at least one item in the stream passes a test.
85
+ *
86
+ * Like `Array.prototype.some()`, it stops and returns `true` on the first
87
+ * success. If the stream completes without any successes, it returns `false`.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import { pipe, some, from } from "./helpers/mod.ts";
92
+ *
93
+ * // Array behavior
94
+ * const hasEven = [1, 3, 4].some(n => n % 2 === 0); // true
95
+ * const noEven = [1, 3, 5].some(n => n % 2 === 0); // false
96
+ *
97
+ * // Stream behavior
98
+ * const hasEvenStream = from([1, 3, 4]);
99
+ * const result1 = await pipe(hasEvenStream, some(n => n % 2 === 0)).toPromise(); // true
100
+ *
101
+ * const noEvenStream = from([1, 3, 5]);
102
+ * const result2 = await pipe(noEvenStream, some(n => n % 2 === 0)).toPromise(); // false
103
+ * ```
104
+ *
105
+ * ## Practical Use Case
106
+ *
107
+ * Use `some` to quickly determine if a condition is met by any item in a
108
+ * stream, such as checking for the existence of a specific user permission or
109
+ * detecting if any item in a batch has an error.
110
+ *
111
+ * ## Key Insight
112
+ *
113
+ * `some` is an efficient way to get a "yes" or "no" answer from a stream
114
+ * without processing all the items.
115
+ *
116
+ * @typeParam T - Type of values from the source stream
117
+ * @param predicate - Function to test each value
118
+ * @returns A stream operator that tests for any matching value
119
+ */
120
+ function some(predicate) {
121
+ return (0, operators_js_1.createStatefulOperator)({
122
+ name: "some",
123
+ createState: () => ({ index: 0, finished: false }),
124
+ transform(chunk, state, controller) {
125
+ if (state.finished)
126
+ return;
127
+ const result = predicate(chunk, state.index++);
128
+ // If the predicate passes, emit true and complete
129
+ if (result) {
130
+ state.finished = true;
131
+ controller.enqueue(true);
132
+ controller.terminate();
133
+ }
134
+ },
135
+ // If the stream completes and we haven't emitted yet, emit false
136
+ flush(state, controller) {
137
+ if (!state.finished) {
138
+ controller.enqueue(false);
139
+ }
140
+ },
141
+ });
142
+ }
143
+ /**
144
+ * Finds the first item in the stream that passes a test.
145
+ *
146
+ * Like `Array.prototype.find()`, it stops and emits the first matching item,
147
+ * then immediately completes the stream.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { pipe, find, from } from "./helpers/mod.ts";
152
+ *
153
+ * // Array behavior
154
+ * const firstEven = [1, 3, 4, 6].find(n => n % 2 === 0); // 4
155
+ *
156
+ * // Stream behavior
157
+ * const numberStream = from([1, 3, 4, 6]);
158
+ * const result = await pipe(numberStream, find(n => n % 2 === 0)).toPromise(); // 4
159
+ * ```
160
+ *
161
+ * ## Practical Use Case
162
+ *
163
+ * Use `find` to locate a specific record or event in a stream without needing
164
+ * to process the entire dataset, such as finding the first available time slot
165
+ * or the first user to log in.
166
+ *
167
+ * ## Key Insight
168
+ *
169
+ * `find` is an efficient shortcut to get the first item you care about from a
170
+ * potentially long stream.
171
+ *
172
+ * @typeParam T - Type of values from the source stream
173
+ * @param predicate - Function to test each value
174
+ * @returns A stream operator that finds the first matching value
175
+ */
176
+ function find(predicate) {
177
+ return (0, operators_js_1.createStatefulOperator)({
178
+ name: "find",
179
+ createState: () => ({ index: 0 }),
180
+ transform(chunk, state, controller) {
181
+ const result = predicate(chunk, state.index++);
182
+ // If the predicate passes, emit the value and complete
183
+ if (result) {
184
+ controller.enqueue(chunk);
185
+ controller.terminate();
186
+ }
187
+ },
188
+ });
189
+ }
190
+ /**
191
+ * Removes duplicate values from the stream, keeping only the first occurrence.
192
+ *
193
+ * Like creating a `new Set()` from an array, but for async streams. You can
194
+ * provide a `keySelector` to determine uniqueness based on an object property.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { pipe, unique, from } from "./helpers/mod.ts";
199
+ *
200
+ * // Array behavior
201
+ * const uniqueNumbers = [...new Set([1, 2, 2, 3, 1])]; // [1, 2, 3]
202
+ *
203
+ * // Stream behavior
204
+ * const numberStream = from([1, 2, 2, 3, 1]);
205
+ * const uniqueStream = pipe(numberStream, unique()); // Emits 1, 2, 3
206
+ *
207
+ * // With a key selector
208
+ * const users = [{ id: 1, name: 'A' }, { id: 2, name: 'B' }, { id: 1, name: 'C' }];
209
+ * const userStream = from(users);
210
+ * const uniqueUserStream = pipe(userStream, unique(user => user.id)); // Emits { id: 1, name: 'A' }, { id: 2, name: 'B' }
211
+ * ```
212
+ *
213
+ * ## Practical Use Case
214
+ *
215
+ * Use `unique` to de-duplicate a stream of events or data, such as processing
216
+ * a list of user IDs where some may appear multiple times, or handling event
217
+ * streams that might emit the same event more than once.
218
+ *
219
+ * ## Key Insight
220
+ *
221
+ * `unique` simplifies de-duplication in asynchronous pipelines, ensuring that
222
+ * downstream operations only run once for each unique item.
223
+ *
224
+ * @typeParam T The type of items in the stream.
225
+ * @typeParam K The type of the key used for uniqueness checks.
226
+ * @param keySelector An optional function to extract a key for uniqueness comparison.
227
+ * @returns An operator that filters out duplicate values.
228
+ */
229
+ function unique(keySelector) {
230
+ return (0, operators_js_1.createStatefulOperator)({
231
+ name: "unique",
232
+ createState: () => ({ seen: new Set() }),
233
+ transform(chunk, state, controller) {
234
+ const key = keySelector
235
+ ? keySelector(chunk)
236
+ : chunk;
237
+ if (!state.seen.has(key)) {
238
+ state.seen.add(key);
239
+ controller.enqueue(chunk);
240
+ }
241
+ },
242
+ });
243
+ }
244
+ /**
245
+ * Emits an item only if it is different from the previous one.
246
+ *
247
+ * This is useful for streams where values can be emitted repeatedly, but you
248
+ * only care about the changes.
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * import { pipe, changed, from } from "./helpers/mod.ts";
253
+ *
254
+ * // No direct Array equivalent, as it depends on sequence.
255
+ *
256
+ * // Stream behavior
257
+ * const valueStream = from([1, 1, 2, 2, 2, 1, 3]);
258
+ * const changedStream = pipe(valueStream, changed()); // Emits 1, 2, 1, 3
259
+ *
260
+ * // With a key selector
261
+ * const userStream = from([
262
+ * { id: 1, status: 'active' },
263
+ * { id: 1, status: 'active' },
264
+ * { id: 1, status: 'inactive' }
265
+ * ]);
266
+ * const statusChangeStream = pipe(userStream, changed(user => user.status));
267
+ * // Emits { id: 1, status: 'active' }, { id: 1, status: 'inactive' }
268
+ * ```
269
+ *
270
+ * ## Practical Use Case
271
+ *
272
+ * Use `changed` to monitor a stream of state updates and only react when the
273
+ * state actually changes. This is common in UI programming for tracking user
274
+ * input or state management.
275
+ *
276
+ * ## Key Insight
277
+ *
278
+ * `changed` filters out noise from repetitive values, allowing you to focus
279
+ * on the moments when something actually changes.
280
+ *
281
+ * @typeParam T The type of items in the stream.
282
+ * @typeParam K The type of the key used for comparison.
283
+ * @param keySelector An optional function to extract a key for comparison.
284
+ * @param compare An optional function to compare two keys for equality.
285
+ * @returns An operator that filters out consecutive duplicate values.
286
+ */
@@ -0,0 +1,198 @@
1
+ import "../../_dnt.polyfills.js";
2
+ import type { ExcludeError, Operator } from "../_types.js";
3
+ import type { ObservableError } from "../../error.js";
4
+ /**
5
+ * Core transformation and terminal operators for everyday stream work.
6
+ *
7
+ * This module is the closest match to familiar array helpers. It exports the
8
+ * operators you reach for first when you want to transform values, filter them,
9
+ * accumulate state, or stop after a condition has been met. In practice, this
10
+ * is where most pipelines start before you add timing or concurrency behavior.
11
+ *
12
+ * The important difference from arrays is error handling. These operators are
13
+ * designed to work with the library's pass-through model, so your callbacks see
14
+ * clean data values while `ObservableError` instances continue downstream
15
+ * unchanged until a dedicated error-handling step decides what to do with them.
16
+ *
17
+ * @module
18
+ */
19
+ /**
20
+ * Transforms each data item, automatically skipping errors.
21
+ *
22
+ * Like `Array.map()`, but errors flow through unchanged:
23
+ *
24
+ * ```ts
25
+ * // Array.map() transforms everything
26
+ * [1, 2, 3].map(n => n * 2) // [2, 4, 6]
27
+ *
28
+ * // Stream map() transforms only data
29
+ * pipe([1, Error, 3], map(n => n * 2)) // [2, Error, 6]
30
+ * ```
31
+ *
32
+ * Your function only receives clean data, never errors:
33
+ *
34
+ * ```ts
35
+ * pipe(
36
+ * userIds,
37
+ * map(id => fetchUser(id)), // Some API calls fail
38
+ * map(user => user.name), // Only runs on real users
39
+ * map(name => name.toUpperCase()) // Only runs on real names
40
+ * );
41
+ * // Result: [Name, Error, Name] - clean transformations, errors preserved
42
+ * ```
43
+ *
44
+ * @param project - Function that transforms each data item
45
+ */
46
+ export declare function map<T, R>(project: (value: ExcludeError<T>, index: number) => R): Operator<T | ObservableError, R | ObservableError>;
47
+ /**
48
+ * Keeps data items that pass your test, always preserves errors.
49
+ *
50
+ * Like `Array.filter()`, but errors automatically pass through:
51
+ *
52
+ * ```ts
53
+ * // Array.filter() tests everything
54
+ * [1, 2, 3, 4].filter(n => n > 2) // [3, 4]
55
+ *
56
+ * // Stream filter() tests only data
57
+ * pipe([1, Error, 3, 4], filter(n => n > 2)) // [Error, 3, 4]
58
+ * ```
59
+ *
60
+ * Your test function only receives clean data:
61
+ *
62
+ * ```ts
63
+ * pipe(
64
+ * users,
65
+ * filter(user => user.isActive), // Only tests real users
66
+ * filter(user => user.age >= 18) // Chain multiple filters
67
+ * );
68
+ * // Result: filtered users + all errors preserved
69
+ * ```
70
+ *
71
+ * @param predicate - Test function that decides which data items to keep
72
+ */
73
+ export declare function filter<T>(predicate: (value: ExcludeError<T>, index: number) => boolean): Operator<T | ObservableError, ExcludeError<T> | ObservableError>;
74
+ /**
75
+ * Takes the first N data items, errors don't count toward the limit.
76
+ *
77
+ * Like `Array.slice(0, N)`, but counts only successful data:
78
+ *
79
+ * ```ts
80
+ * // Array.slice() counts everything
81
+ * [1, "error", 2, 3].slice(0, 2) // [1, "error"] - 2 items total
82
+ *
83
+ * // Stream take() counts only data
84
+ * pipe([1, Error, 2, 3], take(2)) // [1, Error, 2] - 2 data items
85
+ * ```
86
+ *
87
+ * Perfect for pagination and "top N" scenarios:
88
+ *
89
+ * ```ts
90
+ * pipe(
91
+ * productIds,
92
+ * map(id => fetchProduct(id)), // Some API calls fail
93
+ * filter(p => p.rating > 4), // Only high-rated products
94
+ * take(10) // Exactly 10 products + any errors
95
+ * );
96
+ * // Guarantees 10 actual products for your UI
97
+ * ```
98
+ *
99
+ * Stream stops immediately after collecting N data items.
100
+ *
101
+ * @param count - How many data items to take
102
+ */
103
+ export declare function take<T>(count: number): Operator<T | ObservableError, ExcludeError<T> | ObservableError>;
104
+ /**
105
+ * Skips the first N data items, errors don't count toward the skip count.
106
+ *
107
+ * Like `Array.slice(N)`, but counts only successful data:
108
+ *
109
+ * ```ts
110
+ * // Array.slice() counts everything
111
+ * [1, "error", 2, 3].slice(2) // [2, 3] - skipped first 2 items
112
+ *
113
+ * // Stream drop() counts only data
114
+ * pipe([1, Error, 2, 3], drop(2)) // [Error, 3] - skipped first 2 data items
115
+ * ```
116
+ *
117
+ * Perfect for pagination - skip to the right page regardless of errors:
118
+ *
119
+ * ```ts
120
+ * // Page 2: skip first 20 successful products
121
+ * pipe(
122
+ * productIds,
123
+ * map(id => fetchProduct(id)), // Some API calls fail
124
+ * drop(20), // Skip first 20 real products
125
+ * take(20) // Next 20 products
126
+ * );
127
+ * // Errors flow through immediately, don't affect page positioning
128
+ * ```
129
+ *
130
+ * @param count - How many data items to skip
131
+ */
132
+ export declare function drop<T>(count: number): Operator<T | ObservableError, ExcludeError<T> | ObservableError>;
133
+ /**
134
+ * Runs side effects on data items, automatically skipping errors.
135
+ *
136
+ * Like adding `console.log()` to debug, but only logs clean data:
137
+ *
138
+ * ```ts
139
+ * // Regular debugging sees everything (messy)
140
+ * data.map(x => { console.log('Item:', x); return transform(x); })
141
+ *
142
+ * // Stream tap() sees only data (clean)
143
+ * pipe(
144
+ * data,
145
+ * map(x => transform(x)),
146
+ * tap(x => console.log('Processed:', x)) // Only logs real data
147
+ * )
148
+ * ```
149
+ *
150
+ * Perfect for logging, analytics, caching, progress tracking:
151
+ *
152
+ * ```ts
153
+ * pipe(
154
+ * userIds,
155
+ * map(id => fetchUser(id)), // Some API calls fail
156
+ * tap(user => console.log('Loaded:', user.name)), // Clean logs
157
+ * tap(user => analytics.track('user_loaded')), // Business events only
158
+ * filter(user => user.isActive)
159
+ * );
160
+ * // Logs show only successful operations, errors flow silently
161
+ * ```
162
+ *
163
+ * Data flows through unchanged - `tap` just observes.
164
+ *
165
+ * @param fn - Function to run on each data item (for side effects)
166
+ */
167
+ export declare function tap<T>(fn: (value: ExcludeError<T>) => void): Operator<T | ObservableError, T | ObservableError>;
168
+ /**
169
+ * Builds running totals from data, automatically skipping errors.
170
+ *
171
+ * Like `Array.reduce()`, but shows each step and handles errors:
172
+ *
173
+ * ```ts
174
+ * // Array.reduce() gives final result only
175
+ * [1, 2, 3].reduce((sum, n) => sum + n, 0) // 6
176
+ *
177
+ * // Stream scan() shows progressive results
178
+ * pipe([1, Error, 3], scan((sum, n) => sum + n, 0)) // [0, 1, Error, 4]
179
+ * ```
180
+ *
181
+ * Perfect for running totals, counters, building objects:
182
+ *
183
+ * ```ts
184
+ * pipe(
185
+ * productIds,
186
+ * map(id => fetchPrice(id)), // Some API calls fail
187
+ * scan((total, price) => total + price, 0) // Running cart total
188
+ * );
189
+ * // Result: [0, 10, Error, 35, 40] - total ignores errors
190
+ * ```
191
+ *
192
+ * Always starts by emitting your initial value immediately.
193
+ *
194
+ * @param accumulator - Function that combines current total with new data
195
+ * @param seed - Starting value (emitted first)
196
+ */
197
+ export declare function scan<T, R>(accumulator: (acc: R, value: ExcludeError<T>, index: number) => R, seed: R): Operator<T | ObservableError, R | ObservableError>;
198
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/helpers/operations/core.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EACtB,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GACpD,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC,GAAG,eAAe,CAAC,CAapD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAC5D,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAclE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,KAAK,EAAE,MAAM,GACZ,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAoBlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,KAAK,EAAE,MAAM,GACZ,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAgBlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,GAAG,CAAC,CAAC,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GACnC,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC,GAAG,eAAe,CAAC,CAQpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EACvB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,EACjE,IAAI,EAAE,CAAC,GACN,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC,GAAG,eAAe,CAAC,CAqBpD"}