semantic-typescript 0.6.0 → 0.7.1
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/dist/asynchronous/collector.d.ts +62 -58
- package/dist/asynchronous/collector.js +16 -5
- package/dist/asynchronous/semantic.d.ts +6 -2
- package/dist/asynchronous/semantic.js +19 -6
- package/dist/factory.d.ts +32 -71
- package/dist/factory.js +192 -603
- package/dist/guard.d.ts +0 -3
- package/dist/guard.js +0 -19
- package/dist/hash.js +3 -0
- package/dist/hook.d.ts +6 -1
- package/dist/hook.js +20 -3
- package/dist/synchronous/collector.d.ts +8 -4
- package/dist/synchronous/collector.js +74 -59
- package/dist/synchronous/semantic.d.ts +31 -23
- package/dist/synchronous/semantic.js +218 -286
- package/package.json +3 -2
- package/readme.cn.md +267 -214
- package/readme.de.md +225 -172
- package/readme.es.md +229 -170
- package/readme.fr.md +233 -170
- package/readme.jp.md +232 -169
- package/readme.kr.md +227 -169
- package/readme.md +270 -214
- package/readme.ru.md +231 -169
- package/readme.tw.md +225 -172
package/dist/guard.d.ts
CHANGED
|
@@ -37,6 +37,3 @@ export declare let isPromise: (target: unknown) => target is Promise<unknown>;
|
|
|
37
37
|
export declare let isAsyncFunction: (target: unknown) => target is AsyncFunction;
|
|
38
38
|
export declare let isGeneratorFunction: (target: unknown) => target is Generator<unknown, unknown, unknown>;
|
|
39
39
|
export declare let isAsyncGeneratorFunction: (target: unknown) => target is AsyncGenerator<unknown, unknown, unknown>;
|
|
40
|
-
export declare let isWindow: (target: unknown) => target is Window;
|
|
41
|
-
export declare let isDocument: (target: unknown) => target is Document;
|
|
42
|
-
export declare let isHTMLElemet: (target: unknown) => target is HTMLElement;
|
package/dist/guard.js
CHANGED
|
@@ -173,22 +173,3 @@ export let isAsyncGeneratorFunction = (target) => {
|
|
|
173
173
|
}
|
|
174
174
|
return false;
|
|
175
175
|
};
|
|
176
|
-
export let isWindow = (target) => {
|
|
177
|
-
if (isObject(target) && isObject(Reflect.get(target, "window"))) {
|
|
178
|
-
return Object.prototype.toString.call(Reflect.get(target, "window")) === "[object Window]";
|
|
179
|
-
}
|
|
180
|
-
return false;
|
|
181
|
-
};
|
|
182
|
-
export let isDocument = (target) => {
|
|
183
|
-
if (isObject(target) && isObject(Reflect.get(target, "document"))) {
|
|
184
|
-
return Object.prototype.toString.call(Reflect.get(target, "document")) === "[object HTMLDocument]";
|
|
185
|
-
}
|
|
186
|
-
return false;
|
|
187
|
-
};
|
|
188
|
-
export let isHTMLElemet = (target) => {
|
|
189
|
-
if (isObject(target)) {
|
|
190
|
-
let regex = /^\[object HTML\w+Element\]$/;
|
|
191
|
-
return regex.test(Object.prototype.toString.call(target));
|
|
192
|
-
}
|
|
193
|
-
return false;
|
|
194
|
-
};
|
package/dist/hash.js
CHANGED
|
@@ -70,6 +70,9 @@ register("number", (value) => {
|
|
|
70
70
|
if (primitive.has(value)) {
|
|
71
71
|
return primitive.get(value) || 0n;
|
|
72
72
|
}
|
|
73
|
+
if (Number.isNaN(value)) {
|
|
74
|
+
return 0x7ff8000000000000n;
|
|
75
|
+
}
|
|
73
76
|
let mask = maskOf("number");
|
|
74
77
|
let bit = 0xffffffffffffffffn;
|
|
75
78
|
let buffer = new ArrayBuffer(8);
|
package/dist/hook.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeepPropertyKey, type DeepPropertyValue } from "./utility";
|
|
2
|
-
import type { Comparator, SynchronousGenerator } from "./utility";
|
|
2
|
+
import type { BiFunctional, Comparator, SynchronousGenerator } from "./utility";
|
|
3
3
|
export declare let useCompare: <T>(t1: T, t2: T) => number;
|
|
4
4
|
interface UseRandom {
|
|
5
5
|
<N extends number | bigint>(start: N): N extends number ? number : (N extends bigint ? bigint : never);
|
|
@@ -30,4 +30,9 @@ interface UseArrange {
|
|
|
30
30
|
export declare let useArrange: UseArrange;
|
|
31
31
|
export declare let useToNumber: <T = unknown>(target: T) => number;
|
|
32
32
|
export declare let useToBigInt: <T = unknown>(target: T) => bigint;
|
|
33
|
+
interface UseStringify {
|
|
34
|
+
<T extends object>(target: T): string;
|
|
35
|
+
<T extends object, K extends DeepPropertyKey<T>, V extends DeepPropertyValue<T>>(target: T, callback: BiFunctional<K, V, string>): string;
|
|
36
|
+
}
|
|
37
|
+
export declare let useStringify: UseStringify;
|
|
33
38
|
export {};
|
package/dist/hook.js
CHANGED
|
@@ -246,7 +246,7 @@ export let useToNumber = (target) => {
|
|
|
246
246
|
return 0;
|
|
247
247
|
}
|
|
248
248
|
if (Reflect.has(target, Symbol.toPrimitive)) {
|
|
249
|
-
let resolved = Reflect.apply(Reflect.get(target, Symbol.toPrimitive), target, ["
|
|
249
|
+
let resolved = Reflect.apply(Reflect.get(target, Symbol.toPrimitive), target, ["number"]);
|
|
250
250
|
return isNumber(resolved) ? resolved : 0;
|
|
251
251
|
}
|
|
252
252
|
return 0;
|
|
@@ -257,7 +257,7 @@ export let useToNumber = (target) => {
|
|
|
257
257
|
export let useToBigInt = (target) => {
|
|
258
258
|
switch (typeof target) {
|
|
259
259
|
case "number":
|
|
260
|
-
return isNumber(target) ? BigInt(target) : 0n;
|
|
260
|
+
return isNumber(target) ? BigInt(Math.floor(target)) : 0n;
|
|
261
261
|
case "boolean":
|
|
262
262
|
return target ? 1n : 0n;
|
|
263
263
|
case "string":
|
|
@@ -270,7 +270,7 @@ export let useToBigInt = (target) => {
|
|
|
270
270
|
return 0n;
|
|
271
271
|
}
|
|
272
272
|
if (Reflect.has(target, Symbol.toPrimitive)) {
|
|
273
|
-
let resolved = Reflect.apply(Reflect.get(target, Symbol.toPrimitive), target, ["
|
|
273
|
+
let resolved = Reflect.apply(Reflect.get(target, Symbol.toPrimitive), target, ["bigint"]);
|
|
274
274
|
return isBigInt(resolved) ? resolved : 0n;
|
|
275
275
|
}
|
|
276
276
|
return 0n;
|
|
@@ -278,3 +278,20 @@ export let useToBigInt = (target) => {
|
|
|
278
278
|
return 0n;
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
+
;
|
|
282
|
+
export let useStringify = (target, callback) => {
|
|
283
|
+
let seen = new WeakSet();
|
|
284
|
+
let resolve = isFunction(callback) ? callback : (_key, value) => {
|
|
285
|
+
return JSON.stringify(value);
|
|
286
|
+
};
|
|
287
|
+
return JSON.stringify(target, (key, value) => {
|
|
288
|
+
if (isObject(value)) {
|
|
289
|
+
if (seen.has(value)) {
|
|
290
|
+
return (void 0);
|
|
291
|
+
}
|
|
292
|
+
seen.add(value);
|
|
293
|
+
return resolve(key, value);
|
|
294
|
+
}
|
|
295
|
+
return resolve(key, value);
|
|
296
|
+
});
|
|
297
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Optional } from "../optional";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BiFunctional, BiPredicate, Functional, Predicate, Supplier, TriFunctional, TriPredicate, Consumer, BiConsumer, Comparator, SynchronousGenerator } from "../utility";
|
|
3
3
|
export declare class SynchronousCollector<E, A, R> {
|
|
4
4
|
protected identity: Supplier<A>;
|
|
5
5
|
protected interrupt: Predicate<E> | BiPredicate<E, bigint> | TriPredicate<E, bigint, A>;
|
|
@@ -14,6 +14,10 @@ export declare class SynchronousCollector<E, A, R> {
|
|
|
14
14
|
collect(iterable: Iterable<E>): R;
|
|
15
15
|
collect(start: number, end: number): R;
|
|
16
16
|
collect(start: bigint, end: bigint): R;
|
|
17
|
+
getIdentity(): Supplier<A>;
|
|
18
|
+
getInterrupt(): Predicate<E> | BiPredicate<E, bigint> | TriPredicate<E, bigint, A>;
|
|
19
|
+
getAccumulator(): BiFunctional<A, E, A> | TriFunctional<A, E, bigint, A>;
|
|
20
|
+
getFinisher(): Functional<A, R>;
|
|
17
21
|
static full<E, A, R>(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): SynchronousCollector<E, A, R>;
|
|
18
22
|
static full<E, A, R>(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): SynchronousCollector<E, A, R>;
|
|
19
23
|
static shortable<E, A, R>(identity: Supplier<A>, interrupt: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): SynchronousCollector<E, A, R>;
|
|
@@ -140,17 +144,17 @@ interface UseSynchronousWrite {
|
|
|
140
144
|
export declare let useSynchronousWrite: UseSynchronousWrite;
|
|
141
145
|
interface UseSynchronousNumericSummate {
|
|
142
146
|
<E>(): SynchronousCollector<E, number, number>;
|
|
143
|
-
<E>(mapper: Functional<E, number>): SynchronousCollector<
|
|
147
|
+
<E>(mapper: Functional<E, number>): SynchronousCollector<number, number, number>;
|
|
144
148
|
}
|
|
145
149
|
export declare let useSynchronousNumericSummate: UseSynchronousNumericSummate;
|
|
146
150
|
interface UseSynchronousBigIntSummate {
|
|
147
151
|
<E>(): SynchronousCollector<E, bigint, bigint>;
|
|
148
|
-
<E>(mapper: Functional<E, bigint>): SynchronousCollector<
|
|
152
|
+
<E>(mapper: Functional<E, bigint>): SynchronousCollector<bigint, bigint, bigint>;
|
|
149
153
|
}
|
|
150
154
|
export declare let useSynchronousBigIntSummate: UseSynchronousBigIntSummate;
|
|
151
155
|
interface UseSynchronousNumericAverage {
|
|
152
156
|
<E>(): SynchronousCollector<E, NumericAverageAccumulator, number>;
|
|
153
|
-
<E>(mapper: Functional<E, number>): SynchronousCollector<
|
|
157
|
+
<E>(mapper: Functional<E, number>): SynchronousCollector<number, NumericAverageAccumulator, number>;
|
|
154
158
|
}
|
|
155
159
|
interface NumericAverageAccumulator {
|
|
156
160
|
summate: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isFunction,
|
|
1
|
+
import { isFunction, isNumber, isBigInt, isBoolean, isString, isObject, isAsyncFunction, isIterable } from "../guard";
|
|
2
2
|
import { useCompare, useToBigInt, useToNumber } from "../hook";
|
|
3
3
|
import { Optional } from "../optional";
|
|
4
4
|
import { SynchronousCollectorSymbol } from "../symbol";
|
|
5
|
-
import {
|
|
5
|
+
import { invalidate, validate } from "../utility";
|
|
6
6
|
export class SynchronousCollector {
|
|
7
7
|
identity;
|
|
8
8
|
interrupt;
|
|
@@ -54,7 +54,7 @@ export class SynchronousCollector {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
collect(argument1, argument2) {
|
|
57
|
-
if (isFunction(argument1)) {
|
|
57
|
+
if (isAsyncFunction(argument1) || isFunction(argument1)) {
|
|
58
58
|
try {
|
|
59
59
|
let generator = argument1;
|
|
60
60
|
let accumulator = this.identity();
|
|
@@ -66,29 +66,25 @@ export class SynchronousCollector {
|
|
|
66
66
|
return this.finisher(accumulator);
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
|
|
70
|
-
throw new Error("Uncaught error on collect.");
|
|
69
|
+
throw error;
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
else if (isIterable(argument1)) {
|
|
74
73
|
try {
|
|
75
74
|
let iterable = argument1;
|
|
76
|
-
let index = 0n;
|
|
77
75
|
let accumulator = this.identity();
|
|
78
76
|
let count = 0n;
|
|
79
77
|
for (let element of iterable) {
|
|
80
|
-
if (this.interrupt(element,
|
|
78
|
+
if (this.interrupt(element, count, accumulator)) {
|
|
81
79
|
break;
|
|
82
80
|
}
|
|
83
81
|
accumulator = this.accumulator(accumulator, element, count);
|
|
84
82
|
count++;
|
|
85
|
-
index++;
|
|
86
83
|
}
|
|
87
84
|
return this.finisher(accumulator);
|
|
88
85
|
}
|
|
89
86
|
catch (error) {
|
|
90
|
-
|
|
91
|
-
throw new Error("Uncaught error n collect.");
|
|
87
|
+
throw error;
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
else if (isNumber(argument1) && isNumber(argument2)) {
|
|
@@ -107,8 +103,7 @@ export class SynchronousCollector {
|
|
|
107
103
|
return this.finisher(accumulator);
|
|
108
104
|
}
|
|
109
105
|
catch (error) {
|
|
110
|
-
|
|
111
|
-
throw new Error("Uncaught error on collect.");
|
|
106
|
+
throw error;
|
|
112
107
|
}
|
|
113
108
|
}
|
|
114
109
|
else if (isBigInt(argument1) && isBigInt(argument2)) {
|
|
@@ -127,12 +122,23 @@ export class SynchronousCollector {
|
|
|
127
122
|
return this.finisher(accumulator);
|
|
128
123
|
}
|
|
129
124
|
catch (error) {
|
|
130
|
-
|
|
131
|
-
throw new Error("Uncaught error on collect.");
|
|
125
|
+
throw error;
|
|
132
126
|
}
|
|
133
127
|
}
|
|
134
128
|
throw new Error("Invalid arguments.");
|
|
135
129
|
}
|
|
130
|
+
getIdentity() {
|
|
131
|
+
return this.identity;
|
|
132
|
+
}
|
|
133
|
+
getInterrupt() {
|
|
134
|
+
return this.interrupt;
|
|
135
|
+
}
|
|
136
|
+
getAccumulator() {
|
|
137
|
+
return this.accumulator;
|
|
138
|
+
}
|
|
139
|
+
getFinisher() {
|
|
140
|
+
return this.finisher;
|
|
141
|
+
}
|
|
136
142
|
static full(identity, accumulator, finisher) {
|
|
137
143
|
return new SynchronousCollector(identity, () => false, accumulator, finisher);
|
|
138
144
|
}
|
|
@@ -173,7 +179,7 @@ export let useSynchronousCollect = (argument1, argument2, argument3, argument4)
|
|
|
173
179
|
throw new TypeError("Identity, accumulator, and finisher must be functions.");
|
|
174
180
|
};
|
|
175
181
|
export let useSynchronousCount = () => {
|
|
176
|
-
return SynchronousCollector.full(() => 0n, (count) => count + 1n, (count) => count);
|
|
182
|
+
return SynchronousCollector.full(() => 0n, (count) => isBigInt(count) ? (count + 1n) : 1n, (count) => isBigInt(count) ? count : 0n);
|
|
177
183
|
};
|
|
178
184
|
;
|
|
179
185
|
export let useSynchronousError = (argument1, argument2, argument3) => {
|
|
@@ -215,65 +221,78 @@ export let useSynchronousFindAt = (index) => {
|
|
|
215
221
|
let target = useToBigInt(index);
|
|
216
222
|
if (target < 0n) {
|
|
217
223
|
return SynchronousCollector.full(() => [], (accumulator, element) => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
let accumulated = Array.isArray(accumulator) ? accumulator : [];
|
|
225
|
+
accumulated.push(element);
|
|
226
|
+
return accumulated;
|
|
227
|
+
}, (result) => {
|
|
228
|
+
if (Array.isArray(result) && result.length > 0) {
|
|
229
|
+
let index = ((Number(target) % result.length) + result.length) % result.length;
|
|
230
|
+
return Optional.of(result[index]);
|
|
223
231
|
}
|
|
224
|
-
|
|
225
|
-
return Optional.ofNullable(accumulator[Number(limited)]);
|
|
232
|
+
return Optional.empty();
|
|
226
233
|
});
|
|
227
234
|
}
|
|
228
235
|
return SynchronousCollector.shortable(() => [], (_element, _index, accumulator) => BigInt(accumulator.length) - 1n === target, (accumulator, element) => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
let accumulated = Array.isArray(accumulator) ? accumulator : [];
|
|
237
|
+
accumulated.push(element);
|
|
238
|
+
return accumulated;
|
|
239
|
+
}, (result) => {
|
|
240
|
+
let index = ((Number(target) % result.length) + result.length) % result.length;
|
|
241
|
+
if (Array.isArray(result) && result.length > 0) {
|
|
242
|
+
return Optional.of(result[index]);
|
|
234
243
|
}
|
|
235
|
-
return Optional.
|
|
244
|
+
return Optional.empty();
|
|
236
245
|
});
|
|
237
246
|
};
|
|
238
247
|
export let useSynchronousFindFirst = () => {
|
|
239
248
|
return SynchronousCollector.shortable(() => Optional.empty(), (_element, _index, accumulator) => validate(accumulator) && accumulator.isPresent(), (accumulator, element) => {
|
|
240
|
-
if (validate(accumulator) && accumulator.isPresent()) {
|
|
241
|
-
return
|
|
249
|
+
if (validate(accumulator) && accumulator.isPresent() && validate(element)) {
|
|
250
|
+
return Optional.of(element);
|
|
242
251
|
}
|
|
243
|
-
return
|
|
244
|
-
}, (
|
|
252
|
+
return accumulator;
|
|
253
|
+
}, (result) => result);
|
|
245
254
|
};
|
|
246
255
|
export let useSynchronousFindAny = () => {
|
|
247
256
|
return SynchronousCollector.shortable(() => Optional.empty(), (_element, _index, accumulator) => validate(accumulator) && accumulator.isPresent(), (accumulator, element) => {
|
|
248
|
-
if (validate(accumulator) && accumulator.isPresent() && Math.random() < 0.5) {
|
|
249
|
-
return
|
|
257
|
+
if (validate(accumulator) && accumulator.isPresent() && validate(element) && Math.random() < 0.5) {
|
|
258
|
+
return Optional.of(element);
|
|
250
259
|
}
|
|
251
|
-
return
|
|
252
|
-
}, (
|
|
260
|
+
return accumulator;
|
|
261
|
+
}, (result) => result);
|
|
253
262
|
};
|
|
254
263
|
export let useSynchronousFindLast = () => {
|
|
255
264
|
return SynchronousCollector.full(() => Optional.empty(), (accumulator, element) => {
|
|
256
|
-
if (validate(accumulator) && accumulator.isPresent()) {
|
|
257
|
-
return Optional.
|
|
265
|
+
if (validate(accumulator) && accumulator.isPresent() && validate(element)) {
|
|
266
|
+
return Optional.of(element);
|
|
258
267
|
}
|
|
259
268
|
return accumulator;
|
|
260
|
-
}, (
|
|
269
|
+
}, (result) => result);
|
|
261
270
|
};
|
|
262
271
|
export let useSynchronousFindMaximum = (comparator = (useCompare)) => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
272
|
+
if (isFunction(comparator)) {
|
|
273
|
+
return SynchronousCollector.full(() => Optional.empty(), (accumulator, element) => {
|
|
274
|
+
if (validate(accumulator) && accumulator.isPresent()) {
|
|
275
|
+
return accumulator.map((previous) => {
|
|
276
|
+
return comparator(previous, element) > 0 ? previous : element;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return accumulator;
|
|
280
|
+
}, (result) => result);
|
|
281
|
+
}
|
|
282
|
+
throw new TypeError("Invalid argument.");
|
|
269
283
|
};
|
|
270
284
|
export let useSynchronousFindMinimum = (comparator = (useCompare)) => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
285
|
+
if (isFunction(comparator)) {
|
|
286
|
+
return SynchronousCollector.full(() => Optional.empty(), (accumulator, element) => {
|
|
287
|
+
if (validate(accumulator) && accumulator.isPresent()) {
|
|
288
|
+
return accumulator.map((previous) => {
|
|
289
|
+
return comparator(previous, element) < 0 ? previous : element;
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return accumulator;
|
|
293
|
+
}, (result) => result);
|
|
294
|
+
}
|
|
295
|
+
throw new TypeError("Invalid argument.");
|
|
277
296
|
};
|
|
278
297
|
;
|
|
279
298
|
export let useSynchronousForEach = (action) => {
|
|
@@ -364,7 +383,6 @@ export let useSynchronousLog = (argument1, argument2, argument3) => {
|
|
|
364
383
|
}
|
|
365
384
|
else {
|
|
366
385
|
return SynchronousCollector.full(() => "[", (accumulator, element) => {
|
|
367
|
-
console.log(element);
|
|
368
386
|
if (isString(accumulator) && isString(element)) {
|
|
369
387
|
return accumulator + element + ",";
|
|
370
388
|
}
|
|
@@ -416,14 +434,11 @@ export let useSynchronousPartitionBy = (classifier) => {
|
|
|
416
434
|
export let useSynchronousReduce = (argument1, argument2, argument3) => {
|
|
417
435
|
if (isFunction(argument1) && invalidate(argument2) && invalidate(argument3)) {
|
|
418
436
|
let accumulator = argument1;
|
|
419
|
-
return SynchronousCollector.full(() => Optional.
|
|
420
|
-
if (result.
|
|
421
|
-
return
|
|
422
|
-
}
|
|
423
|
-
else {
|
|
424
|
-
let current = result.get();
|
|
425
|
-
return Optional.of(accumulator(current, element, index));
|
|
437
|
+
return SynchronousCollector.full(() => Optional.empty(), (result, element, index) => {
|
|
438
|
+
if (validate(result) && result.isPresent()) {
|
|
439
|
+
return result.map((previous) => accumulator(previous, element, index));
|
|
426
440
|
}
|
|
441
|
+
return result;
|
|
427
442
|
}, (result) => result);
|
|
428
443
|
}
|
|
429
444
|
else if (validate(argument1) && isFunction(argument2) && invalidate(argument3)) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type BiConsumer, type BiFunctional, type BiPredicate, type Comparator, type Consumer, type Functional, type Indexed, type Predicate, type Supplier, type SynchronousGenerator, type TriFunctional, type TriPredicate } from "../utility";
|
|
1
2
|
import { SynchronousCollector } from "./collector";
|
|
2
3
|
import type { Optional } from "../optional";
|
|
3
|
-
import type { BiConsumer, BiFunctional, BiPredicate, Comparator, Consumer, Functional, Indexed, Predicate, Supplier, SynchronousGenerator, TriFunctional, TriPredicate } from "../utility";
|
|
4
4
|
export declare class SynchronousSemantic<E> {
|
|
5
5
|
protected generator: SynchronousGenerator<E>;
|
|
6
6
|
protected readonly SynchronousSemantic: Symbol;
|
|
7
|
+
[Symbol.toStringTag]: string;
|
|
7
8
|
constructor(generator: SynchronousGenerator<E>);
|
|
8
9
|
concat(other: SynchronousSemantic<E>): SynchronousSemantic<E>;
|
|
9
10
|
concat(other: Iterable<E>): SynchronousSemantic<E>;
|
|
@@ -22,8 +23,10 @@ export declare class SynchronousSemantic<E> {
|
|
|
22
23
|
flatMap<R>(mapper: BiFunctional<E, bigint, Iterable<R>>): SynchronousSemantic<R>;
|
|
23
24
|
flatMap<R>(mapper: Functional<E, SynchronousSemantic<R>>): SynchronousSemantic<R>;
|
|
24
25
|
flatMap<R>(mapper: BiFunctional<E, bigint, SynchronousSemantic<R>>): SynchronousSemantic<R>;
|
|
25
|
-
limit(
|
|
26
|
-
limit(
|
|
26
|
+
limit(count: number): SynchronousSemantic<E>;
|
|
27
|
+
limit(count: bigint): SynchronousSemantic<E>;
|
|
28
|
+
map(mapper: Functional<E, E>): SynchronousSemantic<E>;
|
|
29
|
+
map(mapper: BiFunctional<E, bigint, E>): SynchronousSemantic<E>;
|
|
27
30
|
map<R>(mapper: Functional<E, R>): SynchronousSemantic<R>;
|
|
28
31
|
map<R>(mapper: BiFunctional<E, bigint, R>): SynchronousSemantic<R>;
|
|
29
32
|
peek(consumer: Consumer<E>): SynchronousSemantic<E>;
|
|
@@ -32,16 +35,15 @@ export declare class SynchronousSemantic<E> {
|
|
|
32
35
|
reverse(): SynchronousSemantic<E>;
|
|
33
36
|
shuffle(): SynchronousSemantic<E>;
|
|
34
37
|
shuffle(mapper: BiFunctional<E, bigint, bigint>): SynchronousSemantic<E>;
|
|
35
|
-
skip(
|
|
36
|
-
skip(
|
|
38
|
+
skip(count: number): SynchronousSemantic<E>;
|
|
39
|
+
skip(count: bigint): SynchronousSemantic<E>;
|
|
37
40
|
source(): SynchronousGenerator<E>;
|
|
38
|
-
|
|
39
|
-
sorted(comparator: Comparator<E>): SynchronousOrderedCollectable<E>;
|
|
41
|
+
sub(start: number, end: number): SynchronousSemantic<E>;
|
|
40
42
|
sub(start: bigint, end: bigint): SynchronousSemantic<E>;
|
|
41
43
|
takeWhile(predicate: Predicate<E>): SynchronousSemantic<E>;
|
|
42
44
|
takeWhile(predicate: BiPredicate<E, bigint>): SynchronousSemantic<E>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
toCollectable(): SynchronousCollectable<E>;
|
|
46
|
+
toCollectable<C extends SynchronousCollectable<E>>(mapper: Functional<SynchronousGenerator<E>, C>): C;
|
|
45
47
|
toBigintStatistics(): SynchronousBigIntStatistics<E>;
|
|
46
48
|
toNumericStatistics(): SynchronousNumericStatistics<E>;
|
|
47
49
|
toOrdered(): SynchronousOrderedCollectable<E>;
|
|
@@ -51,13 +53,15 @@ export declare class SynchronousSemantic<E> {
|
|
|
51
53
|
translate(offset: bigint): SynchronousSemantic<E>;
|
|
52
54
|
translate(translator: BiFunctional<E, bigint, bigint>): SynchronousSemantic<E>;
|
|
53
55
|
}
|
|
54
|
-
export declare abstract class SynchronousCollectable<E> {
|
|
56
|
+
export declare abstract class SynchronousCollectable<E> implements Iterable<E> {
|
|
55
57
|
protected readonly SynchronousCollectable: symbol;
|
|
58
|
+
[Symbol.toStringTag]: string;
|
|
56
59
|
constructor();
|
|
57
|
-
|
|
58
|
-
abstract [Symbol.asyncIterator](): globalThis.AsyncGenerator<E, void, undefined>;
|
|
60
|
+
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
59
61
|
anyMatch(predicate: Predicate<E>): boolean;
|
|
62
|
+
anyMatch(predicate: BiPredicate<E, bigint>): boolean;
|
|
60
63
|
allMatch(predicate: Predicate<E>): boolean;
|
|
64
|
+
allMatch(predicate: BiPredicate<E, bigint>): boolean;
|
|
61
65
|
collect<A, R>(collector: SynchronousCollector<E, A, R>): R;
|
|
62
66
|
collect<A, R>(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R;
|
|
63
67
|
collect<A, R>(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R;
|
|
@@ -104,8 +108,10 @@ export declare abstract class SynchronousCollectable<E> {
|
|
|
104
108
|
partition(count: bigint): Array<Array<E>>;
|
|
105
109
|
partitionBy(classifier: Functional<E, bigint>): Array<Array<E>>;
|
|
106
110
|
partitionBy(classifier: BiFunctional<E, bigint, bigint>): Array<Array<E>>;
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
pipe(conversion: Functional<SynchronousGenerator<E>, SynchronousSemantic<E>>): SynchronousSemantic<E>;
|
|
112
|
+
pipe<R>(conversion: Functional<SynchronousGenerator<E>, SynchronousSemantic<R>>): SynchronousSemantic<R>;
|
|
113
|
+
reduce(accumulator: BiFunctional<E, E, E>): E;
|
|
114
|
+
reduce(accumulator: TriFunctional<E, E, bigint, E>): E;
|
|
109
115
|
reduce(identity: E, accumulator: BiFunctional<E, E, E>): E;
|
|
110
116
|
reduce(identity: E, accumulator: TriFunctional<E, E, bigint, E>): E;
|
|
111
117
|
reduce<R>(identity: R, accumulator: BiFunctional<R, E, R>, finisher: Functional<R, R>): R;
|
|
@@ -122,30 +128,32 @@ export declare abstract class SynchronousCollectable<E> {
|
|
|
122
128
|
write<S = string>(stream: WritableStream<S>, accumulator: TriFunctional<WritableStream<S>, E, bigint, WritableStream<S>>): Promise<WritableStream<S>>;
|
|
123
129
|
}
|
|
124
130
|
export declare class SynchronousOrderedCollectable<E> extends SynchronousCollectable<E> {
|
|
125
|
-
protected readonly
|
|
131
|
+
protected readonly OrderedCollectable: symbol;
|
|
126
132
|
protected buffer: Array<Indexed<E>>;
|
|
133
|
+
[Symbol.toStringTag]: string;
|
|
127
134
|
constructor(generator: SynchronousGenerator<E>);
|
|
128
135
|
constructor(generator: SynchronousGenerator<E>, comparator: Comparator<E>);
|
|
129
136
|
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
130
|
-
|
|
137
|
+
allMatch(predicate: Predicate<E>): boolean;
|
|
138
|
+
allMatch(predicate: BiPredicate<E, bigint>): boolean;
|
|
131
139
|
source(): SynchronousGenerator<E>;
|
|
132
140
|
isEmpty(): boolean;
|
|
141
|
+
count(): bigint;
|
|
133
142
|
}
|
|
134
143
|
export declare class SynchronousUnorderedCollectable<E> extends SynchronousCollectable<E> {
|
|
135
144
|
protected readonly SynchronousUnorderedCollectable: symbol;
|
|
145
|
+
[Symbol.toStringTag]: string;
|
|
136
146
|
protected buffer: Map<bigint, E>;
|
|
137
147
|
constructor(generator: SynchronousGenerator<E>);
|
|
138
|
-
source(): SynchronousGenerator<E>;
|
|
139
148
|
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
140
|
-
|
|
149
|
+
source(): SynchronousGenerator<E>;
|
|
141
150
|
}
|
|
142
151
|
export declare abstract class SynchronousStatistics<E, D extends number | bigint> extends SynchronousOrderedCollectable<E> {
|
|
143
152
|
protected readonly SynchronousStatistics: symbol;
|
|
153
|
+
[Symbol.toStringTag]: string;
|
|
144
154
|
constructor(generator: SynchronousGenerator<E>);
|
|
145
155
|
constructor(generator: SynchronousGenerator<E>, comparator: Comparator<E>);
|
|
146
156
|
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
147
|
-
[Symbol.asyncIterator](): globalThis.AsyncGenerator<E, void, undefined>;
|
|
148
|
-
count(): bigint;
|
|
149
157
|
abstract average(): D;
|
|
150
158
|
abstract average(mapper: Functional<E, D>): D;
|
|
151
159
|
abstract range(): D;
|
|
@@ -174,10 +182,10 @@ export declare abstract class SynchronousStatistics<E, D extends number | bigint
|
|
|
174
182
|
}
|
|
175
183
|
export declare class SynchronousBigIntStatistics<E> extends SynchronousStatistics<E, bigint> {
|
|
176
184
|
protected readonly BigIntStatistics: symbol;
|
|
185
|
+
[Symbol.toStringTag]: string;
|
|
177
186
|
constructor(generator: SynchronousGenerator<E>);
|
|
178
187
|
constructor(generator: SynchronousGenerator<E>, comparator: Comparator<E>);
|
|
179
188
|
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
180
|
-
[Symbol.asyncIterator](): globalThis.AsyncGenerator<E, void, undefined>;
|
|
181
189
|
average(): bigint;
|
|
182
190
|
average(mapper: Functional<E, bigint>): bigint;
|
|
183
191
|
range(): bigint;
|
|
@@ -205,10 +213,10 @@ export declare class SynchronousBigIntStatistics<E> extends SynchronousStatistic
|
|
|
205
213
|
}
|
|
206
214
|
export declare class SynchronousNumericStatistics<E> extends SynchronousStatistics<E, number> {
|
|
207
215
|
protected readonly SynchronousNumericStatistics: symbol;
|
|
216
|
+
[Symbol.toStringTag]: string;
|
|
208
217
|
constructor(generator: SynchronousGenerator<E>);
|
|
209
218
|
constructor(generator: SynchronousGenerator<E>, comparator: Comparator<E>);
|
|
210
219
|
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
211
|
-
[Symbol.asyncIterator](): globalThis.AsyncGenerator<E, void, undefined>;
|
|
212
220
|
average(): number;
|
|
213
221
|
average(mapper: Functional<E, number>): number;
|
|
214
222
|
range(): number;
|
|
@@ -236,10 +244,10 @@ export declare class SynchronousNumericStatistics<E> extends SynchronousStatisti
|
|
|
236
244
|
}
|
|
237
245
|
export declare class SynchronousWindowCollectable<E> extends SynchronousOrderedCollectable<E> {
|
|
238
246
|
protected readonly WindowCollectable: symbol;
|
|
247
|
+
[Symbol.toStringTag]: string;
|
|
239
248
|
constructor(generator: SynchronousGenerator<E>);
|
|
240
249
|
constructor(generator: SynchronousGenerator<E>, comparator: Comparator<E>);
|
|
241
250
|
[Symbol.iterator](): globalThis.Generator<E, void, undefined>;
|
|
242
|
-
[Symbol.asyncIterator](): globalThis.AsyncGenerator<E, void, undefined>;
|
|
243
251
|
slide(size: bigint, step?: bigint): SynchronousSemantic<SynchronousSemantic<E>>;
|
|
244
252
|
tumble(size: bigint): SynchronousSemantic<SynchronousSemantic<E>>;
|
|
245
253
|
}
|