@gershy/clearing 0.0.29 → 0.0.31

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.
@@ -1,8 +1,144 @@
1
- declare global {
1
+ // TODO: HEEERE add "iterate" or "walk" symbol for typed iteration
2
+
3
+ // <SYMBOLS> :: consts :: /declare[ ]const[ ]([a-zA-Z0-9]+)[:]/
4
+ declare const add: unique symbol;
5
+ declare const allArr: unique symbol;
6
+ declare const allObj: unique symbol;
7
+ declare const at: unique symbol;
8
+ declare const assert: unique symbol;
9
+ declare const base32: unique symbol;
10
+ declare const base36: unique symbol;
11
+ declare const base62: unique symbol;
12
+ declare const base64Std: unique symbol;
13
+ declare const base64Url: unique symbol;
14
+ declare const baseline: unique symbol;
15
+ declare const char: unique symbol;
16
+ declare const charset: unique symbol;
17
+ declare const code: unique symbol;
18
+ declare const count: unique symbol;
19
+ declare const cut: unique symbol;
20
+ declare const empty: unique symbol;
21
+ declare const find: unique symbol;
22
+ declare const fire: unique symbol;
23
+ declare const group: unique symbol;
24
+ declare const has: unique symbol;
25
+ declare const hasHead: unique symbol;
26
+ declare const hasTail: unique symbol;
27
+ declare const indent: unique symbol;
28
+ declare const int32: unique symbol;
29
+ declare const int64: unique symbol;
30
+ declare const isInt: unique symbol;
31
+ declare const later: unique symbol;
32
+ declare const limn: unique symbol;
33
+ declare const lower: unique symbol;
34
+ declare const map: unique symbol;
35
+ declare const mapk: unique symbol;
36
+ declare const merge: unique symbol;
37
+ declare const mod: unique symbol;
38
+ declare const padHead: unique symbol;
39
+ declare const padTail: unique symbol;
40
+ declare const rem: unique symbol;
41
+ declare const slash: unique symbol;
42
+ declare const slice: unique symbol;
43
+ declare const suppress: unique symbol;
44
+ declare const toArr: unique symbol;
45
+ declare const toBin: unique symbol;
46
+ declare const toNum: unique symbol;
47
+ declare const toObj: unique symbol;
48
+ declare const toStr: unique symbol;
49
+ declare const upper: unique symbol;
50
+ declare const walk: unique symbol;
51
+ // </SYMBOLS>
2
52
 
53
+ declare global {
54
+
55
+ const clearing: {
56
+
57
+ skip: Skip,
58
+ // isCls: ClsCheck,
59
+ // inCls: ClsCheck,
60
+ getClsName: (v: any) => string,
61
+ getCls: (v: any) => any,
62
+ then: {
63
+ <V, R0 = V, R1 = never>(val: Promise<V>, rsv?: (v: V) => R0, rjc?: (e: any) => R1): Promise<R0 | R1>,
64
+ <V, R0 = V, R1 = never>(val: V, rsv?: (v: V) => R0, rjc?: (e: any) => R1): R0 | R1;
65
+ },
66
+ safe: {
67
+ <V, R0 = never>(fn: () => Promise<V>, rjc?: (e: any) => R0): Promise<V | R0>,
68
+ <V, R0 = never>(fn: () => V, rjc?: (e: any) => R0): Promise<V | R0>
69
+ }
70
+
71
+ } & {
72
+
73
+ [K in 'isCls' | 'inCls']: {
74
+ (i: unknown, num: BooleanConstructor): i is boolean,
75
+ (i: unknown, num: NumberConstructor): i is number,
76
+ (i: unknown, str: StringConstructor): i is string,
77
+ (i: unknown, buff: Buffer): i is Buffer,
78
+ (i: unknown, arr: ArrayConstructor): i is any[],
79
+ (i: unknown, obj: ObjectConstructor): i is Obj<unknown>,
80
+ (i: unknown, fn: FunctionConstructor): i is (...args: any[]) => any,
81
+ (i: unknown, fn: SymbolConstructor): i is symbol,
82
+ <T>(i: unknown, prm: PromiseConstructor): i is Promise<T>,
83
+ <C extends abstract new (...args: any) => any>(i: unknown, cls: C): i is InstanceType<C>
84
+ }
85
+
86
+ } & {
87
+
88
+ // <SYMBOLS> :: declarations :: /^[ ]*([a-zA-Z0-9]+)[:][ ]+typeof \1/
89
+ add: typeof add, //`Symbol('@gershy/clearing:add')`,
90
+ allArr: typeof allArr, //`Symbol('@gershy/clearing:allArr')`,
91
+ allObj: typeof allObj, //`Symbol('@gershy/clearing:allObj')`,
92
+ at: typeof at, //`Symbol('@gershy/clearing:at')`,
93
+ assert: typeof assert, //`Symbol('@gershy/clearing:assert')`,
94
+ base32: typeof base32, //`Symbol('@gershy/clearing:base32')`,
95
+ base36: typeof base36, //`Symbol('@gershy/clearing:base36')`,
96
+ base62: typeof base62, //`Symbol('@gershy/clearing:base62')`,
97
+ base64Std: typeof base64Std, //`Symbol('@gershy/clearing:base64Std')`,
98
+ base64Url: typeof base64Url, //`Symbol('@gershy/clearing:base64Url')`,
99
+ baseline: typeof baseline, //`Symbol('@gershy/clearing:baseline')`,
100
+ char: typeof char, //`Symbol('@gershy/clearing:char')`,
101
+ charset: typeof charset, //`Symbol('@gershy/clearing:charset')`,
102
+ code: typeof code, //`Symbol('@gershy/clearing:code')`,
103
+ count: typeof count, //`Symbol('@gershy/clearing:count')`,
104
+ cut: typeof cut, //`Symbol('@gershy/clearing:cut')`,
105
+ empty: typeof empty, //`Symbol('@gershy/clearing:empty')`,
106
+ find: typeof find, //`Symbol('@gershy/clearing:find')`,
107
+ fire: typeof fire, //`Symbol('@gershy/clearing:fire')`,
108
+ group: typeof group, //`Symbol('@gershy/clearing:group')`,
109
+ has: typeof has, //`Symbol('@gershy/clearing:has')`,
110
+ hasHead: typeof hasHead, //`Symbol('@gershy/clearing:hasHead')`,
111
+ hasTail: typeof hasTail, //`Symbol('@gershy/clearing:hasTail')`,
112
+ indent: typeof indent, //`Symbol('@gershy/clearing:indent')`,
113
+ int32: typeof int32, //`Symbol('@gershy/clearing:int32')`,
114
+ int64: typeof int64, //`Symbol('@gershy/clearing:int64')`,
115
+ isInt: typeof isInt, //`Symbol('@gershy/clearing:isInt')`,
116
+ later: typeof later, //`Symbol('@gershy/clearing:later')`,
117
+ limn: typeof limn, //`Symbol('@gershy/clearing:limn')`,
118
+ lower: typeof lower, //`Symbol('@gershy/clearing:lower')`,
119
+ map: typeof map, //`Symbol('@gershy/clearing:map')`,
120
+ mapk: typeof mapk, //`Symbol('@gershy/clearing:mapk')`,
121
+ merge: typeof merge, //`Symbol('@gershy/clearing:merge')`,
122
+ mod: typeof mod, //`Symbol('@gershy/clearing:mod')`,
123
+ padHead: typeof padHead, //`Symbol('@gershy/clearing:padHead')`,
124
+ padTail: typeof padTail, //`Symbol('@gershy/clearing:padTail')`,
125
+ rem: typeof rem, //`Symbol('@gershy/clearing:rem')`,
126
+ slash: typeof slash, //`Symbol('@gershy/clearing:slash')`,
127
+ slice: typeof slice, //`Symbol('@gershy/clearing:slice')`,
128
+ suppress: typeof suppress, //`Symbol('@gershy/clearing:suppress')`,
129
+ toArr: typeof toArr, //`Symbol('@gershy/clearing:toArr')`,
130
+ toBin: typeof toBin, //`Symbol('@gershy/clearing:toBin')`,
131
+ toNum: typeof toNum, //`Symbol('@gershy/clearing:toNum')`,
132
+ toObj: typeof toObj, //`Symbol('@gershy/clearing:toObj')`,
133
+ toStr: typeof toStr, //`Symbol('@gershy/clearing:toStr')`,
134
+ upper: typeof upper, //`Symbol('@gershy/clearing:upper')`,
135
+ walk: typeof walk, //`Symbol('@gershy/clearing:walk')`
136
+ // </SYMBOLS>
137
+
138
+ };
139
+
3
140
  // Util
4
- type Fn<A extends any[] = any[], T = any> = (...args: A) => T;
5
- type Obj<V = any> = { [k: string]: V };
141
+ type Obj<V = any> = { [K in string]: V };
6
142
  type Arr<V = any> = V[];
7
143
 
8
144
  // Differentiate between "map" and "rec" ("record") - maps have arbitrary keys; recs have fixed keys
@@ -18,6 +154,9 @@ declare global {
18
154
  type Dive<O extends Obj, K extends readonly string[], D = undefined> =
19
155
  K extends [ infer K0 extends string, ...infer KM extends string[] ]
20
156
  ? K0 extends keyof O
157
+ // For maps, where the type implies "any string" but we know that can't be the case, add
158
+ // the default value into the union of possible results, reflecting the possibility that
159
+ // the dive key misses
21
160
  ? (ObjMode<O> extends 'map' ? D : never) | Dive<O[K0], KM, D>
22
161
  : D
23
162
  : O;
@@ -29,121 +168,69 @@ declare global {
29
168
  valChar: (n: bigint) => string
30
169
  };
31
170
 
32
- // <SYMBOLS> :: declarations :: /const ([a-zA-Z0-9]+)[ ]*[:][ ]*unique symbol;/
33
- const add: unique symbol;
34
- const allArr: unique symbol;
35
- const allObj: unique symbol;
36
- const at: unique symbol;
37
- const assert: unique symbol;
38
- const base32: unique symbol;
39
- const base36: unique symbol;
40
- const base62: unique symbol;
41
- const base64Std: unique symbol;
42
- const base64Url: unique symbol;
43
- const baseline: unique symbol;
44
- const bind: unique symbol;
45
- const char: unique symbol;
46
- const charset: unique symbol;
47
- const code: unique symbol;
48
- const count: unique symbol;
49
- const cut: unique symbol;
50
- const dive: unique symbol;
51
- const empty: unique symbol;
52
- const find: unique symbol;
53
- const fire: unique symbol;
54
- const group: unique symbol;
55
- const has: unique symbol;
56
- const hasHead: unique symbol;
57
- const hasTail: unique symbol;
58
- const indent: unique symbol;
59
- const int32: unique symbol;
60
- const int64: unique symbol;
61
- const isInt: unique symbol;
62
- const later: unique symbol;
63
- const limn: unique symbol;
64
- const lower: unique symbol;
65
- const map: unique symbol;
66
- const mapk: unique symbol;
67
- const merge: unique symbol;
68
- const mod: unique symbol;
69
- const padHead: unique symbol;
70
- const padTail: unique symbol;
71
- const rem: unique symbol;
72
- const slash: unique symbol;
73
- const slice: unique symbol;
74
- const suppress: unique symbol;
75
- const toArr: unique symbol;
76
- const toBin: unique symbol;
77
- const toNum: unique symbol;
78
- const toObj: unique symbol;
79
- const toStr: unique symbol;
80
- const upper: unique symbol;
81
- // </SYMBOLS>
82
-
83
171
  // Adding symbol properties to Object.prototype will cause typescript to think these properties
84
172
  // are also available for extending types, e.g. Array - to avoid this we merge in an object which
85
173
  // defines every symbol as `undefined`!
86
174
  type SymbolsProto = {
87
- // <SYMBOLS> :: SymbolsProto :: /\[([a-zA-Z0-9]+)\][ ]*[:][ ]*undefined
88
- [add]: undefined,
89
- [allArr]: undefined,
90
- [allObj]: undefined,
91
- [at]: undefined,
92
- [assert]: undefined,
93
- [base32]: undefined,
94
- [base36]: undefined,
95
- [base62]: undefined,
96
- [base64Std]: undefined,
97
- [base64Url]: undefined,
98
- [baseline]: undefined,
99
- [bind]: undefined,
100
- [char]: undefined,
101
- [charset]: undefined,
102
- [code]: undefined,
103
- [count]: undefined,
104
- [cut]: undefined,
105
- [dive]: undefined,
106
- [empty]: undefined,
107
- [find]: undefined,
108
- [fire]: undefined,
109
- [group]: undefined,
110
- [has]: undefined,
111
- [hasHead]: undefined,
112
- [hasTail]: undefined,
113
- [indent]: undefined,
114
- [int32]: undefined,
115
- [int64]: undefined,
116
- [isInt]: undefined,
117
- [later]: undefined,
118
- [limn]: undefined,
119
- [lower]: undefined,
120
- [map]: undefined,
121
- [mapk]: undefined,
122
- [merge]: undefined,
123
- [mod]: undefined,
124
- [padHead]: undefined,
125
- [padTail]: undefined,
126
- [rem]: undefined,
127
- [slash]: undefined,
128
- [slice]: undefined,
129
- [suppress]: undefined,
130
- [toArr]: undefined,
131
- [toBin]: undefined,
132
- [toNum]: undefined,
133
- [toObj]: undefined,
134
- [toStr]: undefined,
135
- [upper]: undefined
175
+ // <SYMBOLS> :: proto :: /\[clearing[.]([a-zA-Z0-9]+)\][ ]*[:][ ]*undefined
176
+ [clearing.add]: undefined,
177
+ [clearing.allArr]: undefined,
178
+ [clearing.allObj]: undefined,
179
+ [clearing.at]: undefined,
180
+ [clearing.assert]: undefined,
181
+ [clearing.base32]: undefined,
182
+ [clearing.base36]: undefined,
183
+ [clearing.base62]: undefined,
184
+ [clearing.base64Std]: undefined,
185
+ [clearing.base64Url]: undefined,
186
+ [clearing.baseline]: undefined,
187
+ [clearing.char]: undefined,
188
+ [clearing.charset]: undefined,
189
+ [clearing.code]: undefined,
190
+ [clearing.count]: undefined,
191
+ [clearing.cut]: undefined,
192
+ [clearing.empty]: undefined,
193
+ [clearing.find]: undefined,
194
+ [clearing.fire]: undefined,
195
+ [clearing.group]: undefined,
196
+ [clearing.has]: undefined,
197
+ [clearing.hasHead]: undefined,
198
+ [clearing.hasTail]: undefined,
199
+ [clearing.indent]: undefined,
200
+ [clearing.int32]: undefined,
201
+ [clearing.int64]: undefined,
202
+ [clearing.isInt]: undefined,
203
+ [clearing.later]: undefined,
204
+ [clearing.limn]: undefined,
205
+ [clearing.lower]: undefined,
206
+ [clearing.map]: undefined,
207
+ [clearing.mapk]: undefined,
208
+ [clearing.merge]: undefined,
209
+ [clearing.mod]: undefined,
210
+ [clearing.padHead]: undefined,
211
+ [clearing.padTail]: undefined,
212
+ [clearing.rem]: undefined,
213
+ [clearing.slash]: undefined,
214
+ [clearing.slice]: undefined,
215
+ [clearing.suppress]: undefined,
216
+ [clearing.toArr]: undefined,
217
+ [clearing.toBin]: undefined,
218
+ [clearing.toNum]: undefined,
219
+ [clearing.toObj]: undefined,
220
+ [clearing.toStr]: undefined,
221
+ [clearing.upper]: undefined,
222
+ [clearing.walk]: undefined
136
223
  // </SYMBOLS>
137
224
  };
138
225
 
139
226
  interface ErrorConstructor {
140
- [assert]: <V = any>(args: V, fn: (args: V) => boolean) => void
227
+ [clearing.assert]: <V = any>(args: V, fn: (args: V) => boolean) => void
141
228
  }
142
229
  interface Error extends SymbolsProto {
143
- [mod]: (props: string | Obj<any> | ((msg: string, err: Error) => Obj<any>)) => Error,
144
- [fire]: (props?: string | Obj<any> | ((msg: string, err: Error) => Obj<any>)) => never,
145
- [suppress]: () => Error,
146
- [limn]: (seen?: Map<any, any>) => (Obj<Json> & {
230
+ [clearing.mod]: (props: string | Obj<any> | ((msg: string, err: Error) => Obj<any>)) => Error,
231
+ [clearing.fire]: (props?: string | Obj<any> | ((msg: string, err: Error) => Obj<any>)) => never,
232
+ [clearing.suppress]: () => Error,
233
+ [clearing.limn]: (seen?: Map<any, any>) => (Obj<Json> & {
147
234
  form: string,
148
235
  msg: string,
149
236
  trace: string[],
@@ -153,70 +240,77 @@ declare global {
153
240
 
154
241
  interface ArrayConstructor {}
155
242
  interface Array<T> extends SymbolsProto {
156
- [has]: (val: unknown) => boolean,
157
- [map]: <Fn extends (v: T, i: number) => any>(fn: Fn) => Exclude<ReturnType<Fn>, Skip>[],
158
- [add]: <TT extends T>(val: TT) => TT,
159
- [rem]: <TT extends T>(val: TT) => void,
160
- [count]: () => number,
161
- [empty]: () => boolean,
162
- [toObj]: <R extends readonly [string, any]>(fn: (v: T, n: number) => Skip | R) => { [K: string]: any },
163
- [find]: (fn: (val: T, n: number) => any) => ({ found: true, val: T, ind: number } | { found: false, val: null, ind: null }),
164
- [group]: <G extends string>(fn: (v: T) => Skip | G) => { [K in G]?: T[] }
243
+ [clearing.has]: (val: unknown) => boolean,
244
+ [clearing.map]: <Fn extends (v: T, i: number) => any>(fn: Fn) => Exclude<ReturnType<Fn>, Skip>[],
245
+ [clearing.add]: <TT extends T>(val: TT) => TT,
246
+ [clearing.rem]: <TT extends T>(val: TT) => void,
247
+ [clearing.count]: () => number,
248
+ [clearing.empty]: () => boolean,
249
+ [clearing.toObj]: <R extends readonly [string, any]>(fn: (v: T, n: number) => Skip | R) => { [K in R[0]]: R[1] },
250
+ [clearing.find]: (fn: (val: T, n: number) => any) => ({ found: true, val: T, ind: number } | { found: false, val: null, ind: null }),
251
+ [clearing.group]: <G extends string>(fn: (v: T, i: number) => Skip | G) => { [K in G]?: T[] }
165
252
  }
166
253
 
167
254
  interface NumberConstructor {
168
- [int32]: number,
169
- [int64]: number
255
+ [clearing.int32]: number,
256
+ [clearing.int64]: number
170
257
  }
171
258
  interface Number extends SymbolsProto {
172
- [char]: () => string,
173
- [isInt]: () => boolean,
174
- [toStr]: (str: string | CharSet, len?: number) => string,
175
- [toArr]: <T>(fn: (n: number) => T) => T[],
176
- [toObj]: <R extends readonly [string, any]>(fn: (n: number) => Skip | R) => { [K: string]: any },
177
- [toBin]: () => Uint8Array,
259
+ [clearing.char]: () => string,
260
+ [clearing.isInt]: () => boolean,
261
+ [clearing.toStr]: (str: string | CharSet, len?: number) => string,
262
+ [clearing.toArr]: <T>(fn: (n: number) => T) => T[],
263
+ [clearing.toObj]: <R extends readonly [string, any]>(fn: (n: number) => Skip | R) => { [K in R[0]]: R[1] },
264
+ [clearing.toBin]: () => Uint8Array,
178
265
  [Symbol.iterator]: () => Generator<number>
179
266
  }
180
267
 
181
268
  interface BigIntConstructor {}
182
269
  interface BigInt extends SymbolsProto {
183
- [toStr]: (str: string | CharSet, len?: number) => string,
184
- [toBin]: () => Uint8Array
270
+ [clearing.toStr]: (str: string | CharSet, len?: number) => string,
271
+ [clearing.toBin]: () => Uint8Array
185
272
  }
186
273
 
187
274
  interface ObjectConstructor {}
188
- interface Object {
189
- [empty]: () => boolean,
190
- [at]: <O extends Obj, K extends string | string[], D extends any = undefined>(this: O, k: K, def?: D) => Dive<O, K extends string[] ? K : [ K ], D>,
191
- [has]: <O extends Obj>(this: O, k: unknown) => k is keyof O,
192
- [map]: <O extends Obj, Fn extends (v: ObjVals<O>, k: ObjKeys<O>) => any>(this: O, fn: Fn) => { [K in keyof O]: Exclude<ReturnType<Fn>, Skip> },
193
- [mapk]: <O extends Obj, Fn extends (v: O[keyof O], k: ObjKeys<O>) => undefined | [ string, any ]>(this: O, fn: Fn) => { [K: string]: any },
194
- [merge]: <O1 extends Obj, O2 extends Obj>(this: O1, val: O2) => O1 & O2,
195
- [slice]: <O extends Obj, K extends readonly (keyof O)[]>(this: O, keys: K) => { [P in K[number]]: SkipNever<O[P]> },
196
- [slash]: <O extends Obj, T extends readonly (keyof O)[]>(this: O, keys: T) => { [K in keyof O as Exclude<keyof O, T[number]>]: O[K] },
197
- [toArr]: <O extends Obj, Fn extends (v: O[keyof O], k: ObjKeys<O>) => any>(this: O, fn: Fn) => Exclude<ReturnType<Fn>, Skip>[],
198
- [count]: () => number,
199
- [group]: <O extends Obj, G extends string>(this: O, fn: (v: O[keyof O]) => Skip | G) => { [K in G]?: Partial<O> },
200
- [Symbol.iterator]: <O extends Obj>(this: O) => Iterator<[ ObjKeys<O>, ObjVals<O> ]>
275
+ interface Object extends SymbolsProto {
276
+
277
+ [clearing.empty]: <O extends Obj> (this: O) => this is Obj<never>,
278
+ [clearing.at]: <O extends Obj, K extends string | string[], D extends any = Skip>(this: O, k: K, def?: D) => Dive<O, K extends string[] ? K : [ K ], D>,
279
+ [clearing.has]: <O extends Obj> (this: O, k: unknown) => k is keyof O,
280
+ [clearing.map]: <O extends Obj, V> (this: O, fn: (v: ObjVals<O>, k: ObjKeys<O>) => V) => { [K in keyof O]: Exclude<V, Skip> },
281
+ [clearing.mapk]: <O extends Obj, K extends string, V> (this: O, fn: (v: ObjVals<O>, k: ObjKeys<O>) => Skip | [ K, V ]) => { [KK in K]: V },
282
+ [clearing.merge]: <A extends Obj, B extends Obj> (this: A, val: B) => A & B,
283
+ [clearing.slice]: <O extends Obj, K extends readonly (keyof O)[]> (this: O, keys: K) => { [P in K[number]]: SkipNever<O[P]> },
284
+ [clearing.slash]: <O extends Obj, T extends readonly (keyof O)[]> (this: O, keys: T) => { [K in keyof O as Exclude<keyof O, T[number]>]: O[K] },
285
+ [clearing.toArr]: <O extends Obj, Fn extends (v: O[keyof O], k: ObjKeys<O>) => any> (this: O, fn: Fn) => Exclude<ReturnType<Fn>, Skip>[],
286
+ [clearing.count]: () => number,
287
+ [clearing.group]: <O extends Obj, G extends string> (this: O, fn: (v: O[keyof O], k: keyof O) => Skip | G) => { [K in G]?: Partial<O> },
288
+ [clearing.walk]: <O extends Obj> (this: O) => Iterable<[ ObjKeys<O>, ObjVals<O> ]>,
289
+
290
+ $$inspect: <O>(this: O) => { v: O }
291
+
201
292
  }
202
293
 
203
294
  interface ArrayBufferConstructor {}
204
295
  interface ArrayBuffer {
205
- [toStr]: () => string,
206
- [toNum]: () => bigint
296
+ [clearing.toStr]: () => string,
297
+ [clearing.toNum]: () => bigint
298
+ }
299
+ interface SharedArrayBuffer {
300
+ [clearing.toStr]: () => string,
301
+ [clearing.toNum]: () => bigint
207
302
  }
208
303
 
209
304
  interface Uint8ArrayConstructor {}
210
305
  interface Uint8Array {
211
- [toStr]: () => string,
212
- [toNum]: () => bigint
306
+ [clearing.toStr]: () => string,
307
+ [clearing.toNum]: () => bigint
213
308
  }
214
309
 
215
310
  interface PromiseConstructor {
216
- [allArr]: <V extends Promise<any>>(arr: Arr<V>) => Promise<Arr<Exclude<Awaited<V>, Skip>>>,
217
- [allObj]: <V extends Promise<any>>(obj: Obj<V>) => Promise<Obj<Exclude<Awaited<V>, Skip>>>,
218
- // [allObj]: <O extends { [K: string]: Promise<any> }>(obj: O) => Promise<{ [K in keyof O]: Exclude<Awaited<O[K]>, Skip> }>,
219
- [later]: <T=void>() => PromiseLater<T>
311
+ [clearing.allArr]: <V extends Promise<any>>(arr: Arr<V>) => Promise<Arr<Exclude<Awaited<V>, Skip>>>,
312
+ [clearing.allObj]: <V extends Promise<any>>(obj: Obj<V>) => Promise<Obj<Exclude<Awaited<V>, Skip>>>,
313
+ [clearing.later]: <T=void>() => PromiseLater<T>
220
314
  }
221
315
  interface Promise<T> {}
222
316
  interface PromiseLater<T=void> extends Promise<T> {
@@ -226,56 +320,56 @@ declare global {
226
320
 
227
321
  interface SetConstructor {}
228
322
  interface Set<T> extends SymbolsProto {
229
- [count]: () => number,
230
- [empty]: () => boolean,
231
- [find]: (fn: (val: T) => any) => ({ found: true, val: T } | { found: false, val: null }),
232
- [map]: <V>(fn: (val: T, ind: number) => V) => Exclude<V, Skip>[],
233
- [toArr]: <V>(fn: (val: T, ind: number) => V) => Exclude<V, Skip>[],
234
- [toObj]: <R extends readonly [string, any]>(fn: (val: T) => Skip | R) => { [K: string]: any },
235
- [rem]: (val: T) => void
323
+ [clearing.count]: () => number,
324
+ [clearing.empty]: () => boolean,
325
+ [clearing.find]: (fn: (val: T) => any) => ({ found: true, val: T } | { found: false, val: null }),
326
+ [clearing.map]: <V>(fn: (val: T, ind: number) => V) => Exclude<V, Skip>[],
327
+ [clearing.toArr]: <V>(fn: (val: T, ind: number) => V) => Exclude<V, Skip>[],
328
+ [clearing.toObj]: <R extends readonly [string, any]>(fn: (val: T) => Skip | R) => Obj<R[1]>,
329
+ [clearing.rem]: (val: T) => void
236
330
  }
237
331
 
238
332
  interface MapConstructor {}
239
333
  interface Map<K, V> extends SymbolsProto {
240
- [add]: (k: K, v: V) => void,
241
- [count]: () => number,
242
- [empty]: () => boolean,
243
- [find]: (fn: (val: V, key: K) => any) => ({ found: true, val: V, key: K } | { found: false, val: null, key: null }),
244
- [map]: <T>(fn: (val: V, key: K) => Skip | readonly [string, any]) => { [K: string]: any },
245
- [toArr]: <T>(fn: (val: V, key: K) => T) => Exclude<T, Skip>[],
246
- [toObj]: <R>(fn: (val: V, key: K) => Skip | readonly [string, R]) => Obj<R>,
247
- [rem]: (key: K) => void
334
+ [clearing.add]: (k: K, v: V) => void,
335
+ [clearing.count]: (this: Map<K, V>) => number,
336
+ [clearing.empty]: () => this is Map<K, never>,
337
+ [clearing.find]: (fn: (val: V, key: K) => any) => ({ found: true, val: V, key: K } | { found: false, val: null, key: null }),
338
+ [clearing.map]: <T> (fn: (val: V, key: K) => Skip | readonly [string, any]) => { [K: string]: any },
339
+ [clearing.toArr]: <T> (fn: (val: V, key: K) => T) => Exclude<T, Skip>[],
340
+ [clearing.toObj]: <RK, RV>(fn: (val: V, key: K) => Skip | readonly [ RK, RV ]) => { [K in RK]: RV },
341
+ [clearing.rem]: (key: K) => void
248
342
  }
249
343
 
250
344
  interface StringConstructor {
251
- [base32]: string,
252
- [base36]: string,
253
- [base62]: string,
254
- [base64Url]: string,
255
- [base64Std]: string,
256
- [baseline]: (str: string) => string,
257
- [charset]: (str: string) => CharSet,
345
+ [clearing.base32]: string,
346
+ [clearing.base36]: string,
347
+ [clearing.base62]: string,
348
+ [clearing.base64Url]: string,
349
+ [clearing.base64Std]: string,
350
+ [clearing.baseline]: (str: string) => string,
351
+ [clearing.charset]: (str: string) => CharSet,
258
352
  }
259
353
  interface String extends SymbolsProto {
260
- [code]: (ind?: number) => number,
261
- [count]: () => number,
262
- [has]: (s: string) => boolean,
263
- [padHead]: (n: number, s?: string) => string,
264
- [padTail]: (n: number, s?: string) => string,
265
- [toNum]: (chrs: string | CharSet) => bigint,
266
- [toBin]: () => Uint8Array,
267
- [hasHead]: <H extends string>(this: string, head: H) => this is `${H}${string}`,
268
- [hasTail]: <T extends string>(this: string, tail: T) => this is `${string}${T}`,
269
- [upper]: <S extends string>(this: S) => Uppercase<S>,
270
- [lower]: <S extends string>(this: S) => Lowercase<S>,
271
- [cut]: {
354
+ [clearing.code]: (ind?: number) => number,
355
+ [clearing.count]: () => number,
356
+ [clearing.has]: (s: string) => boolean,
357
+ [clearing.padHead]: (n: number, s?: string) => string,
358
+ [clearing.padTail]: (n: number, s?: string) => string,
359
+ [clearing.toNum]: (chrs: string | CharSet) => bigint,
360
+ [clearing.toBin]: () => Uint8Array,
361
+ [clearing.hasHead]: <H extends string>(this: string, head: H) => this is `${H}${string}`,
362
+ [clearing.hasTail]: <T extends string>(this: string, tail: T) => this is `${string}${T}`,
363
+ [clearing.upper]: <S extends string>(this: S) => Uppercase<S>,
364
+ [clearing.lower]: <S extends string>(this: S) => Lowercase<S>,
365
+ [clearing.cut]: {
272
366
  (str: string, cuts: 1): [ string, string ],
273
367
  (str: string, cuts: 2): [ string, string, string ],
274
368
  (str: string, cuts: 3): [ string, string, string, string ],
275
369
  (str: string, cuts: 4): [ string, string, string, string, string ],
276
370
  (str: string, cuts?: number): string[]
277
371
  },
278
- [indent]: {
372
+ [clearing.indent]: {
279
373
  (amount: number, char?: string): string,
280
374
  (str: string): string
281
375
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gershy/clearing",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "Adds the features you always wish javascript had!",
5
5
  "keywords": [
6
6
  "clearing",