@gershy/clearing 0.0.2 → 0.0.3

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/src/global.d.ts DELETED
@@ -1,197 +0,0 @@
1
- // Util
2
- type fn = (...args: any[]) => any;
3
- type obj = { [key: string]: any };
4
- type maybeFn<T> = T | ((...args: any[]) => T);
5
- type maybeFnResolved<T> = T extends (...args: any[]) => any ? ReturnType<T> : T;
6
- type MaybePromise<T> = T | Promise<T>;
7
-
8
- // Forms
9
- type formConfig = {
10
- name: string,
11
- has: { [key: string]: any },
12
- props: { [key: string]: any }
13
- };
14
- type Form<props extends {}, initArgs extends any[], state extends {}> = {
15
- '~props': maybeFnResolved<props>,
16
- '~initArgs': initArgs,
17
- '~state': state,
18
- (...a: initArgs): formInstance<Form<props, initArgs, state>>,
19
- new (...a: initArgs): formInstance<Form<props, initArgs, state>>
20
- };
21
- type formInstance<MyForm extends Form> = { '~form': MyForm }
22
- & { [ key in keyof MyForm['~props'] ]: MyForm['~props'][key] }
23
- & { [ key in keyof MyForm['~state'] ]: MyForm['~state'][key] };
24
-
25
- // Globals
26
- declare const global: any;
27
- declare const window: any;
28
- declare const getFormName: (f: any) => string;
29
- declare const denumerate: (val: any, name: string) => void;
30
- declare const skip: never;
31
- declare const isForm: {
32
- (val: any, arr: FunctionConstructor): val is fn;
33
- (val: any, obj: ObjectConstructor): val is { [key: string]: any };
34
- (val: any, str: StringConstructor): val is string;
35
- (val: any, num: NumberConstructor): val is number;
36
- (val: any, arr: ArrayConstructor): val is any[];
37
- <T>(val: any, prm: PromiseConstructor): val is Promise<T>;
38
- <T>(val: any, t: T): val is T;
39
- }
40
- declare const hasForm: {
41
- (val: any, t: any): boolean;
42
- }
43
- declare const form: <initArgs extends any[], state extends {}>(c: formConfig) => Form<formConfig['props'], initArgs, state>;
44
- declare const formatAnyValue: (val: any) => string;
45
- declare const C: {
46
- def: fn
47
- };
48
- declare const getMs: () => number;
49
- declare const getDate: () => string;
50
- declare const then: (val: any, resolve: fn, reject?: fn) => any;
51
- declare const valToJson: (val: any) => string;
52
- declare const valToSer: (val: any) => string;
53
- declare const jsonToVal: (val: string | Buffer | null) => any;
54
- declare const GeneratorFunction: any;
55
- declare const global: { [key: string|symbol]: any } & {
56
- skip: typeof skip,
57
- GeneratorFunction: typeof GeneratorFunction,
58
- isForm: typeof isForm,
59
- hasForm: typeof hasForm,
60
- formatAnyValue: typeof formatAnyValue,
61
- then: typeof then,
62
- getMs: typeof getMs,
63
- getDate: typeof getDate,
64
- valToJson: typeof valToJson,
65
- jsonToVal: typeof jsonToVal,
66
- C: typeof C,
67
- denumerate: typeof denumerate
68
- };
69
-
70
- interface JSON {
71
- parse: (val: Buffer) => any
72
- }
73
-
74
- interface Array<T> {
75
- any: (fn: fn) => boolean,
76
- has: (val: T) => boolean,
77
- add: (val: T) => void,
78
- count: () => number,
79
- valSort: (fn: (val: T) => number) => Array<T>,
80
- find: (fn: fn) => ({ found: true, val: T } | { found: false }),
81
- each: (fn: (val: T) => void) => void,
82
- empty: () => boolean,
83
- equals: <Z>(arr: Array<T>) => Z extends T ? boolean : false,
84
- toObj: (fn: fn) => any,
85
- seek: (fn: (val: T) => any) => { found: boolean, val: T | undefined, ind: number },
86
- }
87
- interface ArrayConstructor {
88
- stub: any[]
89
- }
90
-
91
- interface Error {
92
- mod: (props: { [key: string]: any }) => Error
93
- propagate: (props?: { [key: string]: any }) => never
94
- }
95
-
96
- interface FunctionConstructor {
97
- stub: (...args: any[]) => any
98
- }
99
- interface Function {
100
- bound: fn
101
- }
102
-
103
- interface GeneratorFunctionConstructor {
104
- }
105
-
106
- interface Number {
107
- encodeStr: (str: string | CharSet, len?: number) => string,
108
- each: (fn: (n: number) => void) => void,
109
- toArr: <T>(fn: (n: number) => T) => T[]
110
- }
111
- interface NumberConstructor {
112
- int32: number
113
- }
114
-
115
- interface BigInt {
116
- encodeStr: Number[encodeStr]
117
- }
118
-
119
- interface ObjectConstructor {
120
- }
121
- interface Object {
122
- empty: () => boolean,
123
- has: (k: string) => boolean,
124
- map: (fn: (val: any, key: string) => any) => any,
125
- mapk: (fn: (val: any, key: string) => [ string, any ]) => any,
126
- at: (k: string | string[], def?: any) => any,
127
- plain: (obj?: any) => any,
128
- slice: <T>(this: T, keys: (keyof T)[]) => Partial<T>,
129
- omit: <T>(this: T, keys: (keyof T)[]) => Partial<T>,
130
- toArr: <T extends (v: any, k: string) => any>(fn: T) => ReturnType<T>[],
131
- built: () => Object,
132
- merge: <T>(val: T) => Object & T,
133
- gain: (...args: any[]) => any,
134
- [Symbol.iterator]: () => Iterator<[ string, any]>
135
- }
136
-
137
- interface Promise<T> {
138
- fail: Promise<T>['catch'],
139
- }
140
-
141
- interface PromiseLater<T=void> extends Promise<T> {
142
- resolve: T extends void ? () => void : (v: T) => void,
143
- reject: (err: any) => void
144
- }
145
- interface PromiseConstructor {
146
- <T>(fn: (resolve: (v: T) => void, reject: (err: any) => void) => any): Promise<T>,
147
- later: <T=void>() => PromiseLater<T>,
148
- all: {
149
- <T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
150
-
151
- //<T>(arr: Promise<T>[]): Promise<T[]>,
152
- //<T>(obj: { [key: string]: Promise<T> }): Promise<{ [key: string]: T }>
153
- }
154
- }
155
-
156
- interface SetConstructor {
157
- <T>(arr?: T[]): Set<T>
158
- }
159
- interface Set<T> {
160
- toArr: (fn: (val: T, ind: number) => void) => T[],
161
- rem: (val: T) => void
162
- }
163
-
164
- interface MapConstructor {
165
- <K, V>(arr?: [ K, V ][]): Map<K, V>
166
- }
167
- interface Map<K, V> {
168
- add: (k: K, v: V) => void,
169
- toArr: <T>(fn: (val: V, key: K) => T) => T[],
170
- rem: (key: K) => void
171
- }
172
-
173
- type CharSet = { str: string, size: bigint, charVal: (c: string) => bigint, valChar: (n: bigint) => string };
174
- interface String {
175
- count(): number,
176
- padHead(n: number, s?: string): string,
177
- padTail(n: number, s?: string): string,
178
- encodeInt: (chrs: string | CharSet) => bigint,
179
- reencode: (src: string | CharSet, trg: string | CharSet) => string,
180
- trimHead(): string,
181
- trimTail(): string,
182
- hasHead(head: string): boolean,
183
- upper(): string,
184
- lower(): string,
185
- cut(str: string, cuts?: number): string[],
186
- indent: {
187
- (amount: number, char?: string): string,
188
- (str: string): string
189
- }
190
- }
191
- interface StringConstructor {
192
- charset: (str: string) => CharSet,
193
- base32: string,
194
- base62: string,
195
- baseline: (str: string) => str,
196
- multiline: (str: string) => str,
197
- }