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