@gershy/clearing 0.0.1 → 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.
@@ -0,0 +1,607 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const applyClearing = (() => {
4
+ const global = globalThis;
5
+ // Prevent multiple installations...
6
+ const memSym = Symbol.for('clearing:mem');
7
+ if (global[memSym])
8
+ return;
9
+ global[memSym] = true;
10
+ const symNames = ['add', 'at', 'apart', 'assert', 'bind', 'bits', 'built', 'char', 'code', 'count', 'cut', 'dive', 'empty', 'fire', 'group', 'has', 'hasHead', 'hasTail', 'indent', 'isInt', 'limn', 'lower', 'mod', 'map', 'mapk', 'merge', 'padHead', 'padTail', 'rem', 'find', 'slash', 'slice', 'suppress', 'toArr', 'toNum', 'toObj', 'toStr', 'upper'];
11
+ const syms = Object.fromEntries(symNames.map(term => [term, Symbol(`clearing:${term}`)]));
12
+ const sovereign = v => v;
13
+ Object.assign(global, {
14
+ // Reference native constructors
15
+ AsyncFunction: (async () => { }).constructor,
16
+ GeneratorFunction: (function* () { })().constructor,
17
+ AsyncGeneratorFunction: (async function* () { })().constructor,
18
+ // Symbols
19
+ ...syms,
20
+ // Forms
21
+ getFormName: f => {
22
+ if (f === null)
23
+ return 'Null';
24
+ if (f === undefined)
25
+ return 'Undef';
26
+ if (f !== f)
27
+ return 'UndefNum';
28
+ return Object.getPrototypeOf(f)?.constructor.name ?? 'Prototypeless'; // e.g. `getFormName(Object.plain()) === 'Prototypeless'`
29
+ },
30
+ getForm: f => Object.getPrototypeOf(f)?.constructor ?? null,
31
+ isForm: (fact, Form) => {
32
+ // NaN only matches against the NaN primitive (not the Number Form)
33
+ if (fact !== fact)
34
+ return Form !== Form;
35
+ if (fact == null)
36
+ return false;
37
+ return Object.getPrototypeOf(fact).constructor === Form;
38
+ },
39
+ hasForm: (fact, Form) => fact instanceof Form,
40
+ // Utility
41
+ skip: undefined,
42
+ sovereign,
43
+ then: (val, rsv = Function.stub, rjc) => {
44
+ // Act on `val` regardless of whether it's a Promise or an immediate
45
+ // value; return `rsv(val)` either immediately or as a Promise;
46
+ // Promises are returned with `then`/`fail` handling
47
+ if (hasForm(val, Promise))
48
+ return val.then(rsv).catch(rjc);
49
+ // No `rjc` means no `try`/`catch` handling
50
+ if (!rjc)
51
+ return rsv(val);
52
+ try {
53
+ return rsv(val);
54
+ }
55
+ catch (err) {
56
+ return rjc(err);
57
+ }
58
+ },
59
+ safe: (val, acc = Function.stub, rjc) => {
60
+ try {
61
+ return then(val(), acc, rjc);
62
+ }
63
+ catch (err) {
64
+ if (!rjc)
65
+ throw err;
66
+ return rjc(err);
67
+ }
68
+ },
69
+ // Jsfn
70
+ jsfn: {
71
+ encode: sovereign((dec /* `val` is still not allowed to have cycles! */, opts) => {
72
+ const encodeFn = opts?.encodeFn ?? (fn => fn.toString());
73
+ const hoists = [];
74
+ const serializeObjKey = (key) => {
75
+ if (/^[$_a-zA-Z][$_a-zA-Z]+$/.test(key))
76
+ return key;
77
+ return `'${key.replaceAll(`'`, `\\'`)}'`;
78
+ };
79
+ const serialize = (val) => {
80
+ if (isForm(val, Object) && Object.keys(val).sort().join(',') === 'args,form,hoist' && hasForm(val.form, Function)) {
81
+ const { args, form, hoist } = val;
82
+ hoists.push(hoist);
83
+ return `new ${hoist.split('::').at(-1)}(${args.map(a => serialize(a)).join(', ')})`;
84
+ }
85
+ if (isForm(val, Array))
86
+ return '[' + val.map((v) => serialize(v)).join(',') + ']';
87
+ if (isForm(val, Object))
88
+ return '{' + val[toArr]((v, k) => `${serializeObjKey(k)}:${serialize(v)}`).join(',') + '}';
89
+ if (hasForm(val, Function))
90
+ return encodeFn(val);
91
+ return JSON.stringify(val);
92
+ };
93
+ return {
94
+ // Note `str` is stringified, but it isn't json - it's js, in string representation!!
95
+ // This representation is actually very simple - in order to run the js represented by
96
+ // `str`, all hoists need to be imported in the context
97
+ hoists,
98
+ str: serialize(dec)
99
+ };
100
+ })
101
+ },
102
+ });
103
+ const protoDefs = (Cls, def) => {
104
+ const protoVals = [];
105
+ const classVals = [];
106
+ for (const key of Reflect.ownKeys(def) /* includes symbols!! */) {
107
+ if (!isForm(key, String))
108
+ protoVals.push({ key, val: def[key] });
109
+ else if (key.startsWith('$'))
110
+ classVals.push({ key: key.slice(1), val: def[key] });
111
+ else if (key.endsWith('->'))
112
+ protoVals.push({ key: def[key], val: Cls.prototype[key.slice(0, -2)] });
113
+ }
114
+ // Assign class properties
115
+ Object.assign(Cls, Object.fromEntries(classVals.map(({ key, val }) => [key, val])));
116
+ // Avoid making more properties available on `global` - if a typo winds up referring to a
117
+ // global property, the bug which results can be highly unexpected!
118
+ // TODO: Note, we don't want to populate the global namespace, *but* we still populate all the
119
+ // symbols keyed by string name on `global` (note the *symbol* is keyed by its *string name* on
120
+ // `global` - i.e., `global['toArr']` results in `Symbol('clearing.toArr')`! This results in
121
+ // many dozens of keys being populated in global namespace... should probably move these
122
+ // symbols to a module import instead :(
123
+ if (Cls === global.constructor)
124
+ for (const entry of protoVals)
125
+ if (isForm(entry.key, String))
126
+ global[entry.key] = skip;
127
+ // Assign proto properties
128
+ Object.defineProperties(Cls.prototype, Object.fromEntries(protoVals
129
+ .map(({ key, val }) => [key, { enumerable: false, writable: true, value: val }])));
130
+ };
131
+ protoDefs(Object, {
132
+ $stub: Object.freeze({}),
133
+ $plain: obj => obj ? Object.assign(Object.create(null), obj) : Object.create(null),
134
+ 'hasOwnProperty->': has,
135
+ *[apart](dive = []) {
136
+ // Breaks apart a "structured" object into a flat list of dive keys paired with values; every
137
+ // value in the original object appears alongside the "dive" (chain of keys to recursively
138
+ // apply) required to dereference it
139
+ for (const [k, val] of this) {
140
+ if (isForm(val, Object))
141
+ yield* val[apart]([...dive, k]);
142
+ else
143
+ yield { dive: [...dive, k], val };
144
+ }
145
+ },
146
+ [at](cmps, def = skip) {
147
+ let ptr = this;
148
+ if (!isForm(cmps, Array))
149
+ cmps = [cmps];
150
+ for (const c of cmps) {
151
+ if (ptr[has](c))
152
+ ptr = ptr[c];
153
+ else
154
+ return def;
155
+ }
156
+ return ptr;
157
+ },
158
+ [built](diveFromKey = (key) => key.split('.')) {
159
+ // The reverse operation of `apart` - takes a flat list of (dive, value) pairs and produces a
160
+ // structured object
161
+ const result = {};
162
+ for (const [k, v] of this) {
163
+ const dive = diveFromKey(k);
164
+ const last = dive.pop();
165
+ let ptr = result;
166
+ for (const cmp of dive)
167
+ ptr = ptr[at](cmp) ?? (ptr[cmp] = {});
168
+ ptr[last] = isForm(v, Object) ? v[built]() : v;
169
+ }
170
+ return result;
171
+ },
172
+ [count]() { let c = 0; for (const k in this)
173
+ c++; return c; },
174
+ [dive](cmps, def = skip) { return this[at](cmps, def); },
175
+ [map](fn) {
176
+ const ret = Object.assign({}, this);
177
+ for (const k in ret) {
178
+ const v = fn(ret[k], k);
179
+ if (v !== skip)
180
+ ret[k] = v;
181
+ else
182
+ delete ret[k];
183
+ }
184
+ return ret;
185
+ },
186
+ [mapk](fn) {
187
+ const arr = [];
188
+ for (const k in this) {
189
+ const r = fn(this[k], k);
190
+ if (r !== skip)
191
+ arr.push(r);
192
+ }
193
+ return Object.fromEntries(arr);
194
+ },
195
+ [toArr](fn) {
196
+ const ret = [];
197
+ for (const k in this) {
198
+ const r = fn(this[k], k);
199
+ if (r !== skip)
200
+ ret.push(r);
201
+ }
202
+ return ret;
203
+ },
204
+ [slash](p) {
205
+ const obj = { ...this };
206
+ for (const k of p)
207
+ delete obj[k];
208
+ return obj;
209
+ },
210
+ [slice](p) {
211
+ // >> { a: 1, b: 2, c: 3, d: 4 }.slice([ 'b', 'd' ]);
212
+ // { b: 2, d: 4 }
213
+ return p[toObj](p => this[has](p) ? [p, this[p]] : skip);
214
+ },
215
+ [empty]() { for (const k in this)
216
+ return false; return true; },
217
+ [group](fn) {
218
+ // { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }.group(n => {
219
+ // if (n < 4) return 'small';
220
+ // if (n < 8) return 'medium';
221
+ // return 'big';
222
+ // });
223
+ // >> { small: { a: 1, b: 2, c: 3 }, medium: { d: 4, e: 5, f: 6, g: 7 }, big: { h: 8, i: 9, j: 10 } }
224
+ const ret = {};
225
+ for (const [k, v] of this) {
226
+ const t = fn(v, k);
227
+ if (!ret[has](t))
228
+ ret[t] = {};
229
+ ret[t][k] = v;
230
+ }
231
+ return ret;
232
+ },
233
+ [merge](o) {
234
+ for (const [k, v] of o) {
235
+ // `skip` can be passed to remove properties
236
+ if (v === skip) {
237
+ delete this[k];
238
+ continue;
239
+ }
240
+ // Incoming non-Object properties are simple
241
+ if (!isForm(v, Object)) {
242
+ this[k] = v;
243
+ continue;
244
+ }
245
+ // `v` is an Object; existing non-Object replaced with `{}`
246
+ if (!this[has](k) || !isForm(this[k], Object))
247
+ this[k] = {};
248
+ // And simply recurse!
249
+ this[k][merge](v);
250
+ }
251
+ return this;
252
+ },
253
+ *[Symbol.iterator]() { for (const k in this)
254
+ yield [k, this[k]]; }
255
+ });
256
+ protoDefs(Array, {
257
+ $stub: Object.freeze([]),
258
+ 'includes->': has,
259
+ [has](v) { return this.includes(v); },
260
+ [map](it) {
261
+ const ret = [];
262
+ const len = this.length;
263
+ for (let i = 0; i < len; i++) {
264
+ const r = it(this[i], i);
265
+ if (r !== skip)
266
+ ret.push(r);
267
+ }
268
+ return ret;
269
+ },
270
+ [toArr](it) { return this[map](it); },
271
+ [toObj](it) {
272
+ const ret = [];
273
+ const len = this.length;
274
+ for (let i = 0; i < len; i++) {
275
+ const r = it(this[i], i);
276
+ if (r !== skip)
277
+ ret.push(r);
278
+ }
279
+ return Object.fromEntries(ret);
280
+ },
281
+ [find](f) {
282
+ const n = this.length;
283
+ for (let i = 0; i < n; i++)
284
+ if (f(this[i], i))
285
+ return { found: true, val: this[i], ind: i };
286
+ return { found: false, val: null, ind: null };
287
+ },
288
+ [empty]() { return !this.length; },
289
+ [add](...args) { this.push(...args); return args[0]; },
290
+ [rem](val) { const ind = this.indexOf(val); if (ind > -1)
291
+ this.splice(ind, 1); },
292
+ [count]() { return this.length; },
293
+ [group](fn) {
294
+ // [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ].group(n => {
295
+ // if (n < 4) return 'small';
296
+ // if (n < 8) return 'medium';
297
+ // return 'big';
298
+ // });
299
+ // >> { small: [ 1, 2, 3 ], medium: [ 4, 5, 6, 7 ], big: [ 8, 9, 10 ] }
300
+ const ret = {};
301
+ for (const elem of this) {
302
+ const t = fn(elem);
303
+ if (!ret[has](t))
304
+ ret[t] = [];
305
+ ret[t].push(elem);
306
+ }
307
+ return ret;
308
+ }
309
+ });
310
+ protoDefs(String, {
311
+ $baseline: (str, seq = '| ') => {
312
+ return str.split('\n')[map](ln => {
313
+ const ind = ln.indexOf(seq);
314
+ if (ind === -1)
315
+ return skip;
316
+ return ln.slice(ind + seq.length);
317
+ }).join('\n');
318
+ },
319
+ $charset: str => {
320
+ const cache = new Map();
321
+ return {
322
+ str,
323
+ size: BigInt(str.length),
324
+ charVal: (c) => {
325
+ if (!cache.has(c)) {
326
+ const ind = str.indexOf(c);
327
+ if (ind < 0)
328
+ throw Error('char outside charset')[mod]({ char: c });
329
+ cache.set(c, BigInt(ind));
330
+ }
331
+ return cache.get(c);
332
+ },
333
+ valChar: (n) => {
334
+ if (n < 0 || n >= str.length)
335
+ throw Error('val outside charset');
336
+ return str[n];
337
+ }
338
+ };
339
+ },
340
+ $base32: '0123456789abcdefghijklmnopqrstuv',
341
+ $base36: '0123456789abcdefghijklmnopqrstuvwxyz',
342
+ $base62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
343
+ $base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_',
344
+ $base64Std: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/',
345
+ 'includes->': has,
346
+ 'startsWith->': hasHead,
347
+ 'endsWith->': hasTail,
348
+ 'padStart->': padHead,
349
+ 'padEnd->': padTail,
350
+ 'toUpperCase->': upper,
351
+ 'toLowerCase->': lower,
352
+ [cut](delim, cuts = 1) {
353
+ // `cuts` defines # of cuts (resulting array length is `num + 1`)
354
+ const split = this.split(delim, cuts < Infinity ? cuts : skip);
355
+ const numDelimsSplit = split.length - 1;
356
+ const lenConsumed = 0
357
+ + split.reduce((a, s) => a + s.length, 0)
358
+ + delim.length * numDelimsSplit;
359
+ return lenConsumed < this.length
360
+ ? [...split, this.slice(lenConsumed + delim.length)]
361
+ : split;
362
+ },
363
+ [code](ind = 0) { return this.charCodeAt(ind); },
364
+ [count]() { return this.length; },
365
+ [indent](...args /* amt=2, char=' ' | indentStr=' '.repeat(2) */) {
366
+ if (!this)
367
+ return this; // No-op on empty String (otherwise it would transform a 0-line string to a 1-line string)
368
+ let indentStr;
369
+ if (isForm(args[0], String)) {
370
+ indentStr = args[0];
371
+ }
372
+ else {
373
+ const [amt = 2, char = ' '] = args;
374
+ indentStr = char.repeat(amt);
375
+ }
376
+ return this.split('\n')[map](ln => `${indentStr}${ln}`).join('\n');
377
+ },
378
+ [toNum](charset = String.base62) {
379
+ if (isForm(charset, String))
380
+ charset = String.charset(charset);
381
+ const base = charset.size;
382
+ if (base === 1n)
383
+ return this.count();
384
+ let sum = 0n;
385
+ const n = this.length;
386
+ for (let ind = 0; ind < n; ind++)
387
+ // Earlier values of `i` represent higher places same as with written numbers further left
388
+ // digits are more significant
389
+ // The value of the place `i` is `ind - 1`
390
+ sum += (base ** BigInt(n - ind - 1)) * charset.charVal(this[ind]);
391
+ return sum;
392
+ }
393
+ });
394
+ protoDefs(Number, {
395
+ $int32: Math.pow(2, 32),
396
+ $int64: Math.pow(2, 64),
397
+ [char]() { return String.fromCharCode(this); },
398
+ [toArr](fn) { const arr = new Array(this || 0); for (let i = 0; i < this; i++)
399
+ arr[i] = fn(i); return arr; },
400
+ [toObj](fn) {
401
+ const ret = [];
402
+ for (let i = 0; i < this; i++) {
403
+ const r = fn(i);
404
+ if (r !== skip)
405
+ ret.push(r);
406
+ }
407
+ return Object.fromEntries(ret);
408
+ },
409
+ [toStr](charset, padLen = 0) {
410
+ // Note that base-1 requires 0 to map to the empty string. This also
411
+ // means that, for `n >= 1`:
412
+ // | (n).encodeStr(singleChr)
413
+ // is always equivalent to
414
+ // | singleChr.repeat(n - 1)
415
+ if (isForm(charset, String))
416
+ charset = String.charset(charset);
417
+ const base = charset.size;
418
+ if (base === 1n && padLen)
419
+ throw Error(`pad with base-1 encoding`);
420
+ if (this !== this)
421
+ return (base === 1n) ? '' : charset[0].repeat(Math.max(padLen, 1));
422
+ let num = this.constructor === BigInt ? this : BigInt(Math.floor(this));
423
+ const digits = [];
424
+ while (num) {
425
+ digits.push(charset.valChar(num % base));
426
+ num /= base;
427
+ }
428
+ return digits.reverse().join('')[padHead](padLen, charset.str[0]);
429
+ },
430
+ [isInt]() { return this === Math.round(this); }, // No bitwise shortcut - it disrupts Infinity
431
+ *[Symbol.iterator]() { Error.assert({ n: this }, args => args.n.isInteger()); for (let i = 0; i < this; i++)
432
+ yield i; },
433
+ *[bits]() { let n = this >= 0 ? this : -this; while (n) {
434
+ yield n & 1;
435
+ n = n >> 1;
436
+ } },
437
+ [map]: undefined // Prevent `Number(...).map`
438
+ });
439
+ protoDefs(BigInt, { [toStr]: Number.prototype[toStr] });
440
+ protoDefs(Function, {
441
+ $stub: v => v,
442
+ [bind](...args) { return this.bind(null, ...args); }
443
+ });
444
+ protoDefs(Error, {
445
+ $stackTraceLimit: 150,
446
+ $assert: (args, fn) => {
447
+ if (fn(args))
448
+ return;
449
+ throw Error('assert failed')[mod]({
450
+ fn: `false === (${fn.toString().replace(/[\s]+/, ' ')})(args)`,
451
+ args
452
+ });
453
+ },
454
+ [mod](props = {} /* { cause, msg, message, ...more } */) {
455
+ if (isForm(props, Function))
456
+ props = props(this.message, this);
457
+ if (isForm(props, String))
458
+ props = { message: props };
459
+ const { cause = null, msg = null, message = msg ?? this.message, ...moreProps } = props;
460
+ // - Assign `cause` to transfer props like fs "code" props, etc. - watch out, `cause` may be
461
+ // an Array or Object!
462
+ // - Assign `moreProps` to transfer any other properties
463
+ // - Add `message` prop
464
+ // - Only add `cause` prop if `cause` is non-null
465
+ return Object.assign(this, hasForm(cause, Error) ? cause : {}, moreProps, cause ? { message, cause } : { message });
466
+ },
467
+ [fire](props /* { cause, msg, message, ...more } */) { throw this[mod](props); },
468
+ [suppress]() {
469
+ this[Symbol.for('clearing.err.suppressed')] = true;
470
+ if (this.cause) {
471
+ const causes = hasForm(this.cause, Error) ? [this.cause] : this.cause;
472
+ for (const err of causes)
473
+ err[suppress]();
474
+ }
475
+ return this;
476
+ },
477
+ [limn](seen = new Map()) {
478
+ if (seen.has(this))
479
+ return seen.get(this);
480
+ seen.set(this, 'cycle(Error)');
481
+ const { message, stack, cause, ...props } = this;
482
+ return {
483
+ form: getFormName(this),
484
+ msg: message,
485
+ trace: stack?.split('\n').slice(1)[map](v => v.trim() ?? skip) ?? [],
486
+ ...props,
487
+ cause: !cause ? null : cause[limn](seen)
488
+ };
489
+ }
490
+ });
491
+ protoDefs(Promise, {
492
+ $resolve: Promise.resolve,
493
+ $reject: Promise.reject,
494
+ $all: Promise.all,
495
+ $allArr: Promise.all,
496
+ $later: (resolve, reject) => {
497
+ const p = new Promise((...a) => [resolve, reject] = a);
498
+ return Object.assign(p, { resolve, reject });
499
+ },
500
+ $allObj: (obj) => {
501
+ // Need to get `keys` here in case `obj` mutates before resolution
502
+ const keys = Object.keys(obj);
503
+ return Promise.allArr(Object.values(obj)).then(vals => {
504
+ const ret = {};
505
+ for (const [i, k] of keys.entries())
506
+ if (vals[i] !== skip)
507
+ ret[k] = vals[i];
508
+ return ret;
509
+ });
510
+ }
511
+ });
512
+ protoDefs(Set, {
513
+ $stub: { count: () => 0, add: Function.stub, rem: Function.stub, has: () => false, values: () => Array.stub },
514
+ 'delete->': rem,
515
+ [map](fn) {
516
+ const ret = [];
517
+ let ind = 0;
518
+ for (const item of this) {
519
+ const r = fn(item, ind++);
520
+ if (r !== skip)
521
+ ret.push(r);
522
+ }
523
+ return ret;
524
+ },
525
+ [find](fn) {
526
+ for (const val of this)
527
+ if (fn(val))
528
+ return { found: true, val };
529
+ return { found: false, val: null };
530
+ },
531
+ [count]() { return this.size; },
532
+ [empty]() { return !this.size; },
533
+ [toArr](fn) {
534
+ const ret = [];
535
+ let ind = 0;
536
+ for (const item of this) {
537
+ const r = fn(item, ind++);
538
+ if (r !== skip)
539
+ ret.push(r);
540
+ }
541
+ return ret;
542
+ },
543
+ [toObj](fn) {
544
+ const ret = [];
545
+ for (const item of this) {
546
+ const r = fn(item);
547
+ if (r !== skip)
548
+ ret.push(r);
549
+ }
550
+ return Object.fromEntries(ret);
551
+ }
552
+ });
553
+ protoDefs(Map, {
554
+ $stub: { count: () => 0, set: Function.stub, rem: Function.stub, has: () => false, values: () => Array.stub },
555
+ 'set->': add,
556
+ 'delete->': rem,
557
+ [map](fn) {
558
+ const ret = [];
559
+ for (const [k, v] of this) {
560
+ const r = fn(v, k);
561
+ if (r !== skip)
562
+ ret.push(r);
563
+ }
564
+ return Object.fromEntries(ret);
565
+ },
566
+ [find](fn) {
567
+ for (const [k, v] of this)
568
+ if (fn(v, k))
569
+ return { found: true, val: v, key: k };
570
+ return { found: false, val: null, key: null };
571
+ },
572
+ [count]() { return this.size; },
573
+ [empty]() { return !this.size; },
574
+ [toObj](fn) {
575
+ const ret = [];
576
+ for (const [k, v] of this) {
577
+ const r = fn(v, k);
578
+ if (r !== skip)
579
+ ret.push(r);
580
+ }
581
+ return Object.fromEntries(ret);
582
+ },
583
+ [toArr](fn) {
584
+ const ret = [];
585
+ for (const [k, v] of this) {
586
+ const r = fn(v, k);
587
+ if (r !== skip)
588
+ ret.push(r);
589
+ }
590
+ return ret;
591
+ }
592
+ });
593
+ protoDefs(GeneratorFunction, {
594
+ [toArr](fn) { return [...this][map](fn); },
595
+ [toObj](fn) {
596
+ const ret = {};
597
+ for (const v of this) {
598
+ const r = fn(v);
599
+ if (r !== skip)
600
+ ret[r[0]] = r[1];
601
+ }
602
+ return ret;
603
+ }
604
+ });
605
+ });
606
+ applyClearing();
607
+ exports.default = applyClearing;
@@ -0,0 +1,2 @@
1
+ declare const applyClearing: () => void;
2
+ export default applyClearing;