@gershy/clearing 0.0.6 → 0.0.7
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/cmp/cjs/main.js +293 -357
- package/cmp/mjs/main.js +293 -357
- package/cmp/types/global.d.ts +135 -232
- package/license +15 -0
- package/package.json +7 -3
- package/readme.md +784 -1
package/cmp/types/global.d.ts
CHANGED
|
@@ -4,190 +4,115 @@ declare global {
|
|
|
4
4
|
type Fn<A=any[], T=any> = (...args: A) => T;
|
|
5
5
|
type Obj<V = any> = { [typeof iden]: 'obj' } & { [k: string]: V };
|
|
6
6
|
|
|
7
|
+
// Differentiate between "map" and "rec" ("record") - maps have arbitrary keys; recs have fixed keys
|
|
7
8
|
type ObjMode<O extends { [K: string]: any }> = O extends { [K in infer KK]: any } ? (string extends KK ? 'map' : 'rec') : never;
|
|
8
|
-
type ObjKeys<O extends Obj> = Extract<keyof O, string
|
|
9
|
+
type ObjKeys<O extends Obj> = Extract<keyof O, string> | `${Extract<keyof O, number>}`; // Convert numbers to strings; ignores symbols
|
|
9
10
|
type ObjVals<O extends Obj> = O[Extract<keyof O, string>];
|
|
10
|
-
|
|
11
|
-
type MaybeFn<T> = T | ((...args: any[]) => T);
|
|
12
|
-
type ResolveFn<T> = T extends ((...args: any[]) => any) ? ReturnType<T> : T;
|
|
11
|
+
|
|
13
12
|
type Itr<O extends Obj> = Iterable<[ ObjKeys<O>, ObjVals<O> ]>;
|
|
14
13
|
type Json = null | boolean | number | string | Json[] | { [K: string]: Json };
|
|
15
14
|
type Skip = undefined;
|
|
16
15
|
type SkipNever<V> = V extends Skip ? Skip extends V ? never : V : V; // 0 extends (1 & T) ? any : V extends Skip ? Skip extends V ? never : V : V; // Only thing that doesn't work is `SkipNever<any>`
|
|
17
|
-
type Endable = { end: () => MaybePromise<unknown> };
|
|
18
|
-
type Callable = ((...args: any[]) => any) | { new (...args: any): any };
|
|
19
|
-
type SovereignFn<T extends Callable = Callable> = T; // & { _svrn: 1 };
|
|
20
|
-
type Assign<A, B> = Omit<A, keyof B> & B;
|
|
21
16
|
type UGH = any; // Use when necessary to escape typing because typescript has failed us
|
|
22
17
|
|
|
23
18
|
type Dive<O extends Obj, K extends readonly string[], D = undefined> =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: Dive<O[K0], KM, D>
|
|
30
|
-
)
|
|
31
|
-
: D
|
|
32
|
-
: never
|
|
33
|
-
|
|
34
|
-
// Function args have reversed assignability from typical inheritance; they are the key for
|
|
35
|
-
// converting a union to an intersection: https://stackoverflow.com/a/50375286/830905
|
|
36
|
-
// // type Combine<U> =
|
|
37
|
-
// // (U extends any ? (x: U) => void : never) extends (x: infer I) => void
|
|
38
|
-
// // ? I
|
|
39
|
-
// // : never;
|
|
40
|
-
// type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
|
|
41
|
-
// type Combine<Union> = Expand<(Union extends any ? (x: Union) => void : never) extends (x: infer Combined) => void ? Combined : never>;
|
|
42
|
-
// // type Combine0 = { a: number, b?: string } | { a?: number, b: string };
|
|
43
|
-
// type Combine1 = Combine<Combine0>;
|
|
19
|
+
K extends [ infer K0, ...infer KM ]
|
|
20
|
+
? K0 extends keyof O
|
|
21
|
+
? (ObjMode<O> extends 'map' ? D : never) | Dive<O[K0], KM, D>
|
|
22
|
+
: D
|
|
23
|
+
: O; // If `K` doesn't extend an array with a single item, it's an empty array - so use the current value
|
|
44
24
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// the stringified values with `eval`. Of course, these functions should only be used with trusted
|
|
51
|
-
// data!
|
|
52
|
-
type Hoist = `<repo>/${string}` | `@aws/${string}`; // TODO: More imports??
|
|
53
|
-
type JsfnInst<Cls extends { new (...args: any[]): any }> = { // "jsfn instance"
|
|
54
|
-
hoist: `${Hoist}::${string}`,
|
|
55
|
-
form: Cls,
|
|
56
|
-
args: ConstructorParameters<Cls> & Jsfn
|
|
25
|
+
type CharSet = {
|
|
26
|
+
str: string,
|
|
27
|
+
size: bigint,
|
|
28
|
+
charVal: (c: string) => bigint,
|
|
29
|
+
valChar: (n: bigint) => string
|
|
57
30
|
};
|
|
58
|
-
|
|
59
|
-
type Jsfn = null | boolean | number | string | SovereignFn | JsfnInst<any> | Jsfn[] | { [K: string]: Jsfn };
|
|
60
|
-
type JsfnDecoded<T extends Jsfn, N extends string = ''> =
|
|
61
|
-
N extends '+++++'
|
|
62
|
-
? '<TOO DEEP>'
|
|
63
|
-
: T extends null
|
|
64
|
-
? T
|
|
65
|
-
: T extends boolean
|
|
66
|
-
? T
|
|
67
|
-
: T extends number
|
|
68
|
-
? T
|
|
69
|
-
: T extends string
|
|
70
|
-
? T
|
|
71
|
-
: T extends SovereignFn<infer Fn>
|
|
72
|
-
? Fn
|
|
73
|
-
: T extends JsfnInst<any>
|
|
74
|
-
? InstanceType<T['form']>
|
|
75
|
-
: T extends { [K: string]: Jsfn }
|
|
76
|
-
? { [K in keyof T]: T[K] extends Jsfn ? JsfnDecoded<T[K], `+${N}`> : never }
|
|
77
|
-
: T extends Jsfn[]
|
|
78
|
-
? { [K in keyof T]: T[K] extends Jsfn ? JsfnDecoded<T[K], `+${N}`> : never }
|
|
79
|
-
: Jsfn;
|
|
80
|
-
|
|
81
|
-
type JsfnEncoded<T extends Jsfn> = string & { _jsfn: T };
|
|
82
|
-
|
|
83
|
-
type ObjLeafs<O> = O extends Obj ? { [K in keyof O]: ObjLeafs<O[K]> }[keyof O] : O;
|
|
84
|
-
// type ObjLeafs0 = ObjLeafs<{ a: string, b: { c: number }, d: null, e: { f: { g: undefined } } }>;
|
|
85
|
-
|
|
86
|
-
type CharSet = { str: string, size: bigint, charVal: (c: string) => bigint, valChar: (n: bigint) => string };
|
|
87
31
|
|
|
88
32
|
type MaybePromise<T> = T | Promise<T>;
|
|
89
33
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const hasForm: typeof hasForm;
|
|
102
|
-
|
|
103
|
-
// Utility
|
|
104
|
-
const sovereign: <Fn extends (...args: any) => any>(val: Fn) => Fn & { _svrn: 1 };
|
|
105
|
-
const then: <V, G, B = never>(val: MaybePromise<V>, resolve: (val: V) => G, reject?: (err: any) => B) => MaybePromise<G | B>;
|
|
106
|
-
const safe: <V, G, B = never>(fn: () => MaybePromise<V>, resolve: (val: V) => G, reject?: (err: any) => B) => MaybePromise<G | B>;
|
|
107
|
-
|
|
108
|
-
// Forms
|
|
109
|
-
const isForm: {
|
|
110
|
-
(val: unknown, num: BooleanConstructor): val is boolean,
|
|
111
|
-
(val: unknown, num: NumberConstructor): val is number,
|
|
112
|
-
(val: unknown, str: StringConstructor): val is string,
|
|
113
|
-
(val: unknown, buff: BufferConstructor): val is Buffer,
|
|
114
|
-
(val: unknown, arr: ArrayConstructor): val is any[],
|
|
115
|
-
(val: unknown, obj: ObjectConstructor): val is Obj<unknown>,
|
|
116
|
-
(val: unknown, fn: FunctionConstructor): val is Fn,
|
|
117
|
-
(val: unknown, fn: SymbolConstructor): val is symbol,
|
|
118
|
-
<T>(val: unknown, prm: PromiseConstructor): val is Promise<T>,
|
|
119
|
-
<C>(val: unknown, cls: C): val is InstanceType<C>
|
|
120
|
-
};
|
|
121
|
-
const getForm: {
|
|
122
|
-
(val: number): NumberConstructor,
|
|
123
|
-
(val: string): StringConstructor,
|
|
124
|
-
(val: Buffer): BufferConstructor,
|
|
125
|
-
(val: any[]): ArrayConstructor,
|
|
126
|
-
(val: { [K: string]: any }): ObjectConstructor,
|
|
127
|
-
(val: (...a: any[]) => any): FunctionConstructor,
|
|
128
|
-
(val: Promise<any>): PromiseConstructor,
|
|
129
|
-
<T>(val: T): { new (...args: any[]): T }
|
|
34
|
+
type ClsCheck = {
|
|
35
|
+
(i: unknown, num: BooleanConstructor): i is boolean,
|
|
36
|
+
(i: unknown, num: NumberConstructor): i is number,
|
|
37
|
+
(i: unknown, str: StringConstructor): i is string,
|
|
38
|
+
(i: unknown, buff: BufferConstructor): i is Buffer,
|
|
39
|
+
(i: unknown, arr: ArrayConstructor): i is any[],
|
|
40
|
+
(i: unknown, obj: ObjectConstructor): i is Obj<unknown>,
|
|
41
|
+
(i: unknown, fn: FunctionConstructor): i is Fn,
|
|
42
|
+
(i: unknown, fn: SymbolConstructor): i is symbol,
|
|
43
|
+
<T>(i: unknown, prm: PromiseConstructor): i is Promise<T>,
|
|
44
|
+
<C>(i: unknown, cls: C): i is InstanceType<C>
|
|
130
45
|
};
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
>
|
|
46
|
+
const clearing: {
|
|
47
|
+
|
|
48
|
+
getClsName: (i: any) => string,
|
|
49
|
+
getCls: {
|
|
50
|
+
(i: number): NumberConstructor,
|
|
51
|
+
(i: string): StringConstructor,
|
|
52
|
+
(i: Buffer): BufferConstructor,
|
|
53
|
+
(i: any[]): ArrayConstructor,
|
|
54
|
+
(i: { [K: string]: any }): ObjectConstructor,
|
|
55
|
+
(i: (...a: any[]) => any): FunctionConstructor,
|
|
56
|
+
(i: Promise<any>): PromiseConstructor,
|
|
57
|
+
<T>(i: T): { new (...args: any[]): T }
|
|
58
|
+
},
|
|
59
|
+
isCls: ClsCheck,
|
|
60
|
+
inCls: ClsCheck,
|
|
61
|
+
|
|
62
|
+
skip: Skip
|
|
63
|
+
|
|
150
64
|
};
|
|
151
65
|
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
66
|
+
// <SYMBOLS>
|
|
67
|
+
const add: unique symbol;
|
|
68
|
+
const allArr: unique symbol;
|
|
69
|
+
const allObj: unique symbol;
|
|
70
|
+
const at: unique symbol;
|
|
71
|
+
const assert: unique symbol;
|
|
72
|
+
const base32: unique symbol;
|
|
73
|
+
const base36: unique symbol;
|
|
74
|
+
const base62: unique symbol;
|
|
75
|
+
const base64Std: unique symbol;
|
|
76
|
+
const base64Url: unique symbol;
|
|
77
|
+
const baseline: unique symbol;
|
|
78
|
+
const bind: unique symbol;
|
|
79
|
+
const bits: unique symbol;
|
|
80
|
+
const char: unique symbol;
|
|
81
|
+
const charset: unique symbol;
|
|
82
|
+
const code: unique symbol;
|
|
83
|
+
const count: unique symbol;
|
|
84
|
+
const cut: unique symbol;
|
|
85
|
+
const dive: unique symbol;
|
|
86
|
+
const empty: unique symbol;
|
|
87
|
+
const find: unique symbol;
|
|
88
|
+
const fire: unique symbol;
|
|
89
|
+
const group: unique symbol;
|
|
90
|
+
const has: unique symbol;
|
|
91
|
+
const hasHead: unique symbol;
|
|
92
|
+
const hasTail: unique symbol;
|
|
93
|
+
const indent: unique symbol;
|
|
94
|
+
const int32: unique symbol;
|
|
95
|
+
const int64: unique symbol;
|
|
96
|
+
const isInt: unique symbol;
|
|
97
|
+
const later: unique symbol;
|
|
98
|
+
const limn: unique symbol;
|
|
99
|
+
const lower: unique symbol;
|
|
100
|
+
const map: unique symbol;
|
|
101
|
+
const mapk: unique symbol;
|
|
102
|
+
const merge: unique symbol;
|
|
103
|
+
const mod: unique symbol;
|
|
104
|
+
const padHead: unique symbol;
|
|
105
|
+
const padTail: unique symbol;
|
|
106
|
+
const rem: unique symbol;
|
|
107
|
+
const slash: unique symbol;
|
|
108
|
+
const slice: unique symbol;
|
|
109
|
+
const suppress: unique symbol;
|
|
110
|
+
const toArr: unique symbol;
|
|
111
|
+
const toNum: unique symbol;
|
|
112
|
+
const toObj: unique symbol;
|
|
113
|
+
const toStr: unique symbol;
|
|
114
|
+
const upper: unique symbol;
|
|
115
|
+
// </SYMBOLS>
|
|
191
116
|
|
|
192
117
|
// Typing only
|
|
193
118
|
const iden: unique symbol; // associate types with their *direct* constructor
|
|
@@ -197,10 +122,8 @@ declare global {
|
|
|
197
122
|
interface ProtoWithSymbols {
|
|
198
123
|
[add]: undefined
|
|
199
124
|
[at]: undefined
|
|
200
|
-
[apart]: undefined
|
|
201
125
|
[assert]: undefined
|
|
202
126
|
[bind]: undefined
|
|
203
|
-
[built]: undefined
|
|
204
127
|
[count]: undefined
|
|
205
128
|
[cut]: undefined
|
|
206
129
|
[dive]: undefined
|
|
@@ -232,9 +155,7 @@ declare global {
|
|
|
232
155
|
};
|
|
233
156
|
|
|
234
157
|
interface ErrorConstructor {
|
|
235
|
-
assert:
|
|
236
|
-
<R, V = any>(args: V, fn: (args: V) => boolean): asserts args is R,
|
|
237
|
-
}
|
|
158
|
+
[assert]: <V = any>(args: V, fn: (args: V) => boolean) => void
|
|
238
159
|
};
|
|
239
160
|
interface Error extends ProtoWithSymbols {
|
|
240
161
|
[mod]: (props: { [K: string]: any }) => Error,
|
|
@@ -249,9 +170,7 @@ declare global {
|
|
|
249
170
|
})
|
|
250
171
|
};
|
|
251
172
|
|
|
252
|
-
interface ArrayConstructor {
|
|
253
|
-
stub: any[]
|
|
254
|
-
};
|
|
173
|
+
interface ArrayConstructor {};
|
|
255
174
|
interface Array<T> extends ProtoWithSymbols {
|
|
256
175
|
[iden]: 'arr',
|
|
257
176
|
[has]: (val: unknown) => boolean,
|
|
@@ -262,50 +181,42 @@ declare global {
|
|
|
262
181
|
fn: Fn
|
|
263
182
|
): Exclude<ReturnType<Fn>, Skip>[]
|
|
264
183
|
},
|
|
265
|
-
[add]: <TT extends T>(val: TT) =>
|
|
184
|
+
[add]: <TT extends T>(val: TT) => TT,
|
|
266
185
|
[rem]: <TT extends T>(val: TT) => void,
|
|
267
186
|
[count]: () => number,
|
|
268
187
|
[empty]: (this: any[]) => this is never[],
|
|
269
188
|
[toObj]: <Fn extends (v: T, n: number) => Skip | readonly [string, any], R = Exclude<ReturnType<Fn>, Skip>>(fn: Fn) => { [K in R[0]]: R[1] },
|
|
270
189
|
[find]: (fn: (val: T, n: number) => any) => ({ found: true, val: T, ind: number } | { found: false, val: null, ind: null }),
|
|
271
|
-
[group]: <G extends string>(fn: (v: T) => G) => { [K in G]?: T[] }
|
|
190
|
+
[group]: <G extends string>(fn: (v: T) => Skip | G) => { [K in G]?: T[] }
|
|
272
191
|
};
|
|
273
192
|
|
|
274
|
-
interface FunctionConstructor {
|
|
275
|
-
stub: <T>(a: T, ...args: any[]) => T
|
|
276
|
-
};
|
|
193
|
+
interface FunctionConstructor {};
|
|
277
194
|
interface Function extends ProtoWithSymbols {
|
|
278
195
|
[iden]: 'fnc',
|
|
279
196
|
[bind]: {
|
|
280
197
|
<
|
|
281
|
-
Fn extends (
|
|
198
|
+
Fn extends (...args: any[]) => any,
|
|
282
199
|
To
|
|
283
200
|
>(
|
|
284
201
|
this: Fn,
|
|
285
202
|
to: To
|
|
286
|
-
): ((
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
interface GeneratorFunctionConstructor {};
|
|
291
|
-
interface Generator<T> extends ProtoWithSymbols {
|
|
292
|
-
[toArr]: {
|
|
293
|
-
<
|
|
294
|
-
Fn extends (v: T) => any
|
|
295
|
-
>(
|
|
296
|
-
fn: Fn
|
|
297
|
-
):
|
|
298
|
-
ReturnType<Fn>[],
|
|
203
|
+
): ((...args: Parameters<Fn> extends [ infer A0, ...infer AM ] ? AM : never) => ReturnType<Fn>)
|
|
299
204
|
}
|
|
300
205
|
};
|
|
301
206
|
|
|
302
207
|
interface NumberConstructor {
|
|
303
|
-
int32: number
|
|
208
|
+
[int32]: number,
|
|
209
|
+
[int64]: number
|
|
304
210
|
};
|
|
305
211
|
interface Number extends ProtoWithSymbols {
|
|
306
212
|
[iden]: 'num',
|
|
213
|
+
[char]: () => string,
|
|
214
|
+
[isInt]: () => boolean,
|
|
307
215
|
[toStr]: (str: string | CharSet, len?: number) => string,
|
|
308
216
|
[toArr]: <T>(fn: (n: number) => T) => T[],
|
|
217
|
+
[toObj]: <Fn extends (n: number) => Skip | readonly [string, any], R = Exclude<ReturnType<Fn>, Skip>>(fn: Fn) => { [K in R[0]]: R[1] },
|
|
218
|
+
[bits]: () => Generator<number>,
|
|
219
|
+
[Symbol.iterator]: () => Generator<number>,
|
|
309
220
|
[map]: undefined // Prevent calling `map` on `Number` - use `toStr` instead!
|
|
310
221
|
};
|
|
311
222
|
|
|
@@ -314,10 +225,7 @@ declare global {
|
|
|
314
225
|
[toStr]: (str: string | CharSet, len?: number) => string
|
|
315
226
|
};
|
|
316
227
|
|
|
317
|
-
interface ObjectConstructor {
|
|
318
|
-
plain: (obj?: any) => any,
|
|
319
|
-
};
|
|
320
|
-
|
|
228
|
+
interface ObjectConstructor {};
|
|
321
229
|
interface Object extends ProtoWithSymbols {
|
|
322
230
|
[iden]: 'obj',
|
|
323
231
|
[empty]: {
|
|
@@ -337,7 +245,7 @@ declare global {
|
|
|
337
245
|
D extends any = undefined
|
|
338
246
|
>(
|
|
339
247
|
this: O,
|
|
340
|
-
k:
|
|
248
|
+
k: K,
|
|
341
249
|
def?: D
|
|
342
250
|
): Dive<O, K extends string[] ? K : [ K ], D>,
|
|
343
251
|
},
|
|
@@ -399,20 +307,12 @@ declare global {
|
|
|
399
307
|
fn: Fn
|
|
400
308
|
): Exclude<ReturnType<Fn>, Skip>[],
|
|
401
309
|
},
|
|
402
|
-
[built]: {
|
|
403
|
-
(this: Obj<any>): any
|
|
404
|
-
// <O extends Obj>(this: O): Obj<ObjLeafs<O>>,
|
|
405
|
-
},
|
|
406
|
-
[apart]: {
|
|
407
|
-
// Iterates all terminal values in an object tree, along with the dive key needed to access them
|
|
408
|
-
<O extends Obj>(this: O): Generator<{ dive: string[], val: any }>,
|
|
409
|
-
},
|
|
410
|
-
[dive]: {
|
|
411
|
-
<O extends Obj, Cmps extends (keyof any)[], D extends any = Skip>(this: O, cmps: readonly Cmps, def: D): Dive<O, Cmps> | D,
|
|
412
|
-
},
|
|
413
310
|
[count]: {
|
|
414
311
|
<O extends Obj>(this: O): number,
|
|
415
312
|
},
|
|
313
|
+
[group]: {
|
|
314
|
+
<O extends Obj, G extends string>(fn: (v: T) => Skip | G): { [K in G]?: Optional<O> }
|
|
315
|
+
},
|
|
416
316
|
[Symbol.iterator]: {
|
|
417
317
|
<O extends Obj>(this: O): Iterator<[ ObjKeys<O>, ObjVals<O> ]>
|
|
418
318
|
},
|
|
@@ -420,10 +320,9 @@ declare global {
|
|
|
420
320
|
};
|
|
421
321
|
|
|
422
322
|
interface PromiseConstructor {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
allObj: <O extends { [K: keyof any]: Promise<any> }>(obj: O) => { [K in keyof O]: Awaited<O[K]> }
|
|
323
|
+
[allArr]: PromiseConstructor['all'],
|
|
324
|
+
[allObj]: <O extends { [K: keyof any]: Promise<any> }>(obj: O) => { [K in keyof O]: Awaited<O[K]> },
|
|
325
|
+
[later]: <T=void>() => PromiseLater<T>
|
|
427
326
|
};
|
|
428
327
|
interface Promise<T> {};
|
|
429
328
|
interface PromiseLater<T=void> extends Promise<T>, ProtoWithSymbols {
|
|
@@ -433,27 +332,35 @@ declare global {
|
|
|
433
332
|
|
|
434
333
|
interface SetConstructor {};
|
|
435
334
|
interface Set<T> extends ProtoWithSymbols {
|
|
436
|
-
[
|
|
335
|
+
[count]: () => number,
|
|
336
|
+
[empty]: () => boolean,
|
|
337
|
+
[find]: (fn: (val: T) => any) => ({ found: true, val: T } | { found: false, val: null }),
|
|
338
|
+
[map]: <V>(fn: (val: T, ind: number) => V) => Exclude<V, Skip>[],
|
|
339
|
+
[toArr]: <V>(fn: (val: T, ind: number) => V) => Exclude<V, Skip>[],
|
|
340
|
+
[toObj]: <Fn extends (val: T) => Skip | readonly [string, any], R = Exclude<ReturnType<Fn>, Skip>>(fn: Fn) => { [K in R[0]]: R[1] },
|
|
437
341
|
[rem]: (val: T) => void
|
|
438
342
|
};
|
|
439
|
-
|
|
440
|
-
|
|
343
|
+
|
|
441
344
|
interface MapConstructor {};
|
|
442
345
|
interface Map<K, V> extends ProtoWithSymbols {
|
|
443
346
|
[add]: (k: K, v: V) => void,
|
|
444
|
-
[
|
|
445
|
-
[
|
|
347
|
+
[count]: () => number,
|
|
348
|
+
[empty]: () => boolean,
|
|
349
|
+
[find]: (fn: (val: V, key: K) => any) => ({ found: true, val: V, key: K } | { found: false, val: null, key: null }),
|
|
350
|
+
[map]: <T>(fn: (val: V, key: K) => Skip | readonly [string, any]) => { [Key: string]: any },
|
|
351
|
+
[toArr]: <T>(fn: (val: V, key: K) => T) => Exclude<T, Skip>[],
|
|
352
|
+
[toObj]: <T>(fn: (val: V, key: K) => Skip | readonly [string, any]) => { [Key: string]: any },
|
|
446
353
|
[rem]: (key: K) => void
|
|
447
354
|
};
|
|
448
|
-
|
|
355
|
+
|
|
449
356
|
interface StringConstructor {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
357
|
+
[base32]: string,
|
|
358
|
+
[base36]: string,
|
|
359
|
+
[base62]: string,
|
|
360
|
+
[base64]: string,
|
|
361
|
+
[base64Std]: string,
|
|
362
|
+
[baseline]: (str: string) => string,
|
|
363
|
+
[charset]: (str: string) => CharSet,
|
|
457
364
|
};
|
|
458
365
|
interface String extends ProtoWithSymbols {
|
|
459
366
|
[count](): number,
|
|
@@ -482,7 +389,3 @@ declare global {
|
|
|
482
389
|
|
|
483
390
|
export {};
|
|
484
391
|
|
|
485
|
-
// Type testing - these aren't exported!
|
|
486
|
-
type Dive0 = Dive<{ a: { b: { c: 'xyz' } } }, [ 'a', 'b', 'c' ]>;
|
|
487
|
-
type Dive1 = Dive<{ a: { b: { c: 'xyz' } } }, [ 'a', 'b' ]>;
|
|
488
|
-
type Dive2 = Dive<{ a: { b: { c: 'xyz' } } }, [ 'a', 'b', 'd' ]>;
|
package/license
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gershom Maes
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gershy/clearing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Adds the features you always wish javascript had!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clearing",
|
|
@@ -29,17 +29,21 @@
|
|
|
29
29
|
"@types/node": "^24.10.1",
|
|
30
30
|
"cpx": "^1.5.0",
|
|
31
31
|
"rimraf": "^6.1.2",
|
|
32
|
+
"tsx": "^4.21.0",
|
|
32
33
|
"typescript": "^5.9.3"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"cmp"
|
|
36
37
|
],
|
|
37
38
|
"scripts": {
|
|
39
|
+
"test": "npx tsx ./src/main.test.mts",
|
|
40
|
+
"ts.check": "npx tsc --noEmit",
|
|
38
41
|
"build.cjs": "tsc -p ts/tsconfig.cjs.json",
|
|
39
42
|
"build.mjs": "tsc -p ts/tsconfig.mjs.json",
|
|
40
43
|
"build.types": "cpx src/global.d.ts cmp/types",
|
|
41
44
|
"build": "rimraf cmp && npm run build.cjs && npm run build.mjs && npm run build.types",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
45
|
+
"git.pub": "npm run test && git add --all && git commit -m \"automated\" && git push",
|
|
46
|
+
"npm.login": "npm login",
|
|
47
|
+
"npm.pub": "npm run test && npm run build && npm publish --access public"
|
|
44
48
|
}
|
|
45
49
|
}
|