@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.
package/cmp/cjs/main.d.ts CHANGED
@@ -1,30 +1,3 @@
1
1
  import '../sideEffects.js';
2
- type ClsCheck = {
3
- (i: unknown, num: BooleanConstructor): i is boolean;
4
- (i: unknown, num: NumberConstructor): i is number;
5
- (i: unknown, str: StringConstructor): i is string;
6
- (i: unknown, buff: Buffer): i is Buffer;
7
- (i: unknown, arr: ArrayConstructor): i is any[];
8
- (i: unknown, obj: ObjectConstructor): i is Obj<unknown>;
9
- (i: unknown, fn: FunctionConstructor): i is Fn;
10
- (i: unknown, fn: SymbolConstructor): i is symbol;
11
- <T>(i: unknown, prm: PromiseConstructor): i is Promise<T>;
12
- <C extends abstract new (...args: any) => any>(i: unknown, cls: C): i is InstanceType<C>;
13
- };
14
- export declare const getClsName: (i: any) => any;
15
- export declare const getCls: (i: any) => any;
16
- export declare const isCls: ClsCheck;
17
- export declare const inCls: ClsCheck;
18
- export declare const skip: undefined;
19
- type Then = {
20
- <V, R0 = V, R1 = never>(val: Promise<V>, rsv?: (v: V) => R0, rjc?: (e: any) => R1): Promise<R0 | R1>;
21
- <V, R0 = V, R1 = never>(val: V, rsv?: (v: V) => R0, rjc?: (e: any) => R1): R0 | R1;
22
- };
23
- export declare const then: Then;
24
- type Safe = {
25
- <V, R0 = never>(fn: () => Promise<V>, rjc?: (e: any) => R0): Promise<V | R0>;
26
- <V, R0 = never>(fn: () => V, rjc?: (e: any) => R0): Promise<V | R0>;
27
- };
28
- export declare const safe: Safe;
29
2
  declare const applyClearing: () => void;
30
3
  export default applyClearing;
package/cmp/cjs/main.js CHANGED
@@ -1,67 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safe = exports.then = exports.skip = exports.inCls = exports.isCls = exports.getCls = exports.getClsName = void 0;
4
- const getClsName = i => {
5
- if (i === null)
6
- return 'Null';
7
- if (i === undefined)
8
- return 'Undef';
9
- if (i !== i)
10
- return 'Nan';
11
- return Object.getPrototypeOf(i)?.constructor.name ?? 'Prototypeless';
12
- };
13
- exports.getClsName = getClsName;
14
- const getCls = i => Object.getPrototypeOf(i)?.constructor ?? null;
15
- exports.getCls = getCls;
16
- const isCls = (i, C) => {
17
- // NaN only matches against the NaN primitive (not the Number Form)
18
- if (i !== i)
19
- return C !== C;
20
- // `null` and `undefined` only match to themselves
21
- if (i == null)
22
- return i === C;
23
- // Otherwise strictly check the constructor
24
- return Object.getPrototypeOf(i).constructor === C;
25
- };
26
- exports.isCls = isCls;
27
- const inCls = (i, C) => i instanceof C;
28
- exports.inCls = inCls;
29
- exports.skip = undefined;
30
- const then = (val, rsv = (v => v), rjc = ((e) => { throw e; })) => {
31
- // Act on `val` regardless of whether it's a Promise or immediate value; return `rsv(val)`
32
- // either immediately or as a Promise
33
- if ((0, exports.inCls)(val, Promise))
34
- return val.then(rsv).catch(rjc);
35
- try {
36
- return rsv(val);
37
- }
38
- catch (err) {
39
- return rjc(err);
40
- }
41
- };
42
- exports.then = then;
43
- const safe = (fn, rjc = e => { throw e; }) => {
44
- // Execute a function which returns a value either synchronously or asynchronously; in both cases
45
- // allows errors occurring from function execution to be handled
46
- try {
47
- return (0, exports.then)(fn(), v => v, rjc);
48
- }
49
- catch (err) {
50
- return rjc(err);
51
- }
52
- };
53
- exports.safe = safe;
54
3
  const applyClearing = (() => {
55
- const global = globalThis;
56
4
  // Prevent multiple installations...
57
- const pfx = '@gershy/clearing';
58
- const memSym = Symbol.for(`${pfx}:mem`);
59
- if (global[memSym])
5
+ const global = globalThis;
6
+ if (global[Symbol.for(`@gershy/clearing:mem`)])
60
7
  return;
61
- global[memSym] = true;
62
- const [enc, dec] = [new TextEncoder(), new TextDecoder()];
8
+ global[Symbol.for(`@gershy/clearing:mem`)] = true;
9
+ const getClsName = i => {
10
+ if (i === null)
11
+ return 'Null';
12
+ if (i === undefined)
13
+ return 'Undef';
14
+ if (i !== i)
15
+ return 'Nan';
16
+ return Object.getPrototypeOf(i)?.constructor.name ?? 'Prototypeless';
17
+ };
18
+ const getCls = i => Object.getPrototypeOf(i)?.constructor ?? null;
19
+ const isCls = (i, C) => {
20
+ // NaN only matches against the NaN primitive (not the Number Form)
21
+ if (i !== i)
22
+ return C !== C;
23
+ // `null` and `undefined` only match to themselves
24
+ if (i == null)
25
+ return i === C;
26
+ // Otherwise strictly check the constructor
27
+ return Object.getPrototypeOf(i).constructor === C;
28
+ };
29
+ const inCls = (i, C) => i instanceof C;
30
+ const skip = undefined;
31
+ const then = (val, rsv = (v => v), rjc = ((e) => { throw e; })) => {
32
+ // Act on `val` regardless of whether it's a Promise or immediate value; return `rsv(val)`
33
+ // either immediately or as a Promise
34
+ if (inCls(val, Promise))
35
+ return val.then(rsv).catch(rjc);
36
+ try {
37
+ return rsv(val);
38
+ }
39
+ catch (err) {
40
+ return rjc(err);
41
+ }
42
+ };
43
+ const safe = (fn, rjc = e => { throw e; }) => {
44
+ // Execute a function which returns a value either synchronously or asynchronously; in both cases
45
+ // allows errors occurring from function execution to be handled
46
+ try {
47
+ return then(fn(), v => v, rjc);
48
+ }
49
+ catch (err) {
50
+ return rjc(err);
51
+ }
52
+ };
63
53
  const symNames = [
64
- // <SYMBOLS> :: definitions :: /[']([a-zA-Z0-9]+)[']/
54
+ // <SYMBOLS> :: runtimeNames :: /[']([a-zA-Z0-9]+)[']/
65
55
  'add',
66
56
  'allArr',
67
57
  'allObj',
@@ -73,13 +63,11 @@ const applyClearing = (() => {
73
63
  'base64Std',
74
64
  'base64Url',
75
65
  'baseline',
76
- 'bind',
77
66
  'char',
78
67
  'charset',
79
68
  'code',
80
69
  'count',
81
70
  'cut',
82
- 'dive',
83
71
  'empty',
84
72
  'find',
85
73
  'fire',
@@ -109,27 +97,80 @@ const applyClearing = (() => {
109
97
  'toNum',
110
98
  'toObj',
111
99
  'toStr',
112
- 'upper'
100
+ 'upper',
101
+ 'walk'
113
102
  // </SYMBOLS>
114
103
  ];
115
- const syms = Object.fromEntries(symNames.map(term => [term, Symbol(`${pfx}:${term}`)]));
116
- Object.assign(global, { ...syms });
104
+ const cl = {
105
+ getClsName, getCls, isCls, inCls, then, safe, skip,
106
+ ...Object.fromEntries(symNames.map(term => [term, Symbol(`@gershy/clearing:${term}`)]))
107
+ };
108
+ Object.assign(global, { cl, clearing: cl });
109
+ // <SYMBOLS> :: runtimeRefs :: /^[ ]*const[ ]([a-zA-Z0-9]+)[:]/
110
+ const add = clearing.add;
111
+ const allArr = clearing.allArr;
112
+ const allObj = clearing.allObj;
113
+ const at = clearing.at;
114
+ const assert = clearing.assert;
115
+ const base32 = clearing.base32;
116
+ const base36 = clearing.base36;
117
+ const base62 = clearing.base62;
118
+ const base64Std = clearing.base64Std;
119
+ const base64Url = clearing.base64Url;
120
+ const baseline = clearing.baseline;
121
+ const char = clearing.char;
122
+ const charset = clearing.charset;
123
+ const code = clearing.code;
124
+ const count = clearing.count;
125
+ const cut = clearing.cut;
126
+ const empty = clearing.empty;
127
+ const find = clearing.find;
128
+ const fire = clearing.fire;
129
+ const group = clearing.group;
130
+ const has = clearing.has;
131
+ const hasHead = clearing.hasHead;
132
+ const hasTail = clearing.hasTail;
133
+ const indent = clearing.indent;
134
+ const int32 = clearing.int32;
135
+ const int64 = clearing.int64;
136
+ const isInt = clearing.isInt;
137
+ const later = clearing.later;
138
+ const limn = clearing.limn;
139
+ const lower = clearing.lower;
140
+ const map = clearing.map;
141
+ const mapk = clearing.mapk;
142
+ const merge = clearing.merge;
143
+ const mod = clearing.mod;
144
+ const padHead = clearing.padHead;
145
+ const padTail = clearing.padTail;
146
+ const rem = clearing.rem;
147
+ const slash = clearing.slash;
148
+ const slice = clearing.slice;
149
+ const suppress = clearing.suppress;
150
+ const toArr = clearing.toArr;
151
+ const toBin = clearing.toBin;
152
+ const toNum = clearing.toNum;
153
+ const toObj = clearing.toObj;
154
+ const toStr = clearing.toStr;
155
+ const upper = clearing.upper;
156
+ const walk = clearing.walk;
157
+ // </SYMBOLS>
117
158
  const assignSyms = (Cls, def) => {
118
159
  const protoVals = [];
119
- for (const key of Reflect.ownKeys(def)) {
120
- if (!(0, exports.isCls)(key, Symbol))
121
- throw Object.assign(Error('invalid proto key'), { Cls, keyClsName: (0, exports.getClsName)(key), key });
122
- protoVals.push([key, def[key]]);
123
- }
160
+ for (const key of Reflect.ownKeys(def))
161
+ if (!isCls(key, Symbol))
162
+ throw Object.assign(Error('invalid proto key'), { Cls, keyClsName: getClsName(key), key });
163
+ else
164
+ protoVals.push([key, def[key]]);
124
165
  // Assign class properties
125
166
  for (const [sym, value] of protoVals)
126
167
  Object.defineProperty(Cls, sym, { enumerable: false, value });
127
168
  };
128
169
  assignSyms(Object, {});
129
170
  assignSyms(Object.prototype, {
130
- [at](cmps, def = exports.skip) {
171
+ [at](cmps, def = skip) {
131
172
  let ptr = this;
132
- if (!(0, exports.isCls)(cmps, Array))
173
+ if (!isCls(cmps, Array))
133
174
  cmps = [cmps];
134
175
  for (const c of cmps) {
135
176
  if (ptr[has](c))
@@ -151,9 +192,9 @@ const applyClearing = (() => {
151
192
  // });
152
193
  // >> { small: { a: 1, b: 2, c: 3 }, medium: { d: 4, e: 5, f: 6, g: 7 }, big: { h: 8, i: 9, j: 10 } }
153
194
  const ret = {};
154
- for (const [k, v] of this) {
195
+ for (const [k, v] of this[walk]()) {
155
196
  const g = fn(v, k);
156
- if (g === exports.skip)
197
+ if (g === skip)
157
198
  continue;
158
199
  if (!ret[has](g))
159
200
  ret[g] = {};
@@ -166,7 +207,7 @@ const applyClearing = (() => {
166
207
  const ret = Object.assign({}, this);
167
208
  for (const k in ret) {
168
209
  const v = fn(ret[k], k);
169
- if (v !== exports.skip)
210
+ if (v !== skip)
170
211
  ret[k] = v;
171
212
  else
172
213
  delete ret[k];
@@ -177,25 +218,25 @@ const applyClearing = (() => {
177
218
  const arr = [];
178
219
  for (const k in this) {
179
220
  const r = fn(this[k], k);
180
- if (r !== exports.skip)
221
+ if (r !== skip)
181
222
  arr.push(r);
182
223
  }
183
224
  return Object.fromEntries(arr);
184
225
  },
185
- [merge](o) {
186
- for (const [k, v] of o) {
226
+ [merge](obj) {
227
+ for (const [k, v] of obj[walk]()) {
187
228
  // `skip` can be passed to remove properties
188
- if (v === exports.skip) {
229
+ if (v === skip) {
189
230
  delete this[k];
190
231
  continue;
191
232
  }
192
233
  // Incoming non-Object properties are simple
193
- if (!(0, exports.isCls)(v, Object)) {
234
+ if (!isCls(v, Object)) {
194
235
  this[k] = v;
195
236
  continue;
196
237
  }
197
238
  // `v` is an Object; existing non-Object replaced with `{}`
198
- if (!this[has](k) || !(0, exports.isCls)(this[k], Object))
239
+ if (!this[has](k) || !isCls(this[k], Object))
199
240
  this[k] = {};
200
241
  // And simply recurse!
201
242
  this[k][merge](v);
@@ -211,18 +252,18 @@ const applyClearing = (() => {
211
252
  [slice](p) {
212
253
  // >> { a: 1, b: 2, c: 3, d: 4 }.slice([ 'b', 'd' ]);
213
254
  // { b: 2, d: 4 }
214
- return p[toObj](p => this[has](p) ? [p, this[p]] : exports.skip);
255
+ return p[toObj](p => this[has](p) ? [p, this[p]] : skip);
215
256
  },
216
257
  [toArr](fn) {
217
258
  const ret = [];
218
259
  for (const k in this) {
219
260
  const r = fn(this[k], k);
220
- if (r !== exports.skip)
261
+ if (r !== skip)
221
262
  ret.push(r);
222
263
  }
223
264
  return ret;
224
265
  },
225
- *[Symbol.iterator]() { for (const k in this)
266
+ *[walk]() { for (const k in this)
226
267
  yield [k, this[k]]; }
227
268
  });
228
269
  assignSyms(Array, {});
@@ -247,7 +288,7 @@ const applyClearing = (() => {
247
288
  const ret = {};
248
289
  for (const elem of this) {
249
290
  const g = fn(elem);
250
- if (g === exports.skip)
291
+ if (g === skip)
251
292
  continue;
252
293
  if (!ret[has](g))
253
294
  ret[g] = [];
@@ -261,7 +302,7 @@ const applyClearing = (() => {
261
302
  const len = this.length;
262
303
  for (let i = 0; i < len; i++) {
263
304
  const r = it(this[i], i);
264
- if (r !== exports.skip)
305
+ if (r !== skip)
265
306
  ret.push(r);
266
307
  }
267
308
  return ret;
@@ -273,18 +314,19 @@ const applyClearing = (() => {
273
314
  const len = this.length;
274
315
  for (let i = 0; i < len; i++) {
275
316
  const r = it(this[i], i);
276
- if (r !== exports.skip)
317
+ if (r !== skip)
277
318
  ret.push(r);
278
319
  }
279
320
  return Object.fromEntries(ret);
280
321
  }
281
322
  });
323
+ const [enc, dec] = [new TextEncoder(), new TextDecoder()];
282
324
  assignSyms(String, {
283
325
  [baseline]: (str, seq = '| ') => {
284
326
  return str.split('\n')[map](ln => {
285
327
  const ind = ln.indexOf(seq);
286
328
  if (ind === -1)
287
- return exports.skip;
329
+ return skip;
288
330
  return ln.slice(ind + seq.length);
289
331
  }).join('\n');
290
332
  },
@@ -320,7 +362,7 @@ const applyClearing = (() => {
320
362
  [count]() { return this.length; },
321
363
  [cut](delim, cuts = 1) {
322
364
  // `cuts` defines # of cuts (resulting array length is `num + 1`)
323
- const split = this.split(delim, cuts < Infinity ? cuts : exports.skip);
365
+ const split = this.split(delim, cuts < Infinity ? cuts : skip);
324
366
  const numDelimsSplit = split.length - 1;
325
367
  const lenConsumed = 0
326
368
  + split.reduce((a, s) => a + s.length, 0)
@@ -336,7 +378,7 @@ const applyClearing = (() => {
336
378
  if (!this)
337
379
  return this; // No-op on empty String (otherwise it would transform a 0-line string to a 1-line string)
338
380
  let indentStr;
339
- if ((0, exports.isCls)(args[0], String)) {
381
+ if (isCls(args[0], String)) {
340
382
  indentStr = args[0];
341
383
  }
342
384
  else {
@@ -350,7 +392,7 @@ const applyClearing = (() => {
350
392
  [padTail]: String.prototype.padEnd,
351
393
  [toBin]() { return enc.encode(this); },
352
394
  [toNum](cs = String[base62]) {
353
- if ((0, exports.isCls)(cs, String))
395
+ if (isCls(cs, String))
354
396
  cs = String[charset](cs);
355
397
  const base = cs.size;
356
398
  if (base === 1n)
@@ -375,7 +417,7 @@ const applyClearing = (() => {
375
417
  const ret = [];
376
418
  for (let i = 0; i < this; i++) {
377
419
  const r = fn(i);
378
- if (r !== exports.skip)
420
+ if (r !== skip)
379
421
  ret.push(r);
380
422
  }
381
423
  return Object.fromEntries(ret);
@@ -388,7 +430,7 @@ const applyClearing = (() => {
388
430
  // | singleChr.repeat(n - 1)
389
431
  if (this !== this)
390
432
  throw Error('nan');
391
- if ((0, exports.isCls)(cs, String))
433
+ if (isCls(cs, String))
392
434
  cs = String[charset](cs);
393
435
  const base = cs.size;
394
436
  if (base === 1n && padLen)
@@ -423,6 +465,11 @@ const applyClearing = (() => {
423
465
  [toStr]() { return dec.decode(this); },
424
466
  [toNum]() { return (new Uint8Array(this))[toNum](); }
425
467
  });
468
+ assignSyms(SharedArrayBuffer, {});
469
+ assignSyms(SharedArrayBuffer.prototype, {
470
+ [toStr]() { return dec.decode(new Uint8Array(this)); },
471
+ [toNum]() { return (new Uint8Array(this))[toNum](); }
472
+ });
426
473
  assignSyms(Uint8Array, {});
427
474
  assignSyms(Uint8Array.prototype, {
428
475
  [toStr]() { return dec.decode(this); },
@@ -455,17 +502,17 @@ const applyClearing = (() => {
455
502
  seen.set(this, 'cycle(Error)');
456
503
  const { message, stack, cause, ...props } = this;
457
504
  return {
458
- form: (0, exports.getClsName)(this),
505
+ form: getClsName(this),
459
506
  msg: message,
460
- trace: stack?.split('\n').slice(1)[map](v => v.trim() ?? exports.skip) ?? [],
507
+ trace: (stack ?? '<no stack>').split('\n')[map](v => v.trim() ?? skip),
461
508
  ...props,
462
509
  cause: !cause ? null : cause[limn](seen)
463
510
  };
464
511
  },
465
512
  [mod](props = {} /* { cause, msg, message, ...more } */) {
466
- if ((0, exports.isCls)(props, Function))
513
+ if (isCls(props, Function))
467
514
  props = props(this.message, this);
468
- if ((0, exports.isCls)(props, String))
515
+ if (isCls(props, String))
469
516
  props = { message: props };
470
517
  const { cause = null, msg = null, message = msg ?? this.message, ...moreProps } = props;
471
518
  // - Assign `cause` to transfer props like fs "code" props, etc. - watch out, `cause` may be
@@ -473,12 +520,12 @@ const applyClearing = (() => {
473
520
  // - Assign `moreProps` to transfer any other properties
474
521
  // - Add `message` prop
475
522
  // - Only add `cause` prop if `cause` is non-null
476
- return Object.assign(this, (0, exports.inCls)(cause, Error) ? cause : {}, moreProps, cause ? { message, cause } : { message });
523
+ return Object.assign(this, inCls(cause, Error) ? cause : {}, moreProps, cause ? { message, cause } : { message });
477
524
  },
478
525
  [suppress]() {
479
526
  this[Symbol.for('@gershy.clearing.err.suppressed')] = true;
480
527
  if (this.cause) {
481
- const causes = (0, exports.inCls)(this.cause, Error) ? [this.cause] : this.cause;
528
+ const causes = inCls(this.cause, Error) ? [this.cause] : this.cause;
482
529
  for (const err of causes)
483
530
  err[suppress]();
484
531
  }
@@ -486,14 +533,14 @@ const applyClearing = (() => {
486
533
  }
487
534
  });
488
535
  assignSyms(Promise, {
489
- [allArr]: arr => Promise.all(arr).then(arr => arr.filter(v => v !== exports.skip)),
536
+ [allArr]: arr => Promise.all(arr).then(arr => arr.filter(v => v !== skip)),
490
537
  [allObj]: obj => {
491
538
  // Need to get `keys` immediately, in case `obj` mutates before resolution
492
539
  const keys = Object.keys(obj);
493
540
  return Promise.all(Object.values(obj)).then(vals => {
494
541
  const ret = {};
495
542
  for (const [i, k] of keys.entries())
496
- if (vals[i] !== exports.skip)
543
+ if (vals[i] !== skip)
497
544
  ret[k] = vals[i];
498
545
  return ret;
499
546
  });
@@ -519,7 +566,7 @@ const applyClearing = (() => {
519
566
  let ind = 0;
520
567
  for (const item of this) {
521
568
  const r = fn(item, ind++);
522
- if (r !== exports.skip)
569
+ if (r !== skip)
523
570
  ret.push(r);
524
571
  }
525
572
  return ret;
@@ -530,7 +577,7 @@ const applyClearing = (() => {
530
577
  let ind = 0;
531
578
  for (const item of this) {
532
579
  const r = fn(item, ind++);
533
- if (r !== exports.skip)
580
+ if (r !== skip)
534
581
  ret.push(r);
535
582
  }
536
583
  return ret;
@@ -539,7 +586,7 @@ const applyClearing = (() => {
539
586
  const ret = [];
540
587
  for (const item of this) {
541
588
  const r = fn(item);
542
- if (r !== exports.skip)
589
+ if (r !== skip)
543
590
  ret.push(r);
544
591
  }
545
592
  return Object.fromEntries(ret);
@@ -560,7 +607,7 @@ const applyClearing = (() => {
560
607
  const ret = [];
561
608
  for (const [k, v] of this) {
562
609
  const r = fn(v, k);
563
- if (r !== exports.skip)
610
+ if (r !== skip)
564
611
  ret.push(r);
565
612
  }
566
613
  return Object.fromEntries(ret);
@@ -570,7 +617,7 @@ const applyClearing = (() => {
570
617
  const ret = [];
571
618
  for (const [k, v] of this) {
572
619
  const r = fn(v, k);
573
- if (r !== exports.skip)
620
+ if (r !== skip)
574
621
  ret.push(r);
575
622
  }
576
623
  return ret;
@@ -579,7 +626,7 @@ const applyClearing = (() => {
579
626
  const ret = [];
580
627
  for (const [k, v] of this) {
581
628
  const r = fn(v, k);
582
- if (r !== exports.skip)
629
+ if (r !== skip)
583
630
  ret.push(r);
584
631
  }
585
632
  return Object.fromEntries(ret);
package/cmp/mjs/main.d.ts CHANGED
@@ -1,30 +1,3 @@
1
1
  import '../sideEffects.js';
2
- type ClsCheck = {
3
- (i: unknown, num: BooleanConstructor): i is boolean;
4
- (i: unknown, num: NumberConstructor): i is number;
5
- (i: unknown, str: StringConstructor): i is string;
6
- (i: unknown, buff: Buffer): i is Buffer;
7
- (i: unknown, arr: ArrayConstructor): i is any[];
8
- (i: unknown, obj: ObjectConstructor): i is Obj<unknown>;
9
- (i: unknown, fn: FunctionConstructor): i is Fn;
10
- (i: unknown, fn: SymbolConstructor): i is symbol;
11
- <T>(i: unknown, prm: PromiseConstructor): i is Promise<T>;
12
- <C extends abstract new (...args: any) => any>(i: unknown, cls: C): i is InstanceType<C>;
13
- };
14
- export declare const getClsName: (i: any) => any;
15
- export declare const getCls: (i: any) => any;
16
- export declare const isCls: ClsCheck;
17
- export declare const inCls: ClsCheck;
18
- export declare const skip: undefined;
19
- type Then = {
20
- <V, R0 = V, R1 = never>(val: Promise<V>, rsv?: (v: V) => R0, rjc?: (e: any) => R1): Promise<R0 | R1>;
21
- <V, R0 = V, R1 = never>(val: V, rsv?: (v: V) => R0, rjc?: (e: any) => R1): R0 | R1;
22
- };
23
- export declare const then: Then;
24
- type Safe = {
25
- <V, R0 = never>(fn: () => Promise<V>, rjc?: (e: any) => R0): Promise<V | R0>;
26
- <V, R0 = never>(fn: () => V, rjc?: (e: any) => R0): Promise<V | R0>;
27
- };
28
- export declare const safe: Safe;
29
2
  declare const applyClearing: () => void;
30
3
  export default applyClearing;