semantic-typescript 0.0.8 → 0.2.5
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/collectable.d.ts +84 -0
- package/dist/collectable.js +476 -0
- package/dist/collector.d.ts +24 -0
- package/dist/collector.js +63 -0
- package/dist/factory.d.ts +11 -0
- package/dist/factory.js +248 -0
- package/dist/guard.d.ts +23 -0
- package/dist/guard.js +85 -0
- package/dist/hook.d.ts +2 -0
- package/dist/hook.js +64 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/optional.d.ts +18 -0
- package/dist/optional.js +65 -0
- package/dist/semantic.d.ts +9 -272
- package/dist/semantic.js +38 -1679
- package/dist/statistics.d.ts +101 -0
- package/dist/statistics.js +765 -0
- package/dist/symbol.d.ts +10 -0
- package/dist/symbol.js +10 -0
- package/dist/utility.d.ts +49 -0
- package/dist/utility.js +17 -0
- package/package.json +54 -8
- package/readme.cn.md +387 -445
- package/readme.de.md +393 -448
- package/readme.es.md +392 -446
- package/readme.fr.md +396 -450
- package/readme.jp.md +390 -447
- package/readme.kr.md +396 -453
- package/readme.md +389 -445
- package/readme.ru.md +391 -447
- package/readme.tw.md +403 -444
package/dist/semantic.d.ts
CHANGED
|
@@ -1,93 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare let invalidate: <T>(t: MaybeInvalid<T>) => t is (null | undefined);
|
|
6
|
-
export type Primitive = string | number | boolean | symbol | bigint | Function | ((...args: any[]) => any);
|
|
7
|
-
export type MaybePrimitive<T> = T | Primitive;
|
|
8
|
-
export declare let isBoolean: (t: unknown) => t is boolean;
|
|
9
|
-
export declare let isString: (t: unknown) => t is string;
|
|
10
|
-
export declare let isNumber: (t: unknown) => t is number;
|
|
11
|
-
export declare let isFunction: (t: unknown) => t is Function;
|
|
12
|
-
export declare let isObject: (t: unknown) => t is object;
|
|
13
|
-
export declare let isSymbol: (t: unknown) => t is symbol;
|
|
14
|
-
export declare let isBigint: (t: unknown) => t is bigint;
|
|
15
|
-
export declare let isPrimitive: (t: MaybePrimitive<unknown>) => t is Primitive;
|
|
16
|
-
export declare let isIterable: (t: unknown) => t is Iterable<unknown>;
|
|
17
|
-
export declare let useCompare: <T>(t1: T, t2: T) => number;
|
|
18
|
-
export declare let useRandom: <T = number | bigint>(index: T) => T;
|
|
19
|
-
export declare let OptionalSymbol: symbol;
|
|
20
|
-
export declare let SemanticSymbol: symbol;
|
|
21
|
-
export declare let CollectorsSymbol: symbol;
|
|
22
|
-
export declare let CollectableSymbol: symbol;
|
|
23
|
-
export declare let OrderedCollectableSymbol: symbol;
|
|
24
|
-
export declare let UnorderedCollectableSymbol: symbol;
|
|
25
|
-
export declare let StatisticsSymbol: symbol;
|
|
26
|
-
export declare let isOptional: (t: unknown) => t is Optional<unknown>;
|
|
27
|
-
export declare let isSemantic: (t: unknown) => t is Semantic<unknown>;
|
|
28
|
-
export declare let isCollector: (t: unknown) => t is Collector<unknown, unknown, unknown>;
|
|
29
|
-
export declare let isCollectable: (t: unknown) => t is Collectable<unknown>;
|
|
30
|
-
export declare let isOrderedCollectable: (t: unknown) => t is OrderedCollectable<unknown>;
|
|
31
|
-
export declare let isUnorderedCollectable: (t: unknown) => t is UnorderedCollectable<unknown>;
|
|
32
|
-
export declare let isStatistics: (t: unknown) => t is Statistics<unknown, number | bigint>;
|
|
33
|
-
export interface Runnable {
|
|
34
|
-
(): void;
|
|
35
|
-
}
|
|
36
|
-
export interface Supplier<R> {
|
|
37
|
-
(): R;
|
|
38
|
-
}
|
|
39
|
-
export interface Functional<T, R> {
|
|
40
|
-
(t: T): R;
|
|
41
|
-
}
|
|
42
|
-
export interface Predicate<T> {
|
|
43
|
-
(t: T): boolean;
|
|
44
|
-
}
|
|
45
|
-
export interface BiFunctional<T, U, R> {
|
|
46
|
-
(t: T, u: U): R;
|
|
47
|
-
}
|
|
48
|
-
export interface BiPredicate<T, U> {
|
|
49
|
-
(t: T, u: U): boolean;
|
|
50
|
-
}
|
|
51
|
-
export interface Comparator<T> {
|
|
52
|
-
(t1: T, t2: T): number;
|
|
53
|
-
}
|
|
54
|
-
export interface TriFunctional<T, U, V, R> {
|
|
55
|
-
(t: T, u: U, v: V): R;
|
|
56
|
-
}
|
|
57
|
-
export interface Consumer<T> {
|
|
58
|
-
(t: T): void;
|
|
59
|
-
}
|
|
60
|
-
export interface BiConsumer<T, U> {
|
|
61
|
-
(t: T, u: U): void;
|
|
62
|
-
}
|
|
63
|
-
export interface TriConsumer<T, U, V> {
|
|
64
|
-
(t: T, u: U, v: V): void;
|
|
65
|
-
}
|
|
66
|
-
export interface Generator<T> {
|
|
67
|
-
(accept: BiConsumer<T, bigint>, interrupt: Predicate<T>): void;
|
|
68
|
-
}
|
|
69
|
-
declare class Optional<T> {
|
|
70
|
-
protected value: MaybeInvalid<T>;
|
|
71
|
-
protected readonly Optional: Symbol;
|
|
72
|
-
protected constructor(value: MaybeInvalid<T>);
|
|
73
|
-
filter(predicate: Predicate<T>): Optional<T>;
|
|
74
|
-
get(): T;
|
|
75
|
-
getOrDefault(defaultValue: T): T;
|
|
76
|
-
ifPresent(action: Consumer<T>): void;
|
|
77
|
-
isEmpty(): boolean;
|
|
78
|
-
isPresent(): boolean;
|
|
79
|
-
map<R>(mapper: Functional<T, R>): Optional<R>;
|
|
80
|
-
static of<T>(value: MaybeInvalid<T>): Optional<T>;
|
|
81
|
-
static ofNullable<T>(value?: MaybeInvalid<T>): Optional<T>;
|
|
82
|
-
static ofNonNull<T>(value: T): Optional<T>;
|
|
83
|
-
}
|
|
84
|
-
export declare let blob: BiFunctional<Blob, bigint, Semantic<Uint8Array>>;
|
|
85
|
-
export declare let empty: <E>() => Semantic<E>;
|
|
86
|
-
export declare let fill: <E>(element: E | Supplier<E>, count: bigint) => Semantic<E>;
|
|
87
|
-
export declare let from: <E>(iterable: Iterable<E>) => Semantic<E>;
|
|
88
|
-
export declare let range: <N extends number | bigint>(start: N, end: N, step: N) => Semantic<N>;
|
|
89
|
-
export declare let iterate: <E>(generator: Generator<E>) => Semantic<E>;
|
|
90
|
-
export declare let websocket: Functional<WebSocket, Semantic<MessageEvent | CloseEvent | Event>>;
|
|
1
|
+
import { Collectable, OrderedCollectable, UnorderedCollectable, WindowCollectable } from "./collectable";
|
|
2
|
+
import { type Statistics } from "./statistics";
|
|
3
|
+
import { type Predicate } from "./utility";
|
|
4
|
+
import type { Generator, Functional, BiFunctional, Consumer, BiConsumer, Comparator } from "./utility";
|
|
91
5
|
export declare class Semantic<E> {
|
|
92
6
|
protected generator: Generator<E>;
|
|
93
7
|
protected readonly Semantic: Symbol;
|
|
@@ -103,6 +17,7 @@ export declare class Semantic<E> {
|
|
|
103
17
|
limit(n: number): Semantic<E>;
|
|
104
18
|
limit(n: bigint): Semantic<E>;
|
|
105
19
|
map<R>(mapper: Functional<E, R>): Semantic<R>;
|
|
20
|
+
peek(consumer: Consumer<E>): Semantic<E>;
|
|
106
21
|
peek(consumer: BiConsumer<E, bigint>): Semantic<E>;
|
|
107
22
|
redirect(redirector: BiFunctional<E, bigint, bigint>): Semantic<E>;
|
|
108
23
|
reverse(): Semantic<E>;
|
|
@@ -114,192 +29,14 @@ export declare class Semantic<E> {
|
|
|
114
29
|
sorted(comparator: Comparator<E>): OrderedCollectable<E>;
|
|
115
30
|
sub(start: bigint, end: bigint): Semantic<E>;
|
|
116
31
|
takeWhile(predicate: Predicate<E>): Semantic<E>;
|
|
117
|
-
|
|
118
|
-
|
|
32
|
+
toCollectable(): Collectable<E>;
|
|
33
|
+
toCollectable<C extends Collectable<E>>(mapper: Functional<Generator<E>, C>): C;
|
|
119
34
|
toBigintStatistics(): Statistics<E, bigint>;
|
|
35
|
+
toNumericStatistics(): Statistics<E, number>;
|
|
36
|
+
toOrdered(): OrderedCollectable<E>;
|
|
120
37
|
toUnoredered(): UnorderedCollectable<E>;
|
|
121
38
|
toWindow(): WindowCollectable<E>;
|
|
122
39
|
translate(offset: number): Semantic<E>;
|
|
123
40
|
translate(offset: bigint): Semantic<E>;
|
|
124
41
|
translate(translator: BiFunctional<E, bigint, bigint>): Semantic<E>;
|
|
125
42
|
}
|
|
126
|
-
export declare class Collector<E, A, R> {
|
|
127
|
-
protected identity: Supplier<A>;
|
|
128
|
-
protected interruptor: Predicate<E>;
|
|
129
|
-
protected accumulator: BiFunctional<A, E, A> | TriFunctional<A, E, bigint, A>;
|
|
130
|
-
protected finisher: Functional<A, R>;
|
|
131
|
-
protected readonly Collector: symbol;
|
|
132
|
-
constructor(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>);
|
|
133
|
-
constructor(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>);
|
|
134
|
-
collect(generator: Generator<E>): R;
|
|
135
|
-
collect(iterable: Iterable<E>): R;
|
|
136
|
-
static full<E, A, R>(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>;
|
|
137
|
-
static full<E, A, R>(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>;
|
|
138
|
-
static shortable<E, A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): Collector<E, A, R>;
|
|
139
|
-
static shortable<E, A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): Collector<E, A, R>;
|
|
140
|
-
}
|
|
141
|
-
export declare abstract class Collectable<E> {
|
|
142
|
-
constructor();
|
|
143
|
-
anyMatch(predicate: Predicate<E>): boolean;
|
|
144
|
-
allMatch(predicate: Predicate<E>): boolean;
|
|
145
|
-
collect<A, R>(collector: Collector<E, A, R>): R;
|
|
146
|
-
collect<A, R>(identity: Supplier<A>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R;
|
|
147
|
-
collect<A, R>(identity: Supplier<A>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R;
|
|
148
|
-
collect<A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: BiFunctional<A, E, A>, finisher: Functional<A, R>): R;
|
|
149
|
-
collect<A, R>(identity: Supplier<A>, interruptor: Predicate<E>, accumulator: TriFunctional<A, E, bigint, A>, finisher: Functional<A, R>): R;
|
|
150
|
-
count(): bigint;
|
|
151
|
-
isEmpty(): boolean;
|
|
152
|
-
findAny(): Optional<E>;
|
|
153
|
-
findFirst(): Optional<E>;
|
|
154
|
-
findLast(): Optional<E>;
|
|
155
|
-
forEach(action: BiConsumer<E, bigint>): void;
|
|
156
|
-
group<K>(classifier: Functional<E, K>): Map<K, Array<E>>;
|
|
157
|
-
groupBy<K, V>(keyExtractor: Functional<E, K>, valueExtractor: Functional<E, V>): Map<K, Array<V>>;
|
|
158
|
-
join(): string;
|
|
159
|
-
join(delimiter: string): string;
|
|
160
|
-
join(prefix: string, delimiter: string, suffix: string): string;
|
|
161
|
-
join(prefiex: string, accumulator: BiFunctional<string, E, string>, suffix: string): string;
|
|
162
|
-
join(prefiex: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): string;
|
|
163
|
-
log(): void;
|
|
164
|
-
log(accumulator: BiFunctional<string, E, string>): void;
|
|
165
|
-
log(accumulator: BiFunctional<string, E, string> | TriFunctional<string, E, bigint, string>): void;
|
|
166
|
-
log(prefix: string, accumulator: BiFunctional<string, E, string>, suffix: string): void;
|
|
167
|
-
log(prefix: string, accumulator: TriFunctional<string, E, bigint, string>, suffix: string): void;
|
|
168
|
-
nonMatch(predicate: Predicate<E>): boolean;
|
|
169
|
-
partition(count: bigint): Array<Array<E>>;
|
|
170
|
-
partitionBy(classifier: Functional<E, bigint>): Array<Array<E>>;
|
|
171
|
-
reduce(accumulator: BiFunctional<E, E, E>): Optional<E>;
|
|
172
|
-
reduce(accumulator: TriFunctional<E, E, bigint, E>): Optional<E>;
|
|
173
|
-
reduce(identity: E, accumulator: BiFunctional<E, E, E>): E;
|
|
174
|
-
reduce(identity: E, accumulator: TriFunctional<E, E, bigint, E>): E;
|
|
175
|
-
reduce<R>(identity: R, accumulator: BiFunctional<R, E, R>, finisher: BiFunctional<R, R, R>): R;
|
|
176
|
-
reduce<R>(identity: R, accumulator: TriFunctional<R, E, bigint, R>, finisher: BiFunctional<R, R, R>): R;
|
|
177
|
-
semantic(): Semantic<E>;
|
|
178
|
-
protected abstract source(): Generator<E> | Iterable<E>;
|
|
179
|
-
toArray(): Array<E>;
|
|
180
|
-
toMap<K, V>(keyExtractor: Functional<E, K>, valueExtractor: Functional<E, V>): Map<K, V>;
|
|
181
|
-
toSet(): Set<E>;
|
|
182
|
-
write(stream: WritableStream<string>): Promise<void>;
|
|
183
|
-
write(stream: WritableStream<Uint8Array>, accumulator: Functional<E, Uint8Array>): Promise<void>;
|
|
184
|
-
}
|
|
185
|
-
export declare class UnorderedCollectable<E> extends Collectable<E> {
|
|
186
|
-
protected generator: Generator<E>;
|
|
187
|
-
constructor(generator: Generator<E>);
|
|
188
|
-
source(): Generator<E>;
|
|
189
|
-
}
|
|
190
|
-
type Indexed<K, V> = {
|
|
191
|
-
index: K;
|
|
192
|
-
value: V;
|
|
193
|
-
};
|
|
194
|
-
export declare class OrderedCollectable<E> extends Collectable<E> {
|
|
195
|
-
protected ordered: Array<Indexed<bigint, E>>;
|
|
196
|
-
constructor(iterable: Iterable<E>);
|
|
197
|
-
constructor(iterable: Iterable<E>, comparator: Comparator<E>);
|
|
198
|
-
constructor(generator: Generator<E>);
|
|
199
|
-
constructor(generator: Generator<E>, comparator: Comparator<E>);
|
|
200
|
-
source(): Generator<E> | Iterable<E>;
|
|
201
|
-
}
|
|
202
|
-
export declare class WindowCollectable<E> extends OrderedCollectable<E> {
|
|
203
|
-
constructor(iterable: Iterable<E>);
|
|
204
|
-
constructor(iterable: Iterable<E>, comparator: Comparator<E>);
|
|
205
|
-
constructor(generator: Generator<E>);
|
|
206
|
-
constructor(generator: Generator<E>, comparator: Comparator<E>);
|
|
207
|
-
slide(size: bigint, step?: bigint): Semantic<Semantic<E>>;
|
|
208
|
-
tumble(size: bigint): Semantic<Semantic<E>>;
|
|
209
|
-
}
|
|
210
|
-
export declare abstract class Statistics<E, D extends number | bigint> extends OrderedCollectable<E> {
|
|
211
|
-
constructor(iterable: Iterable<E>);
|
|
212
|
-
constructor(iterable: Iterable<E>, comparator: Comparator<E>);
|
|
213
|
-
constructor(generator: Generator<E>);
|
|
214
|
-
constructor(generator: Generator<E>, comparator: Comparator<E>);
|
|
215
|
-
count(): bigint;
|
|
216
|
-
maximum(): Optional<E>;
|
|
217
|
-
maximum(comparator: Comparator<E>): Optional<E>;
|
|
218
|
-
minimum(): Optional<E>;
|
|
219
|
-
minimum(comparator: Comparator<E>): Optional<E>;
|
|
220
|
-
abstract range(): D;
|
|
221
|
-
abstract range(mapper: Functional<E, D>): D;
|
|
222
|
-
abstract variance(): D;
|
|
223
|
-
abstract variance(mapper: Functional<E, D>): D;
|
|
224
|
-
abstract standardDeviation(): D;
|
|
225
|
-
abstract standardDeviation(mapper: Functional<E, D>): D;
|
|
226
|
-
abstract mean(): D;
|
|
227
|
-
abstract mean(mapper: Functional<E, D>): D;
|
|
228
|
-
abstract median(): D;
|
|
229
|
-
abstract median(mapper: Functional<E, D>): D;
|
|
230
|
-
abstract mode(): D;
|
|
231
|
-
abstract mode(mapper: Functional<E, D>): D;
|
|
232
|
-
abstract frequency(): Map<D, bigint>;
|
|
233
|
-
abstract frequency(mapper: Functional<E, D>): Map<D, bigint>;
|
|
234
|
-
abstract summate(): D;
|
|
235
|
-
abstract summate(mapper: Functional<E, D>): D;
|
|
236
|
-
abstract quantile(quantile: number): D;
|
|
237
|
-
abstract quantile(quantile: number, mapper: Functional<E, D>): D;
|
|
238
|
-
abstract interquartileRange(): D;
|
|
239
|
-
abstract interquartileRange(mapper: Functional<E, D>): D;
|
|
240
|
-
abstract skewness(): D;
|
|
241
|
-
abstract skewness(mapper: Functional<E, D>): D;
|
|
242
|
-
abstract kurtosis(): D;
|
|
243
|
-
abstract kurtosis(mapper: Functional<E, D>): D;
|
|
244
|
-
}
|
|
245
|
-
export declare class NumericStatistics<E> extends Statistics<E, number> {
|
|
246
|
-
constructor(iterable: Iterable<E>);
|
|
247
|
-
constructor(iterable: Iterable<E>, comparator: Comparator<E>);
|
|
248
|
-
constructor(generator: Generator<E>);
|
|
249
|
-
constructor(generator: Generator<E>, comparator: Comparator<E>);
|
|
250
|
-
range(): number;
|
|
251
|
-
range(mapper: Functional<E, number>): number;
|
|
252
|
-
variance(): number;
|
|
253
|
-
variance(mapper: Functional<E, number>): number;
|
|
254
|
-
standardDeviation(): number;
|
|
255
|
-
standardDeviation(mapper: Functional<E, number>): number;
|
|
256
|
-
mean(): number;
|
|
257
|
-
mean(mapper: Functional<E, number>): number;
|
|
258
|
-
median(): number;
|
|
259
|
-
median(mapper: Functional<E, number>): number;
|
|
260
|
-
mode(): number;
|
|
261
|
-
mode(mapper: Functional<E, number>): number;
|
|
262
|
-
frequency(): Map<number, bigint>;
|
|
263
|
-
frequency(mapper: Functional<E, number>): Map<number, bigint>;
|
|
264
|
-
summate(): number;
|
|
265
|
-
summate(mapper: Functional<E, number>): number;
|
|
266
|
-
quantile(quantile: number): number;
|
|
267
|
-
quantile(quantile: number, mapper: Functional<E, number>): number;
|
|
268
|
-
interquartileRange(): number;
|
|
269
|
-
interquartileRange(mapper: Functional<E, number>): number;
|
|
270
|
-
skewness(): number;
|
|
271
|
-
skewness(mapper: Functional<E, number>): number;
|
|
272
|
-
kurtosis(): number;
|
|
273
|
-
kurtosis(mapper: Functional<E, number>): number;
|
|
274
|
-
}
|
|
275
|
-
export declare class BigIntStatistics<E> extends Statistics<E, bigint> {
|
|
276
|
-
constructor(iterable: Iterable<E>);
|
|
277
|
-
constructor(iterable: Iterable<E>, comparator: Comparator<E>);
|
|
278
|
-
constructor(generator: Generator<E>);
|
|
279
|
-
constructor(generator: Generator<E>, comparator: Comparator<E>);
|
|
280
|
-
range(): bigint;
|
|
281
|
-
range(mapper: Functional<E, bigint>): bigint;
|
|
282
|
-
variance(): bigint;
|
|
283
|
-
variance(mapper: Functional<E, bigint>): bigint;
|
|
284
|
-
standardDeviation(): bigint;
|
|
285
|
-
standardDeviation(mapper: Functional<E, bigint>): bigint;
|
|
286
|
-
mean(): bigint;
|
|
287
|
-
mean(mapper: Functional<E, bigint>): bigint;
|
|
288
|
-
median(): bigint;
|
|
289
|
-
median(mapper: Functional<E, bigint>): bigint;
|
|
290
|
-
mode(): bigint;
|
|
291
|
-
mode(mapper: Functional<E, bigint>): bigint;
|
|
292
|
-
frequency(): Map<bigint, bigint>;
|
|
293
|
-
frequency(mapper: Functional<E, bigint>): Map<bigint, bigint>;
|
|
294
|
-
summate(): bigint;
|
|
295
|
-
summate(mapper: Functional<E, bigint>): bigint;
|
|
296
|
-
quantile(quantile: number): bigint;
|
|
297
|
-
quantile(quantile: number, mapper: Functional<E, bigint>): bigint;
|
|
298
|
-
interquartileRange(): bigint;
|
|
299
|
-
interquartileRange(mapper: Functional<E, bigint>): bigint;
|
|
300
|
-
skewness(): bigint;
|
|
301
|
-
skewness(mapper: Functional<E, bigint>): bigint;
|
|
302
|
-
kurtosis(): bigint;
|
|
303
|
-
kurtosis(mapper: Functional<E, bigint>): bigint;
|
|
304
|
-
}
|
|
305
|
-
export {};
|