semantic-typescript 0.3.3 → 0.3.8

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 CHANGED
@@ -2,9 +2,59 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- Semantic-TypeScript is a modern stream processing library inspired by JavaScript GeneratorFunction, Java Stream, and MySQL Index. Its core design philosophy is based on building efficient data processing pipelines using data indexing, providing a type-safe, functional-style streaming operation experience for front-end development.
5
+ **Semantic-TypeScript: A Paradigm-Shifting Stream Processing Library for the Modern Web**
6
6
 
7
- Unlike traditional synchronous processing, Semantic employs an asynchronous processing model. When creating a data stream, the time when the terminal receives data entirely depends on when the upstream calls the `accept` and `interrupt` callback functions. This design allows the library to elegantly handle real-time data streams, large datasets, and asynchronous data sources.
7
+ Semantic-TypeScript represents a significant advancement in stream processing technology, synthesising the most effective concepts from JavaScript GeneratorFunction, Java Stream, and MySQL Index paradigms. Its foundational design principle is centred on constructing exceptionally efficient data processing pipelines through sophisticated data indexing methodologies. The library delivers a rigorously type-safe, functionally pure streaming operation experience specifically engineered for contemporary front-end development.
8
+
9
+ In contrast to conventional synchronous processing architectures, Semantic-TypeScript implements a fully asynchronous processing model. During data stream generation, the temporal reception of data at the terminal is determined exclusively by the upstream invocation of the `accept` and `interrupt` callback mechanisms. This deliberate architectural choice enables the library to handle with exceptional grace:
10
+
11
+ - **Real-time data streams** with deterministic latency characteristics
12
+ - **Large-scale datasets** through memory-efficient processing pipelines
13
+ - **Asynchronous data sources** with guaranteed consistency and reliability
14
+
15
+ The library's innovative approach fundamentally reimagines how developers interact with streaming data, providing both unprecedented performance characteristics and developer ergonomics in a single, cohesive package.
16
+
17
+ ### Why Choose Semantic-TypeScript?
18
+
19
+ Selecting the right library for data stream processing in a TypeScript project involves balancing performance, developer experience, and architectural fit. Semantic-TypeScript is engineered to excel across all these dimensions, offering a paradigm-shifting approach for the modern web. Here’s why it stands out.
20
+
21
+ #### 1. **A Unified, Type-Safe Paradigm for Streams**
22
+ Semantic-TypeScript synthesises the most effective concepts from **JavaScript GeneratorFunctions**, **Java Streams API**, and **database indexing strategies**. It provides a consistent, declarative API for processing any data sequence—be it static arrays, real-time events, or asynchronous chunks—while leveraging TypeScript's full power to ensure end-to-end type safety. This eliminates a whole class of runtime errors and transforms stream manipulation into a predictable, compiler-verified activity.
23
+
24
+ #### 2. **Uncompromising Performance with Intelligent Laziness**
25
+ At its core, the library is built on **lazy evaluation**. Operations like `filter`, `map`, and `flatMap` merely compose a processing pipeline; no work is done until a terminal operation (like `collect` or `toArray`) is invoked. This is coupled with **short-circuiting** capabilities (via operations like `limit`, `anyMatch`, or custom `interruptor` functions), which allows the processing to stop early when the result is known, dramatically improving efficiency for large or infinite streams.
26
+
27
+ #### 3. **Architectural Distinction: `Semantic<E>` vs. `Collectable<E>`**
28
+ This library introduces a crucial architectural separation that others often lack:
29
+ * **`Semantic<E>`**: Represents the abstract, lazy stream definition—the "blueprint" of your data transformation. It is immutable and composable.
30
+ * **`Collectable<E>`**: Represents a materialised, executable view of the stream, offering all terminal operations.
31
+
32
+ This separation enforces a clear mental model and allows for optimisations (e.g., an `UnorderedCollectable` can skip expensive sorting steps if order is not required).
33
+
34
+ #### 4. **The Power of the `Collector<E, A, R>` Pattern**
35
+ Inspired by Java, the `Collector` pattern is the engine of flexibility. It decouples the *specification* of how to accumulate stream elements from the *execution* of the stream itself. The library provides a rich set of built-in collectors (`useToArray`, `useGroupBy`, `useSummate`, etc.) for everyday tasks, while the pattern makes it trivial to implement your own complex, reusable reduction logic. This is far more powerful and composable than a fixed set of terminal methods.
36
+
37
+ #### 5. **First-Class Support for Modern Web & Async Data**
38
+ Semantic-TypeScript is designed for contemporary front-end and Node.js development. It offers native factory methods for modern web sources:
39
+ * `from(iterable)`, `range()` for static data.
40
+ * `interval()`, `animationFrame()` for time-based streams.
41
+ * `blob()` for chunked binary data processing.
42
+ * `websocket()` for real-time message streams.
43
+ Its foundational support for both `Iterable` and `AsyncIterable` protocols means it handles synchronous and asynchronous data flows with the same elegant API.
44
+
45
+ #### 6. **Beyond Basic Aggregation: Built-in Statistical Analysis**
46
+ Move beyond simple sums and averages. The library provides dedicated `NumericStatistics` and `BigIntStatistics` classes, offering immediate access to advanced statistical measures directly from your streams—**variance, standard deviation, median, quantiles, skewness, and kurtosis**. This turns complex data analysis into a one-liner, saving you from manual implementation or integrating another specialised library.
47
+
48
+ #### 7. **Designed for Developer Ergonomics**
49
+ * **Fluent, Chainable API**: Write complex data pipelines as readable, sequential chains of operations.
50
+ * **Comprehensive Utility Suite**: Comes with essential guards (`isOptional`, `isSemantic`), type-safe utilities (`useCompare`, `useTraverse`), and functional interfaces out of the box.
51
+ * **`Optional<T>` Integration**: Models the absence of a value safely, eliminating null-pointer concerns in find operations.
52
+ * **Performance Guidance**: The documentation clearly guides you on when to use `toUnordered()` (for maximum speed) versus `toOrdered()` (when sequence matters).
53
+
54
+ #### 8. **Robust, Community-Ready Foundation**
55
+ As an open-source library hosted on **GitHub** and distributed via **npm**, it is built for real-world use. The extensive documentation, complete with time/space complexity annotations and practical examples, lowers the learning curve and provides clarity for performance-sensitive applications.
56
+
57
+ **In summary, choose Semantic-TypeScript if you seek a rigorously designed, type-safe, and high-performance stream processing library that brings the power of enterprise-level data transformation patterns to the TypeScript ecosystem, without compromising on the idioms and needs of modern web development.**
8
58
 
9
59
  ## Installation
10
60
 
@@ -83,7 +133,10 @@ let comparator: Comparator<number> = (a: number, b: number): number => a - b;
83
133
  | `isNumericStatistics(t: unknown): t is NumericStatistics<unknown>` | Check if it is a NumericStatistics instance | O(1) | O(1) |
84
134
  | `isBigIntStatistics(t: unknown): t is BigIntStatistics<unknown>` | Check if it is a BigIntStatistics instance | O(1) | O(1) |
85
135
  | `isPromise(t: unknown): t is Promise<unknown>` | Check if it is a Promise object | O(1) | O(1) |
86
- | `isAsync(t: unknown): t is AsyncFunction` | Check if it is an AsyncFunction | O(1) | O(1) |
136
+ | `isAsyncFunction(t: unknown): t is AsyncFunction` | Check if it is an AsyncFunction | O(1) | O(1) |
137
+ | `isGenerator(t: unknown): t is Generator<unknown>` | Check if it is a Generator | O(1) | O(1) |
138
+ | `isGeneratorFunction(t: unknown): t is GeneratorFunction` | Check if it is a GeneratorFunction | O(1) | O(1) |
139
+ | `isAsyncGeneratorFunction(t: unknown): t is AsyncGeneratorFunction` | Check if it is an AsyncGeneratorFunction | O(1) | O(1) |
87
140
 
88
141
  ```typescript
89
142
  // Type guard usage examples
@@ -94,7 +147,7 @@ if (isString(value)) {
94
147
  }
95
148
 
96
149
  if (isOptional(someValue)) {
97
- someValue.ifPresent((value): void => console.log(val));
150
+ someValue.ifPresent((value): void => console.log(value));
98
151
  }
99
152
 
100
153
  if(isIterable(value)){
@@ -111,7 +164,9 @@ if(isIterable(value)){
111
164
  |------|------|------------|------------|
112
165
  | `useCompare<T>(t1: T, t2: T): number` | Generic comparison function | O(1) | O(1) |
113
166
  | `useRandom<T = number \| bigint>(index: T): T` | Pseudo-random number generator | O(log n) | O(1) |
114
- | `useTraverse(t, callback)` | Deep traverse an object without cyclic references | O(n) | O(1) |
167
+ | `useTraverse(t, callback: BiPredicate<keyof T, T[keyof T]>): void` | Deep traverse an object without cyclic references | O(n) | O(1) |
168
+ | `useToNumber(t: unknown): number` | Convert a value to a number | O(1) | O(1) |
169
+ | `useToBigInt(t: unknown): bigint` | Convert a value to a BigInt | O(1) | O(1) |
115
170
 
116
171
  ```typescript
117
172
  // Utility function usage examples
@@ -140,6 +195,12 @@ useTraverse(o, (value, key): boolean => {
140
195
  */
141
196
  return true; // Returns true to continue traversing.
142
197
  });
198
+
199
+ let toBeResolved: object = {
200
+ [Symbol.toPrimitive]: () => 5
201
+ };
202
+ let resolvedNumber: number = useToNumber(toBeResolved); // 5
203
+ let resolvedBigInt: bigint = useToBigInt(toBeResolved); // 5n
143
204
  ```
144
205
 
145
206
  ## Factory Methods
@@ -148,10 +209,10 @@ useTraverse(o, (value, key): boolean => {
148
209
 
149
210
  | Method | Description | Time Complexity | Space Complexity |
150
211
  |------|------|------------|------------|
151
- | `Optional.empty<T>()` | Create an empty Optional | O(1) | O(1) |
152
- | `Optional.of<T>(value)` | Create an Optional containing a value | O(1) | O(1) |
153
- | `Optional.ofNullable<T>(value)` | Create a potentially empty Optional | O(1) | O(1) |
154
- | `Optional.ofNonNull<T>(value)` | Create a non-null Optional | O(1) | O(1) |
212
+ | `Optional.empty<T>(): Optional<T>` | Create an empty Optional | O(1) | O(1) |
213
+ | `Optional.of<T>(value): Optional<T>` | Create an Optional containing a value | O(1) | O(1) |
214
+ | `Optional.ofNullable<T>(value): Optional<T>` | Create a potentially empty Optional | O(1) | O(1) |
215
+ | `Optional.ofNonNull<T>(value): Optional<T>` | Create a non-null Optional | O(1) | O(1) |
155
216
 
156
217
  ```typescript
157
218
  // Optional usage examples
@@ -160,7 +221,7 @@ let present: Optional<number> = Optional.of(42);
160
221
  let nullable: Optional<string> = Optional.ofNullable<string>(null);
161
222
  let nonNull: Optional<string> = Optional.ofNonNull("hello");
162
223
 
163
- presentO.ifPresent((value: number): void => console.log(value)); // Outputs 42
224
+ present.ifPresent((value: number): void => console.log(value)); // Outputs 42
164
225
  console.log(empty.get(100)); // Outputs 100
165
226
  ```
166
227
 
@@ -168,44 +229,93 @@ console.log(empty.get(100)); // Outputs 100
168
229
 
169
230
  | Method | Description | Time Complexity | Space Complexity |
170
231
  |------|------|------------|------------|
171
- | `Collector.full(identity, accumulator, finisher)` | Create a full collector | O(1) | O(1) |
172
- | `Collector.shortable(identity, interruptor, accumulator, finisher)` | Create an interruptible collector | O(1) | O(1) |
173
- | `useAnyMatch<E>(predicate)` | Create a shortable collector returning true if any element matches the predicate | O(n) | O(1) |
174
- | `useAllMatch<E>(predicate)` | Create a shortable collector returning true if all elements match the predicate | O(n) | O(1) |
175
- | `useCollect<E, A, R>(identity, accumulator, finisher)` | Create a full collector with identity, accumulator, finisher | O(1) | O(1) |
176
- | `useCollect<E, A, R>(identity, interruptor, accumulator, finisher)` | Create a shortable collector with identity, interruptor, accumulator, finisher | O(1) | O(1) |
177
- | `useCount<E>()` | Create a full collector counting elements | O(n) | O(1) |
178
- | `useFindFirst<E>()` | Create a shortable collector returning the first element | O(n) | O(1) |
179
- | `useFindAny<E>()` | Create a shortable collector returning any element | O(n) | O(1) |
180
- | `useFindLast<E>()` | Create a full collector returning the last element | O(n) | O(1) |
181
- | `useForEach<E>(action)` | Create a full collector executing an action for each element | O(n) | O(1) |
182
- | `useNoneMatch<E>(predicate)` | Create a shortable collector returning true if no element matches the predicate | O(n) | O(1) |
183
- | `useGroup<E, K>(classifier)` | Create a full collector grouping elements by classifier key | O(n) | O(n) |
184
- | `useGroupBy<E, K, V>(keyExtractor, valueExtractor)` | Create a full collector grouping elements by key with extracted values | O(n) | O(n) |
185
- | `useJoin<E>()` | Create a full collector joining elements into a string with default format | O(n) | O(1) |
186
- | `useJoin<E>(delimiter)` | Create a full collector joining elements with delimiter | O(n) | O(1) |
187
- | `useJoin<E>(prefix, delimiter, suffix)` | Create a full collector joining elements with prefix, delimiter, suffix | O(n) | O(1) |
188
- | `useJoin<E>(prefix, accumulator, suffix)` | Create a full collector joining elements via custom accumulator | O(n) | O(1) |
189
- | `useLog<E>()` | Create a full collector logging elements to console with default format | O(n) | O(1) |
190
- | `useLog<E>(accumulator)` | Create a full collector logging elements via custom accumulator | O(n) | O(1) |
191
- | `useLog<E>(prefix, accumulator, suffix)` | Create a full collector logging elements with prefix/suffix via accumulator | O(n) | O(1) |
192
- | `usePartition<E>(count)` | Create a full collector partitioning elements into chunks of specified size | O(n) | O(n) |
193
- | `usePartitionBy<E>(classifier)` | Create a full collector partitioning elements by classifier result | O(n) | O(n) |
194
- | `useReduce<E>(accumulator)` | Create a full collector reducing elements without identity | O(n) | O(1) |
195
- | `useReduce<E>(identity, accumulator)` | Create a full collector reducing elements with identity | O(n) | O(1) |
196
- | `useReduce<E, R>(identity, accumulator, finisher)` | Create a full collector reducing elements with identity, accumulator, finisher | O(n) | O(1) |
197
- | `useToArray<E>()` | Create a full collector gathering elements into an array | O(n) | O(n) |
198
- | `useToMap<E, K, V>(keyExtractor, valueExtractor)` | Create a full collector gathering elements into a Map | O(n) | O(n) |
199
- | `useToSet<E>()` | Create a full collector gathering elements into a Set | O(n) | O(n) |
200
- | `useWrite<E, S>(stream)` | Create a full collector writing elements to a stream | O(n) | O(1) |
201
- | `useWrite<E, S>(stream, accumulator)` | Create a full collector writing elements via custom accumulator | O(n) | O(1) |
202
- | `useNumericAverage<E>(mapper)` | Create a full collector computing numeric average with mapper | O(n) | O(1) |
203
- | `useNumericAverage<E>()` | Create a full collector computing numeric average | O(n) | O(1) |
204
- | `useBigIntAverage<E>(mapper)` | Create a full collector computing bigint average with mapper | O(n) | O(1) |
205
- | `useBigIntAverage<E>()` | Create a full collector computing bigint average | O(n) | O(1) |
206
- | `useFrequency<E>()` | Create a full collector counting element frequencies | O(n) | O(n) |
207
- | `useSummate<E>(mapper)` | Create a full collector summing mapped numeric values | O(n) | O(1) |
208
- | `useSummate<E>()` | Create a full collector summing numeric elements | O(n) | O(1) |
232
+ | `Collector.full(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create a full collector | O(1) | O(1) |
233
+ | `Collector.full(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create a full collector | O(1) | O(1) |
234
+ | `Collector.shortable(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create an interruptible collector | O(1) | O(1) |
235
+ | `Collector.shortable(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create an interruptible collector | O(1) | O(1) |
236
+ | `Collector.shortable(identity: Supplier<A>, interruptor: BiPredicate<E, bigint>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create an interruptible collector | O(1) | O(1) |
237
+ | `Collector.shortable(identity: Supplier<A>, interruptor: BiPredicate<E, bigint>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create an interruptible collector | O(1) | O(1) |
238
+ | `Collector.shortable(identity: Supplier<A>, interruptor: TriPredicate<E, bigint, A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create an interruptible collector | O(1) | O(1) |
239
+ | `Collector.shortable(identity: Supplier<A>, interruptor: TriPredicate<E, bigint, A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Create an interruptible collector | O(1) | O(1) |
240
+ | `useAnyMatch<E>(predicate: Predicate<E>): Collector<E, boolean, boolean>` | Creates a collector that checks if any element matches the predicate | `predicate: Predicate<E>` | `Collector<E, boolean, boolean>` |
241
+ | `useAllMatch<E>(predicate: Predicate<E>): Collector<E, boolean, boolean>` | Creates a collector that checks if all elements match the predicate | `predicate: Predicate<E>` | `Collector<E, boolean, boolean>` |
242
+ | `useCollect<E, A, R>(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates a full collector | `identity: Supplier<A>`, `accumulator: BiFunctional<A, E, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
243
+ | `useCollect<E, A, R>(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates a full collector | `identity: Supplier<A>`, `accumulator: TriFunctional<A, E, bigint, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
244
+ | `useCollect<E, A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates an interruptible collector | `identity: Supplier<A>`, `interruptor: Predicate<E>`, `accumulator: BiFunctional<A, E, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
245
+ | `useCollect<E, A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates an interruptible collector | `identity: Supplier<A>`, `interruptor: Predicate<E>`, `accumulator: TriFunctional<A, E, bigint, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
246
+ | `useCollect<E, A, R>(identity: Supplier<A>, interruptor: BiPredicate<E, bigint>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates an interruptible collector | `identity: Supplier<A>`, `interruptor: BiPredicate<E, bigint>`, `accumulator: BiFunctional<A, E, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
247
+ | `useCollect<E, A, R>(identity: Supplier<A>, interruptor: BiPredicate<E, bigint>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates an interruptible collector | `identity: Supplier<A>`, `interruptor: BiPredicate<E, bigint>`, `accumulator: TriFunctional<A, E, bigint, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
248
+ | `useCollect<E, A, R>(identity: Supplier<A>, interruptor: TriPredicate<E, bigint, A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates an interruptible collector | `identity: Supplier<A>`, `interruptor: TriPredicate<E, bigint, A>`, `accumulator: BiFunctional<A, E, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
249
+ | `useCollect<E, A, R>(identity: Supplier<A>, interruptor: TriPredicate<E, bigint, A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>` | Creates an interruptible collector | `identity: Supplier<A>`, `interruptor: TriPredicate<E, bigint, A>`, `accumulator: TriFunctional<A, E, bigint, A>`, `finisher: Functional<A, R>` | `Collector<E, A, R>` |
250
+ | `useCount<E = unknown>(): Collector<E, bigint, bigint>` | Creates a collector that counts elements | None | `Collector<E, bigint, bigint>` |
251
+ | `useError<E = unknown>(): Collector<E, string, string>` | Creates a collector that accumulates errors to console.error | None | `Collector<E, string, string>` |
252
+ | `useError<E = unknown>(accumulator: BiFunctional<string, E, string>): Collector<E, string, string>` | Creates a collector that accumulates errors with custom accumulator | `accumulator: BiFunctional<string, E, string>` | `Collector<E, string, string>` |
253
+ | `useError<E = unknown>(accumulator: TriFunctional<string, E, bigint, string>): Collector<E, string, string>` | Creates a collector that accumulates errors with custom accumulator | `accumulator: TriFunctional<string, E, bigint, string>` | `Collector<E, string, string>` |
254
+ | `useError<E = unknown>(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): Collector<E, string, string>` | Creates a collector that accumulates errors with prefix and suffix | `prefix: string`, `accumulator: BiFunctional<string, E, string>`, `suffix: string` | `Collector<E, string, string>` |
255
+ | `useError<E = unknown>(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): Collector<E, string, string>` | Creates a collector that accumulates errors with prefix and suffix | `prefix: string`, `accumulator: TriFunctional<string, E, bigint, string>`, `suffix: string` | `Collector<E, string, string>` |
256
+ | `useFindFirst<E>(): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds the first element | None | `Collector<E, Optional<E>, Optional<E>>` |
257
+ | `useFindAny<E>(): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds any element randomly | None | `Collector<E, Optional<E>, Optional<E>>` |
258
+ | `useFindLast<E>(): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds the last element | None | `Collector<E, Optional<E>, Optional<E>>` |
259
+ | `useFindMaximum<E>(): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds the maximum element | None | `Collector<E, Optional<E>, Optional<E>>` |
260
+ | `useFindMaximum<E>(comparator: Comparator<E>): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds the maximum element with custom comparator | `comparator: Comparator<E>` | `Collector<E, Optional<E>, Optional<E>>` |
261
+ | `useFindMinimum<E>(): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds the minimum element | None | `Collector<E, Optional<E>, Optional<E>>` |
262
+ | `useFindMinimum<E>(comparator: Comparator<E>): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that finds the minimum element with custom comparator | `comparator: Comparator<E>` | `Collector<E, Optional<E>, Optional<E>>` |
263
+ | `useForEach<E>(action: Consumer<E>): Collector<E, bigint, bigint>` | Creates a collector that performs an action on each element | `action: Consumer<E>` | `Collector<E, bigint, bigint>` |
264
+ | `useForEach<E>(action: BiConsumer<E, bigint>): Collector<E, bigint, bigint>` | Creates a collector that performs an action on each element with index | `action: BiConsumer<E, bigint>` | `Collector<E, bigint, bigint>` |
265
+ | `useNoneMatch<E>(predicate: Predicate<E>): Collector<E, boolean, boolean>` | Creates a collector that checks if no element matches the predicate | `predicate: Predicate<E>` | `Collector<E, boolean, boolean>` |
266
+ | `useGroup<E, K>(classifier: Functional<E, K>): Collector<E, Map<K, E[]>, Map<K, E[]>>` | Creates a collector that groups elements by classifier | `classifier: Functional<E, K>` | `Collector<E, Map<K, E[]>, Map<K, E[]>>` |
267
+ | `useGroupBy<E, K, V>(keyExtractor: Functional<E, K>, valueExtractor: Functional<E, V>): Collector<E, Map<K, V[]>, Map<K, V[]>>` | Creates a collector that groups elements by key and extracts values | `keyExtractor: Functional<E, K>`, `valueExtractor: Functional<E, V>` | `Collector<E, Map<K, V[]>, Map<K, V[]>>` |
268
+ | `useJoin<E = unknown>(): Collector<E, string, string>` | Creates a collector that joins elements into a string | None | `Collector<E, string, string>` |
269
+ | `useJoin<E = unknown>(delimiter: string): Collector<E, string, string>` | Creates a collector that joins elements with delimiter | `delimiter: string` | `Collector<E, string, string>` |
270
+ | `useJoin<E = unknown>(prefix: string, delimiter: string, suffix: string): Collector<E, string, string>` | Creates a collector that joins elements with prefix, delimiter, and suffix | `prefix: string`, `delimiter: string`, `suffix: string` | `Collector<E, string, string>` |
271
+ | `useJoin<E = unknown>(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): Collector<E, string, string>` | Creates a collector that joins elements with custom accumulator | `prefix: string`, `accumulator: BiFunctional<string, E, string>`, `suffix: string` | `Collector<E, string, string>` |
272
+ | `useJoin<E = unknown>(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): Collector<E, string, string>` | Creates a collector that joins elements with custom accumulator | `prefix: string`, `accumulator: TriFunctional<string, E, bigint, string>`, `suffix: string` | `Collector<E, string, string>` |
273
+ | `useLog<E = unknown>(): Collector<E, string, string>` | Creates a collector that accumulates logs to console.log | None | `Collector<E, string, string>` |
274
+ | `useLog<E = unknown>(accumulator: BiFunctional<string, E, string>): Collector<E, string, string>` | Creates a collector that accumulates logs with custom accumulator | `accumulator: BiFunctional<string, E, string>` | `Collector<E, string, string>` |
275
+ | `useLog<E = unknown>(accumulator: TriFunctional<string, E, bigint, string>): Collector<E, string, string>` | Creates a collector that accumulates logs with custom accumulator | `accumulator: TriFunctional<string, E, bigint, string>` | `Collector<E, string, string>` |
276
+ | `useLog<E = unknown>(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): Collector<E, string, string>` | Creates a collector that accumulates logs with prefix and suffix | `prefix: string`, `accumulator: BiFunctional<string, E, string>`, `suffix: string` | `Collector<E, string, string>` |
277
+ | `useLog<E = unknown>(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): Collector<E, string, string>` | Creates a collector that accumulates logs with prefix and suffix | `prefix: string`, `accumulator: TriFunctional<string, E, bigint, string>`, `suffix: string` | `Collector<E, string, string>` |
278
+ | `usePartition<E>(count: bigint): Collector<E, Array<Array<E>>, Array<Array<E>>>` | Creates a collector that partitions elements into groups | `count: bigint` | `Collector<E, Array<Array<E>>, Array<Array<E>>>` |
279
+ | `usePartitionBy<E>(classifier: Functional<E, bigint>): Collector<E, Array<E[]>, Array<E[]>>` | Creates a collector that partitions elements by classifier | `classifier: Functional<E, bigint>` | `Collector<E, Array<E[]>, Array<E[]>>` |
280
+ | `useReduce<E>(accumulator: BiFunctional<E, E, E>): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that reduces elements | `accumulator: BiFunctional<E, E, E>` | `Collector<E, Optional<E>, Optional<E>>` |
281
+ | `useReduce<E>(accumulator: TriFunctional<E, E, bigint, E>): Collector<E, Optional<E>, Optional<E>>` | Creates a collector that reduces elements | `accumulator: TriFunctional<E, E, bigint, E>` | `Collector<E, Optional<E>, Optional<E>>` |
282
+ | `useReduce<E>(identity: E, accumulator: BiFunctional<E, E, E>): Collector<E, E, E>` | Creates a collector that reduces elements with identity | `identity: E`, `accumulator: BiFunctional<E, E, E>` | `Collector<E, E, E>` |
283
+ | `useReduce<E>(identity: E, accumulator: TriFunctional<E, E, bigint, E>): Collector<E, E, E>` | Creates a collector that reduces elements with identity | `identity: E`, `accumulator: TriFunctional<E, E, bigint, E>` | `Collector<E, E, E>` |
284
+ | `useReduce<E, R>(identity: R, accumulator: BiFunctional<R, E, R>, finisher: Functional<R, R>): Collector<E, R, R>` | Creates a collector that reduces elements with identity and finisher | `identity: R`, `accumulator: BiFunctional<R, E, R>`, `finisher: Functional<R, R>` | `Collector<E, R, R>` |
285
+ | `useReduce<E, R>(identity: R, accumulator: TriFunctional<R, E, bigint, R>, finisher: Functional<R, R>): Collector<E, R, R>` | Creates a collector that reduces elements with identity and finisher | `identity: R`, `accumulator: TriFunctional<R, E, bigint, R>`, `finisher: Functional<R, R>` | `Collector<E, R, R>` |
286
+ | `useToArray<E>(): Collector<E, E[], E[]>` | Creates a collector that accumulates elements into an array | None | `Collector<E, E[], E[]>` |
287
+ | `useToMap<E, K, V>(keyExtractor: Functional<E, K>, valueExtractor: Functional<E, V>): Collector<E, Map<K, V>, Map<K, V>>` | Creates a collector that accumulates elements into a map | `keyExtractor: Functional<E, K>`, `valueExtractor: Functional<E, V>` | `Collector<E, Map<K, V>, Map<K, V>>` |
288
+ | `useToSet<E>(): Collector<E, Set<E>, Set<E>>` | Creates a collector that accumulates elements into a set | None | `Collector<E, Set<E>, Set<E>>` |
289
+ | `useWrite<E, S = string>(stream: WritableStream<S>): Collector<E, Promise<WritableStream<S>>, Promise<WritableStream<S>>>` | Creates a collector that writes elements to a stream | `stream: WritableStream<S>` | `Collector<E, Promise<WritableStream<S>>, Promise<WritableStream<S>>>` |
290
+ | `useWrite<E, S = string>(stream: WritableStream<S>, accumulator: BiFunctional<WritableStream<S>, E, WritableStream<S>>): Collector<E, Promise<WritableStream<S>>, Promise<WritableStream<S>>>` | Creates a collector that writes elements to a stream with custom accumulator | `stream: WritableStream<S>`, `accumulator: BiFunctional<WritableStream<S>, E, WritableStream<S>>` | `Collector<E, Promise<WritableStream<S>>, Promise<WritableStream<S>>>` |
291
+ | `useWrite<E, S = string>(stream: WritableStream<S>, accumulator: TriFunctional<WritableStream<S>, E, bigint, WritableStream<S>>): Collector<E, Promise<WritableStream<S>>, Promise<WritableStream<S>>>` | Creates a collector that writes elements to a stream with custom accumulator | `stream: WritableStream<S>`, `accumulator: TriFunctional<WritableStream<S>, E, bigint, WritableStream<S>>` | `Collector<E, Promise<WritableStream<S>>, Promise<WritableStream<S>>>` |
292
+ | `useNumericSummate<E>(): Collector<E, number, number>` | Creates a collector that sums numeric values | None | `Collector<number, number, number>` or `Collector<E, number, number>` |
293
+ | `useNumericSummate<E>(mapper: Functional<E, number>): Collector<E, number, number>` | Creates a collector that sums mapped numeric values | `mapper: Functional<E, number>` | `Collector<E, number, number>` |
294
+ | `useBigIntSummate<E>(): Collector<E, bigint, bigint>` | Creates a collector that sums bigint values | None | `Collector<bigint, bigint, bigint>` or `Collector<E, bigint, bigint>` |
295
+ | `useBigIntSummate<E>(mapper: Functional<E, bigint>): Collector<E, bigint, bigint>` | Creates a collector that sums mapped bigint values | `mapper: Functional<E, bigint>` | `Collector<E, bigint, bigint>` |
296
+ | `useNumericAverage<E>(): Collector<E, NumericAverageAccumulator, number>` | Creates a collector that calculates numeric average | None | `Collector<number, NumericAverageAccumulator, number>` or `Collector<E, NumericAverageAccumulator, number>` |
297
+ | `useNumericAverage<E>(mapper: Functional<E, number>): Collector<E, NumericAverageAccumulator, number>` | Creates a collector that calculates numeric average of mapped values | `mapper: Functional<E, number>` | `Collector<E, NumericAverageAccumulator, number>` |
298
+ | `useBigIntAverage<E>(): Collector<E, BigIntAverageAccumulator, bigint>` | Creates a collector that calculates bigint average | None | `Collector<bigint, BigIntAverageAccumulator, bigint>` or `Collector<E, BigIntAverageAccumulator, bigint>` |
299
+ | `useBigIntAverage<E>(mapper: Functional<E, bigint>): Collector<E, BigIntAverageAccumulator, bigint>` | Creates a collector that calculates bigint average of mapped values | `mapper: Functional<E, bigint>` | `Collector<E, BigIntAverageAccumulator, bigint>` |
300
+ | `useFrequency<E>(): Collector<E, Map<E, bigint>, Map<E, bigint>>` | Creates a collector that counts frequency of elements | None | `Collector<E, Map<E, bigint>, Map<E, bigint>>` |
301
+ | `useNumericMode<E>(): Collector<E, Map<number, bigint>, number>` | Creates a collector that finds numeric mode | None | `Collector<number, Map<number, bigint>, number>` or `Collector<E, Map<number, bigint>, number>` |
302
+ | `useNumericMode<E>(mapper: Functional<E, number>): Collector<E, Map<number, bigint>, number>` | Creates a collector that finds numeric mode of mapped values | `mapper: Functional<E, number>` | `Collector<E, Map<number, bigint>, number>` |
303
+ | `useBigIntMode<E>(): Collector<E, Map<bigint, bigint>, bigint>` | Creates a collector that finds bigint mode | None | `Collector<bigint, Map<bigint, bigint>, bigint>` or `Collector<E, Map<bigint, bigint>, bigint>` |
304
+ | `useBigIntMode<E>(mapper: Functional<E, bigint>): Collector<E, Map<bigint, bigint>, bigint>` | Creates a collector that finds bigint mode of mapped values | `mapper: Functional<E, bigint>` | `Collector<E, Map<bigint, bigint>, bigint>` |
305
+ | `useNumericVariance<E>(): Collector<E, VarianceAccumulator, number>` | Creates a collector that calculates numeric variance | None | `Collector<number, VarianceAccumulator, number>` or `Collector<E, VarianceAccumulator, number>` |
306
+ | `useNumericVariance<E>(mapper: Functional<E, number>): Collector<E, VarianceAccumulator, number>` | Creates a collector that calculates numeric variance of mapped values | `mapper: Functional<E, number>` | `Collector<E, VarianceAccumulator, number>` |
307
+ | `useBigIntVariance<E>(): Collector<E, BigIntVarianceAccumulator, bigint>` | Creates a collector that calculates bigint variance | None | `Collector<bigint, BigIntVarianceAccumulator, bigint>` or `Collector<E, BigIntVarianceAccumulator, bigint>` |
308
+ | `useBigIntVariance<E>(mapper: Functional<E, bigint>): Collector<E, BigIntVarianceAccumulator, bigint>` | Creates a collector that calculates bigint variance of mapped values | `mapper: Functional<E, bigint>` | `Collector<E, BigIntVarianceAccumulator, bigint>` |
309
+ | `useNumericStandardDeviation<E>(): Collector<E, StandardDeviationAccumulator, number>` | Creates a collector that calculates numeric standard deviation | None | `Collector<number, StandardDeviationAccumulator, number>` or `Collector<E, StandardDeviationAccumulator, number>` |
310
+ | `useNumericStandardDeviation<E>(mapper: Functional<E, number>): Collector<E, StandardDeviationAccumulator, number>` | Creates a collector that calculates numeric standard deviation of mapped values | `mapper: Functional<E, number>` | `Collector<E, StandardDeviationAccumulator, number>` |
311
+ | `useBigIntStandardDeviation<E>(): Collector<E, BigIntStandardDeviationAccumulator, bigint>` | Creates a collector that calculates bigint standard deviation | None | `Collector<bigint, BigIntStandardDeviationAccumulator, bigint>` or `Collector<E, BigIntStandardDeviationAccumulator, bigint>` |
312
+ | `useBigIntStandardDeviation<E>(mapper: Functional<E, bigint>): Collector<E, BigIntStandardDeviationAccumulator, bigint>` | Creates a collector that calculates bigint standard deviation of mapped values | `mapper: Functional<E, bigint>` | `Collector<E, BigIntStandardDeviationAccumulator, bigint>` |
313
+ | `useNumericMedian<E>(): Collector<E, number[], number>` | Creates a collector that calculates numeric median | None | `Collector<number, number[], number>` or `Collector<E, number[], number>` |
314
+ | `useNumericMedian<E>(mapper: Functional<E, number>): Collector<E, number[], number>` | Creates a collector that calculates numeric median of mapped values | `mapper: Functional<E, number>` | `Collector<E, number[], number>` |
315
+ | `useBigIntMedian<E>(): Collector<E, bigint[], bigint>` | Creates a collector that calculates bigint median | None | `Collector<bigint, bigint[], bigint>` or `Collector<E, bigint[], bigint>` |
316
+ | `useBigIntMedian<E>(mapper: Functional<E, bigint>): Collector<E, bigint[], bigint>` | Creates a collector that calculates bigint median of mapped values | `mapper: Functional<E, bigint>` | `Collector<E, bigint[], bigint>` |
317
+ | `useToGeneratorFunction<E>(): Collector<E, Array<E>, globalThis.Generator<E, void, undefined>>` | Creates a collector that converts elements to a generator function | None | `Collector<E, Array<E>, globalThis.Generator<E, void, undefined>>` |
318
+ | `useToAsyncGeneratorFunction<E>(): Collector<E, Array<E>, globalThis.AsyncGenerator<E, void, undefined>>` | Creates a collector that converts elements to an async generator function | None | `Collector<E, Array<E>, globalThis.AsyncGenerator<E, void, undefined>>` |
209
319
 
210
320
  ```typescript
211
321
  // Collector conversion examples
@@ -244,28 +354,39 @@ average.collect([1,2,3,4,5]); // Averages from an iterable object
244
354
  ## Collector Class Methods
245
355
 
246
356
  | Method | Description | Time Complexity | Space Complexity |
247
- |------------|------------|------------|------------|
248
- | `collect(stream)` | Collect elements from a stream | O(n) | O(1) |
249
- | `collect(iterable)` | Collect elements from an iterable object | O(n) | O(1) |
250
- | `collect(generator)` | Collect elements from a generator | O(n) | O(1) |
251
- | `collect(semantic)` | Collect elements from a semantic stream | O(n) | O(1) |
252
- | `collect(collectable)` | Collect elements from a collectable stream | O(n) | O(1) |
253
- | `collect(start, endExelusive)` | Collect elements from a range | O(n) | O(1) |
357
+ |--------|-------------|-----------------|------------------|
358
+ | `collect(generator: Generator<E>): R` | Collect elements from a generator function | O(n) | O(1) |
359
+ | `collect(iterable: Iterable<E>): R` | Collect elements from an iterable object | O(n) | O(1) |
360
+ | `collect(semantic: Semantic<E>): R` | Collect elements from a semantic stream | O(n) | O(1) |
361
+ | `collect(collectable: Collectable<E>): R` | Collect elements from a collectable stream | O(n) | O(1) |
362
+ | `collect(start: number, end: number): R` | Collect elements from a numeric range | O(n) | O(1) |
363
+ | `collect(start: bigint, end: bigint): R` | Collect elements from a bigint range | O(n) | O(1) |
254
364
 
255
365
  ### Semantic Factory Methods
256
366
 
257
- | Method | Description | Time Complexity | Space Complexity |
258
- |------|------|------------|------------|
259
- | `animationFrame(period: number, delay: number = 0)` | Create a timed animation frame stream | O(1)* | O(1) |
260
- | `attribute(target)` | Create a stream from an object deep attributes | O(n) | O(1) |
261
- | `blob(blob, chunkSize)` | Create a stream from a Blob | O(n) | O(chunkSize) |
262
- | `empty<E>()` | Create an empty stream | O(1) | O(1) |
263
- | `fill<E>(element, count)` | Create a filled stream | O(n) | O(1) |
264
- | `from<E>(iterable)` | Create a stream from an iterable object | O(1) | O(1) |
265
- | `interval(period, delay?)` | Create a timed interval stream | O(1)* | O(1) |
266
- | `iterate<E>(generator)` | Create a stream from a generator | O(1) | O(1) |
267
- | `range(start, end, step)` | Create a numerical range stream | O(n) | O(1) |
268
- | `websocket(websocket)` | Create a stream from a WebSocket | O(1) | O(1) |
367
+ | Function | Description | Parameters | Return Type |
368
+ |----------|-------------|------------|-------------|
369
+ | `animationFrame(period: number): Semantic<number>` | Creates a semantic that emits animation frame timestamps | `period: number` | `Semantic<number>` |
370
+ | `animationFrame(period: number, delay: number): Semantic<number>` | Creates a semantic that emits animation frame timestamps with delay | `period: number`, `delay: number` | `Semantic<number>` |
371
+ | `attribute<T extends object>(target: T): Semantic<Attribute<T>>` | Creates a semantic that emits object attributes | `target: T` | `Semantic<Attribute<T>>` |
372
+ | `blob(blob: Blob): Semantic<Uint8Array>` | Creates a semantic that emits blob data in chunks | `blob: Blob` | `Semantic<Uint8Array>` |
373
+ | `blob(blob: Blob, chunk: bigint): Semantic<Uint8Array>` | Creates a semantic that emits blob data with custom chunk size | `blob: Blob`, `chunk: bigint` | `Semantic<Uint8Array>` |
374
+ | `empty<E>(): Semantic<E>` | Creates an empty semantic that emits no elements | None | `Semantic<E>` |
375
+ | `fill<E>(element: E, count: bigint): Semantic<E>` | Creates a semantic that emits a repeated element | `element: E`, `count: bigint` | `Semantic<E>` |
376
+ | `fill<E>(supplier: Supplier<E>, count: bigint): Semantic<E>` | Creates a semantic that emits values from a supplier | `supplier: Supplier<E>`, `count: bigint` | `Semantic<E>` |
377
+ | `from<E>(iterable: Iterable<E>): Semantic<E>` | Creates a semantic from an iterable | `iterable: Iterable<E>` | `Semantic<E>` |
378
+ | `from<E>(iterable: AsyncIterable<E>): Semantic<E>` | Creates a semantic from an async iterable | `iterable: AsyncIterable<E>` | `Semantic<E>` |
379
+ | `generate<E>(supplier: Supplier<E>, count: bigint): Semantic<E>` | Creates a semantic that generates a fixed number of values | `supplier: Supplier<E>`, `count: bigint` | `Semantic<E>` |
380
+ | `generate<E>(element: E, count: bigint): Semantic<E>` | Creates a semantic that repeats an element | `element: E`, `count: bigint` | `Semantic<E>` |
381
+ | `generate<E>(supplier: Supplier<E>, interrupt: Predicate<E>): Semantic<E>` | Creates a semantic that generates until condition is met | `supplier: Supplier<E>`, `interrupt: Predicate<E>` | `Semantic<E>` |
382
+ | `generate<E>(supplier: Supplier<E>, interrupt: BiPredicate<E, bigint>): Semantic<E>` | Creates a semantic that generates until condition is met | `supplier: Supplier<E>`, `interrupt: BiPredicate<E, bigint>` | `Semantic<E>` |
383
+ | `interval(period: number): Semantic<number>` | Creates a semantic that emits at regular intervals | `period: number` | `Semantic<number>` |
384
+ | `interval(period: number, delay: number): Semantic<number>` | Creates a semantic that emits at intervals with initial delay | `period: number`, `delay: number` | `Semantic<number>` |
385
+ | `iterate<E>(generator: Generator<E>): Semantic<E>` | Creates a semantic from a generator function | `generator: Generator<E>` | `Semantic<E>` |
386
+ | `promise<T>(promise: Promise<T>): Semantic<T>` | Creates a semantic that emits a promise's result | `promise: Promise<T>` | `Semantic<T>` |
387
+ | `range(start: number, end: number): Semantic<number>` | Creates a semantic that emits a range of numbers | `start: number`, `end: number` | `Semantic<number>` |
388
+ | `range(start: number, end: number, step: number): Semantic<number>` | Creates a semantic that emits a range with custom step | `start: number`, `end: number`, `step: number` | `Semantic<number>` |
389
+ | `websocket(websocket: WebSocket): Semantic<MessageEvent \| CloseEvent \| Event>` | Creates a semantic that emits WebSocket events | `websocket: WebSocket` | `Semantic<MessageEvent \| CloseEvent \| Event>` |
269
390
 
270
391
  ```typescript
271
392
  // Semantic factory method usage examples
@@ -273,7 +394,7 @@ average.collect([1,2,3,4,5]); // Averages from an iterable object
273
394
  // Create a stream from a timed animation frame
274
395
  animationFrame(1000)
275
396
  .toUnordered()
276
- .forEach(frame => console.log(frame));
397
+ .forEach((frame): void => console.log(frame));
277
398
 
278
399
  // Create a stream from a Blob (chunked reading)
279
400
  blob(someBlob, 1024n)
@@ -298,7 +419,7 @@ let numberStream = from([1, 2, 3, 4, 5]);
298
419
  let stringStream = from(new Set(["Alex", "Bob"]));
299
420
 
300
421
  // Create a stream from a resolved Promise
301
- let promisedStream: Semantic<Array<number>> = Promise.resolve([1, 2, 3, 4, 5]);
422
+ let promisedStream: Semantic<Array<number>> = promise(Promise.resolve([1, 2, 3, 4, 5]));
302
423
 
303
424
  // Create a range stream
304
425
  let rangeStream = range(1, 10, 2); // 1, 3, 5, 7, 9
@@ -314,29 +435,42 @@ websocket(ws)
314
435
  ## Semantic Class Methods
315
436
 
316
437
  | Method | Description | Time Complexity | Space Complexity |
317
- |------|------|------------|------------|
318
- | `concat(semantic)` | Concatenate two streams | O(n) | O(1) |
319
- | `concat(iterable)` | Concatenate from an iterable object | O(n) | O(1) |
320
- | `distinct()` | Remove duplicates | O(n) | O(n) |
321
- | `distinct(comparator)` | Remove duplicates using a comparator | O(n²) | O(n) |
322
- | `dropWhile(predicate)` | Discard elements satisfying condition | O(n) | O(1) |
323
- | `filter(predicate)` | Filter elements | O(n) | O(1) |
324
- | `flat(mapper)` | Flattening map | O(n × m) | O(1) |
325
- | `flatMap(mapper)` | Flattening map to new type | O(n × m) | O(1) |
326
- | `limit(n)` | Limit number of elements | O(n) | O(1) |
327
- | `map(mapper)` | Map transformation | O(n) | O(1) |
328
- | `peek(consumer)` | Peek at elements | O(n) | O(1) |
329
- | `redirect(redirector)` | Redirect index | O(n) | O(1) |
330
- | `reverse()` | Reverse stream | O(n) | O(1) |
331
- | `shuffle()` | Randomly shuffle | O(n) | O(1) |
332
- | `shuffle(mapper)` | Shuffle using a mapper | O(n) | O(1) |
333
- | `skip(n)` | Skip first n elements | O(n) | O(1) |
334
- | `sorted()` | Sort | O(n log n) | O(n) |
335
- | `sorted(comparator)` | Sort using a comparator | O(n log n) | O(n) |
336
- | `sub(start, end)` | Get substream | O(n) | O(1) |
337
- | `takeWhile(predicate)` | Get elements satisfying condition | O(n) | O(1) |
338
- | `translate(offset)` | Translate index | O(n) | O(1) |
339
- | `translate(translator)` | Translate index using a translator | O(n) | O(1) |
438
+ |--------|-------------|-----------------|------------------|
439
+ | `concat(other: Semantic<E>): Semantic<E>` | Concatenates two semantics | O(m+n) | O(1) |
440
+ | `concat(other: Iterable<E>): Semantic<E>` | Concatenates semantic with an iterable | O(m+n) | O(1) |
441
+ | `distinct(): Semantic<E>` | Returns distinct elements | O(n) | O(n) |
442
+ | `distinct<K>(keyExtractor: Functional<E, K>): Semantic<E>` | Returns distinct elements by key | O(n) | O(n) |
443
+ | `distinct<K>(keyExtractor: BiFunctional<E, bigint, K>): Semantic<E>` | Returns distinct elements by key with index | O(n) | O(n) |
444
+ | `dropWhile(predicate: Predicate<E>): Semantic<E>` | Drops elements while predicate is true | O(n) | O(1) |
445
+ | `dropWhile(predicate: BiPredicate<E, bigint>): Semantic<E>` | Drops elements while predicate is true with index | O(n) | O(1) |
446
+ | `filter(predicate: Predicate<E>): Semantic<E>` | Filters elements by predicate | O(n) | O(1) |
447
+ | `filter(predicate: BiPredicate<E, bigint>): Semantic<E>` | Filters elements by predicate with index | O(n) | O(1) |
448
+ | `flat(mapper: Functional<E, Iterable<E>>): Semantic<E>` | Flattens iterable results | O(n) | O(1) |
449
+ | `flat(mapper: BiFunctional<E, bigint, Iterable<E>>): Semantic<E>` | Flattens iterable results with index | O(n) | O(1) |
450
+ | `flat(mapper: Functional<E, Semantic<E>>): Semantic<E>` | Flattens semantic results | O(n) | O(1) |
451
+ | `flat(mapper: BiFunctional<E, bigint, Semantic<E>>): Semantic<E>` | Flattens semantic results with index | O(n) | O(1) |
452
+ | `flatMap<R>(mapper: Functional<E, Iterable<R>>): Semantic<R>` | Maps and flattens to different type | O(n) | O(1) |
453
+ | `flatMap<R>(mapper: BiFunctional<E, bigint, Iterable<R>>): Semantic<R>` | Maps and flattens with index | O(n) | O(1) |
454
+ | `flatMap<R>(mapper: Functional<E, Semantic<R>>): Semantic<R>` | Maps and flattens semantics | O(n) | O(1) |
455
+ | `flatMap<R>(mapper: BiFunctional<E, bigint, Semantic<R>>): Semantic<R>` | Maps and flattens semantics with index | O(n) | O(1) |
456
+ | `limit(n: number): Semantic<E>` | Limits number of elements | O(n) | O(1) |
457
+ | `limit(n: bigint): Semantic<E>` | Limits number of elements (bigint) | O(n) | O(1) |
458
+ | `map<R>(mapper: Functional<E, R>): Semantic<R>` | Maps elements to different type | O(n) | O(1) |
459
+ | `map<R>(mapper: BiFunctional<E, bigint, R>): Semantic<R>` | Maps elements with index | O(n) | O(1) |
460
+ | `peek(consumer: Consumer<E>): Semantic<E>` | Performs action on elements | O(n) | O(1) |
461
+ | `peek(consumer: BiConsumer<E, bigint>): Semantic<E>` | Performs action on elements with index | O(n) | O(1) |
462
+ | `redirect(redirector: BiFunctional<E, bigint, bigint>): Semantic<E>` | Redirects element indices | O(n) | O(1) |
463
+ | `reverse(): Semantic<E>` | Reverses element indices | O(n) | O(1) |
464
+ | `shuffle(): Semantic<E>` | Shuffles element indices randomly | O(n) | O(1) |
465
+ | `shuffle(mapper: BiFunctional<E, bigint, bigint>): Semantic<E>` | Shuffles element indices with mapper | O(n) | O(1) |
466
+ | `skip(n: number): Semantic<E>` | Skips first n elements | O(n) | O(1) |
467
+ | `skip(n: bigint): Semantic<E>` | Skips first n elements (bigint) | O(n) | O(1) |
468
+ | `sub(start: bigint, end: bigint): Semantic<E>` | Returns sub-semantic range | O(n) | O(1) |
469
+ | `takeWhile(predicate: Predicate<E>): Semantic<E>` | Takes elements while predicate is true | O(n) | O(1) |
470
+ | `takeWhile(predicate: BiPredicate<E, bigint>): Semantic<E>` | Takes elements while predicate is true with index | O(n) | O(1) |
471
+ | `translate(offset: number): Semantic<E>` | Translates element indices by offset | O(n) | O(1) |
472
+ | `translate(offset: bigint): Semantic<E>` | Translates element indices by offset (bigint) | O(n) | O(1) |
473
+ | `translate(translator: BiFunctional<E, bigint, bigint>): Semantic<E>` | Translates element indices with translator | O(n) | O(1) |
340
474
 
341
475
  ```typescript
342
476
  // Semantic operation examples
@@ -363,14 +497,15 @@ let complexResult = range(1, 100, 1)
363
497
 
364
498
  | Method | Description | Time Complexity | Space Complexity |
365
499
  |------------|------------|------------|------------|
366
- | `sorted()` | Convert to ordered collector | O(n log n) | O(n) |
367
- | `toUnordered()` | Convert to unordered collector | O(1) | O(1) |
368
- | `toOrdered()` | Convert to ordered collector | O(1) | O(1) |
369
- | `toNumericStatistics()` | Convert to numeric statistics | O(n) | O(1) |
370
- | `toBigintStatistics()` | Convert to bigint statistics | O(n) | O(1) |
371
- | `toWindow()` | Convert to window collector | O(1) | O(1) |
372
- | `toCollectable()` | Convert to `UnorderdCollectable` | O(n) | O(1) |
373
- | `toCollectable(mapper)` | Convert to customized collectable | O(n) | O(1) |
500
+ | `sorted(): OrderedCollectable<E>` | Returns sorted collectable | O(n log n) | O(n) |
501
+ | `sorted(comparator: Comparator<E>): OrderedCollectable<E>` | Returns sorted collectable with comparator | O(n log n) | O(n) |
502
+ | `toCollectable(): Collectable<E>` | Converts to collectable | O(1) | O(1) |
503
+ | `toCollectable<C extends Collectable<E>>(mapper: Functional<Generator<E>, C>): C` | Converts to collectable with mapper | O(1) | O(1) |
504
+ | `toBigintStatistics(): BigIntStatistics<E>` | Converts to bigint statistics | O(1) | O(1) |
505
+ | `toNumericStatistics(): NumericStatistics<E>` | Converts to numeric statistics | O(1) | O(1) |
506
+ | `toOrdered(): OrderedCollectable<E>` | Converts to ordered collectable | O(1) | O(1) |
507
+ | `toUnordered(): UnorderedCollectable<E>` | Converts to unordered collectable | O(1) | O(1) |
508
+ | `toWindow(): WindowCollectable<E>` | Converts to window collectable | O(1) | O(1) |
374
509
 
375
510
  ```typescript
376
511
  // Convert to an ascending sorted array
@@ -423,42 +558,63 @@ let customizedCollector = from([1, 2, 3, 4, 5]).toCollectable((generator: Genera
423
558
  ## Collectable Collection Methods
424
559
 
425
560
  | Method | Description | Time Complexity | Space Complexity |
426
- |------|------|------------|------------|
427
- | `anyMatch(predicate)` | Whether any element matches the predicate | O(n) | O(1) |
428
- | `allMatch(predicate)` | Whether all elements match the predicate | O(n) | O(1) |
429
- | `collect(collector)` | Collect elements using the given collector | O(n) | O(1) |
430
- | `collect(identity, accumulator, finisher)` | Collect elements with identity, accumulator, and finisher | O(n) | O(1) |
431
- | `collect(identity, interruptor, accumulator, finisher)` | Collect elements with identity, interruptor, accumulator, and finisher | O(n) | O(1) |
432
- | `count()` | Count the number of elements | O(n) | O(1) |
433
- | `error()` | Log elements to console with default error format | O(n) | O(1) |
434
- | `error(accumulator)` | Log elements via custom accumulator error format | O(n) | O(1) |
435
- | `error(prefix, accumulator, suffix)` | Log elements with prefix, custom accumulator, and suffix | O(n) | O(1) |
436
- | `isEmpty()` | Check whether the collectable is empty | O(n) | O(1) |
437
- | `findAny()` | Find any element in the collectable | O(n) | O(1) |
438
- | `findFirst()` | Find the first element in the collectable | O(n) | O(1) |
439
- | `findLast()` | Find the last element in the collectable | O(n) | O(1) |
440
- | `forEach(action)` | Iterate over all elements with a consumer or bi-consumer | O(n) | O(1) |
441
- | `group(classifier)` | Group elements by a classifier function | O(n) | O(n) |
442
- | `groupBy(keyExtractor, valueExtractor)` | Group elements by key and value extractors | O(n) | O(n) |
443
- | `join()` | Join elements into a string with default format | O(n) | O(n) |
444
- | `join(delimiter)` | Join elements into a string with a delimiter | O(n) | O(n) |
445
- | `join(prefix, delimiter, suffix)` | Join elements with prefix, delimiter, and suffix | O(n) | O(n) |
446
- | `join(prefix, accumulator, suffix)` | Join elements via custom accumulator with prefix and suffix | O(n) | O(n) |
447
- | `log()` | Log elements to console with default format | O(n) | O(1) |
448
- | `log(accumulator)` | Log elements via custom accumulator | O(n) | O(1) |
449
- | `log(prefix, accumulator, suffix)` | Log elements with prefix, custom accumulator, and suffix | O(n) | O(1) |
450
- | `nonMatch(predicate)` | Whether no elements match the predicate | O(n) | O(1) |
451
- | `partition(count)` | Partition elements into chunks of specified size | O(n) | O(n) |
452
- | `partitionBy(classifier)` | Partition elements by a classifier function | O(n) | O(n) |
453
- | `reduce(accumulator)` | Reduce elements using an accumulator (no initial value) | O(n) | O(1) |
454
- | `reduce(identity, accumulator)` | Reduce elements with an initial value and accumulator | O(n) | O(1) |
455
- | `reduce(identity, accumulator, finisher)` | Reduce elements with initial value, accumulator, and finisher | O(n) | O(1) |
456
- | `semantic()` | Convert the collectable to a semantic object | O(1) | O(1) |
457
- | `toArray()` | Convert elements to an array | O(n) | O(n) |
458
- | `toMap(keyExtractor, valueExtractor)` | Convert elements to a Map via key and value extractors | O(n) | O(n) |
459
- | `toSet()` | Convert elements to a Set | O(n) | O(n) |
460
- | `write(stream)` | Write elements to a stream (default format) | O(n) | O(1) |
461
- | `write(stream, accumulator)` | Write elements to a stream via custom accumulator | O(n) | O(1) |
561
+ |--------|-------------|-----------------|------------------|
562
+ | `anyMatch(predicate: Predicate<E>): boolean` | Returns true if any element matches the predicate | O(n) | O(1) |
563
+ | `allMatch(predicate: Predicate<E>): boolean` | Returns true if all elements match the predicate | O(n) | O(1) |
564
+ | `collect<A, R>(collector: Collector<E, A, R>): R` | Collects elements using a collector | O(n) | O(1) |
565
+ | `collect<A, R>(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R` | Collects elements with accumulator and finisher | O(n) | O(1) |
566
+ | `collect<A, R>(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R` | Collects elements with index-aware accumulator | O(n) | O(1) |
567
+ | `collect<A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R` | Collects with interruptor and accumulator | O(n) | O(1) |
568
+ | `collect<A, R>(identity: Supplier<A>, interruptor: BiPredicate<E, bigint>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R` | Collects with index-aware interruptor | O(n) | O(1) |
569
+ | `collect<A, R>(identity: Supplier<A>, interruptor: TriPredicate<E, bigint, A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R` | Collects with state-aware interruptor | O(n) | O(1) |
570
+ | `collect<A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R` | Collects with index-aware accumulator | O(n) | O(1) |
571
+ | `collect<A, R>(identity: Supplier<A>, interruptor: BiPredicate<E, bigint>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R` | Collects with both index-aware | O(n) | O(1) |
572
+ | `collect<A, R>(identity: Supplier<A>, interruptor: TriPredicate<E, bigint, A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R` | Collects with state and index awareness | O(n) | O(1) |
573
+ | `count(): bigint` | Counts number of elements | O(n) | O(1) |
574
+ | `error(): void` | Logs elements to console.error | O(n) | O(1) |
575
+ | `error(accumulator: BiFunctional<string, E, string>): void` | Logs with custom accumulator | O(n) | O(1) |
576
+ | `error(accumulator: TriFunctional<string, E, bigint, string>): void` | Logs with index-aware accumulator | O(n) | O(1) |
577
+ | `error(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): void` | Logs with prefix and suffix | O(n) | O(1) |
578
+ | `error(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): void` | Logs with index-aware accumulator | O(n) | O(1) |
579
+ | `isEmpty(): boolean` | Returns true if no elements | O(1) | O(1) |
580
+ | `findAny(): Optional<E>` | Returns any element randomly | O(1) | O(1) |
581
+ | `findFirst(): Optional<E>` | Returns the first element | O(1) | O(1) |
582
+ | `findLast(): Optional<E>` | Returns the last element | O(n) | O(1) |
583
+ | `findMaximum(): Optional<E>` | Returns maximum element | O(n) | O(1) |
584
+ | `findMaximum(comparator: Comparator<E>): Optional<E>` | Returns maximum with comparator | O(n) | O(1) |
585
+ | `findMinimum(): Optional<E>` | Returns minimum element | O(n) | O(1) |
586
+ | `findMinimum(comparator: Comparator<E>): Optional<E>` | Returns minimum with comparator | O(n) | O(1) |
587
+ | `forEach(action: Consumer<E>): void` | Performs action on each element | O(n) | O(1) |
588
+ | `forEach(action: BiConsumer<E, bigint>): void` | Performs action with index | O(n) | O(1) |
589
+ | `group<K>(classifier: Functional<E, K>): Map<K, Array<E>>` | Groups elements by classifier | O(n) | O(n) |
590
+ | `groupBy<K, V>(keyExtractor: Functional<E, K>, valueExtractor: Functional<E, V>): Map<K, Array<V>>` | Groups with key-value mapping | O(n) | O(n) |
591
+ | `join(): string` | Joins elements into string | O(n) | O(1) |
592
+ | `join(delimiter: string): string` | Joins with delimiter | O(n) | O(1) |
593
+ | `join(prefix: string, delimiter: string, suffix: string): string` | Joins with prefix and suffix | O(n) | O(1) |
594
+ | `join(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): string` | Joins with custom accumulator | O(n) | O(1) |
595
+ | `join(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): string` | Joins with index-aware accumulator | O(n) | O(1) |
596
+ | `log(): void` | Logs elements to console.log | O(n) | O(1) |
597
+ | `log(accumulator: BiFunctional<string, E, string>): void` | Logs with custom accumulator | O(n) | O(1) |
598
+ | `log(accumulator: TriFunctional<string, E, bigint, string>): void` | Logs with index-aware accumulator | O(n) | O(1) |
599
+ | `log(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): void` | Logs with prefix and suffix | O(n) | O(1) |
600
+ | `log(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): void` | Logs with index-aware accumulator | O(n) | O(1) |
601
+ | `nonMatch(predicate: Predicate<E>): boolean` | Returns true if no element matches | O(n) | O(1) |
602
+ | `partition(count: bigint): Array<Array<E>>` | Partitions into groups of size | O(n) | O(n) |
603
+ | `partitionBy(classifier: Functional<E, bigint>): Array<Array<E>>` | Partitions by classifier | O(n) | O(n) |
604
+ | `reduce(accumulator: BiFunctional<E, E, E>): Optional<E>` | Reduces elements | O(n) | O(1) |
605
+ | `reduce(accumulator: TriFunctional<E, E, bigint, E>): Optional<E>` | Reduces with index | O(n) | O(1) |
606
+ | `reduce(identity: E, accumulator: BiFunctional<E, E, E>): E` | Reduces with identity | O(n) | O(1) |
607
+ | `reduce(identity: E, accumulator: TriFunctional<E, E, bigint, E>): E` | Reduces with identity and index | O(n) | O(1) |
608
+ | `reduce<R>(identity: R, accumulator: BiFunctional<R, E, R>, finisher: Functional<R, R>): R` | Reduces with finisher | O(n) | O(1) |
609
+ | `reduce<R>(identity: R, accumulator: TriFunctional<R, E, bigint, R>, finisher: Functional<R, R>): R` | Reduces with index and finisher | O(n) | O(1) |
610
+ | `semantic(): Semantic<E>` | Converts to semantic | O(1) | O(1) |
611
+ | `source(): Generator<E>` | Returns generator source | O(1) | O(1) |
612
+ | `toArray(): Array<E>` | Converts to array | O(n) | O(n) |
613
+ | `toMap<K, V>(keyExtractor: Functional<E, K>, valueExtractor: Functional<E, V>): Map<K, V>` | Converts to map | O(n) | O(n) |
614
+ | `toSet(): Set<E>` | Converts to set | O(n) | O(n) |
615
+ | `write<S = string>(stream: WritableStream<S>): Promise<WritableStream<S>>` | Writes to stream | O(n) | O(1) |
616
+ | `write<S = string>(stream: WritableStream<S>, accumulator: BiFunctional<WritableStream<S>, E, WritableStream<S>>): Promise<WritableStream<S>>` | Writes with accumulator | O(n) | O(1) |
617
+ | `write<S = string>(stream: WritableStream<S>, accumulator: TriFunctional<WritableStream<S>, E, bigint, WritableStream<S>>): Promise<WritableStream<S>>` | Writes with index-aware accumulator | O(n) | O(1) |
462
618
 
463
619
  ```typescript
464
620
  // Collectable operation examples
@@ -488,24 +644,98 @@ let sum = data.reduce(0, (accumulator: number, n: number): number => accumulator
488
644
  data.join(", "); // "[2, 4, 6, 8, 10]"
489
645
  ```
490
646
 
647
+ ## Unordered Collectable Methods
648
+
649
+ | Method | Description | Time Complexity | Space Complexity |
650
+ |--------|-------------|-----------------|------------------|
651
+ | `constructor(generator: Generator<E>)` | Creates unordered collectable | O(1) | O(1) |
652
+ | `source(): Generator<E>` | Returns generator source | O(1) | O(1) |
653
+ | `[Symbol.iterator](): Generator<E, void, undefined>` | Returns iterator | O(n) | O(1) |
654
+ | `[Symbol.asyncIterator](): AsyncGenerator<E, void, undefined>` | Returns async iterator | O(n) | O(1) |
655
+
656
+ ## Ordered Collectable Methods
657
+
658
+ | Method | Description | Time Complexity | Space Complexity |
659
+ |--------|-------------|-----------------|------------------|
660
+ | `constructor(generator: Generator<E>)` | Creates ordered collectable | O(n log n) | O(n) |
661
+ | `constructor(generator: Generator<E>, comparator: Comparator<E>)` | Creates ordered collectable with comparator | O(n log n) | O(n) |
662
+ | `[Symbol.iterator](): Generator<E, void, undefined>` | Returns iterator | O(n) | O(1) |
663
+ | `[Symbol.asyncIterator](): AsyncGenerator<E, void, undefined>` | Returns async iterator | O(n) | O(1) |
664
+ | `source(): Generator<E>` | Returns indexed generator source | O(1) | O(1) |
665
+ | `isEmpty(): boolean` | Returns true if buffer is empty | O(1) | O(1) |
666
+
491
667
  ## Statistical Analysis Methods
492
668
 
669
+ ### Statisttics Methods
670
+
671
+ | Method | Description | Time Complexity | Space Complexity |
672
+ |--------|-------------|-----------------|------------------|
673
+ | `constructor(generator: Generator<E>)` | Creates a statistics instance | O(n log n) | O(n) |
674
+ | `constructor(generator: Generator<E>, comparator: Comparator<E>)` | Creates a statistics instance with comparator | O(n log n) | O(n) |
675
+ | `[Symbol.iterator](): Generator<E, void, undefined>` | Returns iterator | O(n) | O(1) |
676
+ | `[Symbol.asyncIterator](): AsyncGenerator<E, void, undefined>` | Returns async iterator | O(n) | O(1) |
677
+ | `count(): bigint` | Returns the number of elements | O(1) | O(1) |
678
+ | `average(): D` | Returns the average (arithmetic mean) | O(n) | O(1) |
679
+ | `average(mapper: Functional<E, D>): D` | Returns the average of mapped values | O(n) | O(1) |
680
+ | `range(): D` | Returns the range (max-min) | O(1) | O(1) |
681
+ | `range(mapper: Functional<E, D>): D` | Returns the range of mapped values | O(1) | O(1) |
682
+ | `variance(): D` | Returns the variance | O(n) | O(1) |
683
+ | `variance(mapper: Functional<E, D>): D` | Returns the variance of mapped values | O(n) | O(1) |
684
+ | `standardDeviation(): D` | Returns the standard deviation | O(n) | O(1) |
685
+ | `standardDeviation(mapper: Functional<E, D>): D` | Returns the standard deviation of mapped values | O(n) | O(1) |
686
+ | `mean(): D` | Returns the mean (same as average) | O(n) | O(1) |
687
+ | `mean(mapper: Functional<E, D>): D` | Returns the mean of mapped values | O(n) | O(1) |
688
+ | `median(): D` | Returns the median | O(n) | O(n) |
689
+ | `median(mapper: Functional<E, D>): D` | Returns the median of mapped values | O(n) | O(n) |
690
+ | `mode(): D` | Returns the mode | O(n) | O(n) |
691
+ | `mode(mapper: Functional<E, D>): D` | Returns the mode of mapped values | O(n) | O(n) |
692
+ | `frequency(): Map<E, bigint>` | Returns the frequency distribution | O(n) | O(n) |
693
+ | `summate(): D` | Returns the sum of elements | O(n) | O(1) |
694
+ | `summate(mapper: Functional<E, D>): D` | Returns the sum of mapped values | O(n) | O(1) |
695
+ | `quantile(quantile: number): D` | Returns the specified quantile | O(1) | O(1) |
696
+ | `quantile(quantile: number, mapper: Functional<E, D>): D` | Returns the quantile of mapped values | O(1) | O(1) |
697
+ | `interquartileRange(): D` | Returns the interquartile range (IQR) | O(1) | O(1) |
698
+ | `interquartileRange(mapper: Functional<E, D>): D` | Returns the IQR of mapped values | O(1) | O(1) |
699
+ | `skewness(): D` | Returns the skewness measure | O(n) | O(1) |
700
+ | `skewness(mapper: Functional<E, D>): D` | Returns the skewness of mapped values | O(n) | O(1) |
701
+ | `kurtosis(): D` | Returns the kurtosis measure | O(n) | O(1) |
702
+ | `kurtosis(mapper: Functional<E, D>): D` | Returns the kurtosis of mapped values | O(n) | O(1) |
703
+
704
+
493
705
  ### NumericStatistics Methods
494
706
 
495
707
  | Method | Description | Time Complexity | Space Complexity |
496
- |------|------|------------|------------|
497
- | `range()` | Range | O(n) | O(1) |
498
- | `variance()` | Variance | O(n) | O(1) |
499
- | `standardDeviation()` | Standard deviation | O(n) | O(1) |
500
- | `mean()` | Mean | O(n) | O(1) |
501
- | `median()` | Median | O(n log n) | O(n) |
502
- | `mode()` | Mode | O(n) | O(n) |
503
- | `frequency()` | Frequency distribution | O(n) | O(n) |
504
- | `summate()` | Summation | O(n) | O(1) |
505
- | `quantile(quantile)` | Quantile | O(n log n) | O(n) |
506
- | `interquartileRange()` | Interquartile range | O(n log n) | O(n) |
507
- | `skewness()` | Skewness | O(n) | O(1) |
508
- | `kurtosis()` | Kurtosis | O(n) | O(1) |
708
+ |--------|-------------|-----------------|------------------|
709
+ | `constructor(generator: Generator<E>)` | Creates a numeric statistics instance | O(n log n) | O(n) |
710
+ | `constructor(generator: Generator<E>, comparator: Comparator<E>)` | Creates a numeric statistics instance with comparator | O(n log n) | O(n) |
711
+ | `[Symbol.iterator](): Generator<E, void, undefined>` | Returns iterator | O(n) | O(1) |
712
+ | `[Symbol.asyncIterator](): AsyncGenerator<E, void, undefined>` | Returns async iterator | O(n) | O(1) |
713
+ | `count(): bigint` | Returns the number of elements | O(1) | O(1) |
714
+ | `average(): number` | Returns the numeric average | O(n) | O(1) |
715
+ | `average(mapper: Functional<E, number>): number` | Returns the average of mapped numeric values | O(n) | O(1) |
716
+ | `range(): number` | Returns the numeric range | O(1) | O(1) |
717
+ | `range(mapper: Functional<E, number>): number` | Returns the range of mapped numeric values | O(1) | O(1) |
718
+ | `variance(): number` | Returns the numeric variance | O(n) | O(1) |
719
+ | `variance(mapper: Functional<E, number>): number` | Returns the variance of mapped numeric values | O(n) | O(1) |
720
+ | `standardDeviation(): number` | Returns the numeric standard deviation | O(n) | O(1) |
721
+ | `standardDeviation(mapper: Functional<E, number>): number` | Returns the standard deviation of mapped numeric values | O(n) | O(1) |
722
+ | `mean(): number` | Returns the numeric mean (same as average) | O(n) | O(1) |
723
+ | `mean(mapper: Functional<E, number>): number` | Returns the mean of mapped numeric values | O(n) | O(1) |
724
+ | `median(): number` | Returns the numeric median | O(n) | O(n) |
725
+ | `median(mapper: Functional<E, number>): number` | Returns the median of mapped numeric values | O(n) | O(n) |
726
+ | `mode(): number` | Returns the numeric mode | O(n) | O(n) |
727
+ | `mode(mapper: Functional<E, number>): number` | Returns the mode of mapped numeric values | O(n) | O(n) |
728
+ | `frequency(): Map<E, bigint>` | Returns the frequency distribution | O(n) | O(n) |
729
+ | `summate(): number` | Returns the numeric sum | O(n) | O(1) |
730
+ | `summate(mapper: Functional<E, number>): number` | Returns the sum of mapped numeric values | O(n) | O(1) |
731
+ | `quantile(quantile: number): number` | Returns the specified numeric quantile | O(1) | O(1) |
732
+ | `quantile(quantile: number, mapper: Functional<E, number>): number` | Returns the quantile of mapped numeric values | O(1) | O(1) |
733
+ | `interquartileRange(): number` | Returns the numeric interquartile range | O(1) | O(1) |
734
+ | `interquartileRange(mapper: Functional<E, number>): number` | Returns the IQR of mapped numeric values | O(1) | O(1) |
735
+ | `skewness(): number` | Returns the numeric skewness | O(n) | O(1) |
736
+ | `skewness(mapper: Functional<E, number>): number` | Returns the skewness of mapped numeric values | O(n) | O(1) |
737
+ | `kurtosis(): number` | Returns the numeric kurtosis | O(n) | O(1) |
738
+ | `kurtosis(mapper: Functional<E, number>): number` | Returns the kurtosis of mapped numeric values | O(n) | O(1) |
509
739
 
510
740
  ```typescript
511
741
  // Statistical analysis examples
@@ -527,6 +757,53 @@ let objects = from([
527
757
  console.log("Mapped mean:", objects.mean(obj => obj.value)); // 20
528
758
  ```
529
759
 
760
+ ### BigintStatistics Methods
761
+
762
+ | Method | Description | Time Complexity | Space Complexity |
763
+ |--------|-------------|-----------------|------------------|
764
+ | `constructor(generator: Generator<E>)` | Creates a bigint statistics instance | O(n log n) | O(n) |
765
+ | `constructor(generator: Generator<E>, comparator: Comparator<E>)` | Creates a bigint statistics instance with comparator | O(n log n) | O(n) |
766
+ | `[Symbol.iterator](): Generator<E, void, undefined>` | Returns iterator | O(n) | O(1) |
767
+ | `[Symbol.asyncIterator](): AsyncGenerator<E, void, undefined>` | Returns async iterator | O(n) | O(1) |
768
+ | `count(): bigint` | Returns the number of elements | O(1) | O(1) |
769
+ | `average(): bigint` | Returns the bigint average | O(n) | O(1) |
770
+ | `average(mapper: Functional<E, bigint>): bigint` | Returns the average of mapped bigint values | O(n) | O(1) |
771
+ | `range(): bigint` | Returns the bigint range | O(1) | O(1) |
772
+ | `range(mapper: Functional<E, bigint>): bigint` | Returns the range of mapped bigint values | O(1) | O(1) |
773
+ | `variance(): bigint` | Returns the bigint variance | O(n) | O(1) |
774
+ | `variance(mapper: Functional<E, bigint>): bigint` | Returns the variance of mapped bigint values | O(n) | O(1) |
775
+ | `standardDeviation(): bigint` | Returns the bigint standard deviation | O(n) | O(1) |
776
+ | `standardDeviation(mapper: Functional<E, bigint>): bigint` | Returns the standard deviation of mapped bigint values | O(n) | O(1) |
777
+ | `mean(): bigint` | Returns the bigint mean (same as average) | O(n) | O(1) |
778
+ | `mean(mapper: Functional<E, bigint>): bigint` | Returns the mean of mapped bigint values | O(n) | O(1) |
779
+ | `median(): bigint` | Returns the bigint median | O(n) | O(n) |
780
+ | `median(mapper: Functional<E, bigint>): bigint` | Returns the median of mapped bigint values | O(n) | O(n) |
781
+ | `mode(): bigint` | Returns the bigint mode | O(n) | O(n) |
782
+ | `mode(mapper: Functional<E, bigint>): bigint` | Returns the mode of mapped bigint values | O(n) | O(n) |
783
+ | `frequency(): Map<E, bigint>` | Returns the frequency distribution | O(n) | O(n) |
784
+ | `summate(): bigint` | Returns the bigint sum | O(n) | O(1) |
785
+ | `summate(mapper: Functional<E, bigint>): bigint` | Returns the sum of mapped bigint values | O(n) | O(1) |
786
+ | `quantile(quantile: number): bigint` | Returns the specified bigint quantile | O(1) | O(1) |
787
+ | `quantile(quantile: number, mapper: Functional<E, bigint>): bigint` | Returns the quantile of mapped bigint values | O(1) | O(1) |
788
+ | `interquartileRange(): bigint` | Returns the bigint interquartile range | O(1) | O(1) |
789
+ | `interquartileRange(mapper: Functional<E, bigint>): bigint` | Returns the IQR of mapped bigint values | O(1) | O(1) |
790
+ | `skewness(): bigint` | Returns the bigint skewness | O(n) | O(1) |
791
+ | `skewness(mapper: Functional<E, bigint>): bigint` | Returns the skewness of mapped bigint values | O(n) | O(1) |
792
+ | `kurtosis(): bigint` | Returns the bigint kurtosis | O(n) | O(1) |
793
+ | `kurtosis(mapper: Functional<E, bigint>): bigint` | Returns the kurtosis of mapped bigint values | O(n) | O(1) |
794
+
795
+ ### Window Collectable Methods
796
+
797
+ | Method | Description | Time Complexity | Space Complexity |
798
+ |--------|-------------|-----------------|------------------|
799
+ | `constructor(generator: Generator<E>)` | Creates a window collectable instance | O(n log n) | O(n) |
800
+ | `constructor(generator: Generator<E>, comparator: Comparator<E>)` | Creates a window collectable with comparator | O(n log n) | O(n) |
801
+ | `[Symbol.iterator](): Generator<E, void, undefined>` | Returns iterator | O(n) | O(1) |
802
+ | `[Symbol.asyncIterator](): AsyncGenerator<E, void, undefined>` | Returns async iterator | O(n) | O(1) |
803
+ | `slide(size: bigint): Semantic<Semantic<E>>` | Creates sliding windows of elements with 1 step | O(m × n) | O(m × n) |
804
+ | `slide(size: bigint, step: bigint): Semantic<Semantic<E>>` | Creates sliding windows of elements | O(m × n) | O(m × n) |
805
+ | `tumble(size: bigint): Semantic<Semantic<E>>` | Creates tumbling windows of elements | O(k × n) | O(k × n) |
806
+
530
807
  ## Performance Selection Guide
531
808
 
532
809
  ### Choose Unordered Collector (Performance First)
@@ -572,7 +849,6 @@ let bigIntStatistics: BigintStatistics<bigint> = data
572
849
  3. **Memory Usage**: Sorting operations require O(n) additional space
573
850
  4. **Real-time Data**: Semantic streams are suitable for processing real-time data and support asynchronous data sources
574
851
 
575
-
576
852
  This library provides TypeScript developers with powerful and flexible streaming capabilities, combining the benefits of functional programming with type safety guarantees.
577
853
 
578
854