eslint-plugin-react-hooks-extra 1.5.0 → 1.5.1-beta.0

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/dist/index.mjs CHANGED
@@ -2,11 +2,10 @@ import { useHookCollector, isReactHookCall, isUseCallbackCall, isReactHookCallWi
2
2
  import { createRuleForPlugin, parseSchema, ESLintSettingsSchema } from '@eslint-react/shared';
3
3
  import { NodeType, is, getNestedCallExpressions } from '@eslint-react/ast';
4
4
  import { getPragmaFromContext } from '@eslint-react/jsx';
5
- import { F, O } from '@eslint-react/tools';
6
5
  import { findVariable, getVariableInit } from '@eslint-react/var';
7
6
 
8
7
  var name = "eslint-plugin-react-hooks-extra";
9
- var version = "1.5.0";
8
+ var version = "1.5.1-beta.0";
10
9
 
11
10
  const createRule = createRuleForPlugin("hooks-extra");
12
11
 
@@ -46,6 +45,833 @@ var ensureCustomHooksUsingOtherHooks = createRule({
46
45
  }
47
46
  });
48
47
 
48
+ /**
49
+ * Tests if a value is a `function`.
50
+ *
51
+ * @param input - The value to test.
52
+ *
53
+ * @example
54
+ * import { isFunction } from 'effect/Predicate'
55
+ *
56
+ * assert.deepStrictEqual(isFunction(isFunction), true)
57
+ * assert.deepStrictEqual(isFunction("function"), false)
58
+ *
59
+ * @category guards
60
+ * @since 2.0.0
61
+ */
62
+ const isFunction$1 = input => typeof input === "function";
63
+ /**
64
+ * Creates a function that can be used in a data-last (aka `pipe`able) or
65
+ * data-first style.
66
+ *
67
+ * The first parameter to `dual` is either the arity of the uncurried function
68
+ * or a predicate that determines if the function is being used in a data-first
69
+ * or data-last style.
70
+ *
71
+ * Using the arity is the most common use case, but there are some cases where
72
+ * you may want to use a predicate. For example, if you have a function that
73
+ * takes an optional argument, you can use a predicate to determine if the
74
+ * function is being used in a data-first or data-last style.
75
+ *
76
+ * @param arity - Either the arity of the uncurried function or a predicate
77
+ * which determines if the function is being used in a data-first
78
+ * or data-last style.
79
+ * @param body - The definition of the uncurried function.
80
+ *
81
+ * @example
82
+ * import { dual, pipe } from "effect/Function"
83
+ *
84
+ * // Exampe using arity to determine data-first or data-last style
85
+ * const sum: {
86
+ * (that: number): (self: number) => number
87
+ * (self: number, that: number): number
88
+ * } = dual(2, (self: number, that: number): number => self + that)
89
+ *
90
+ * assert.deepStrictEqual(sum(2, 3), 5)
91
+ * assert.deepStrictEqual(pipe(2, sum(3)), 5)
92
+ *
93
+ * // Example using a predicate to determine data-first or data-last style
94
+ * const sum2: {
95
+ * (that: number): (self: number) => number
96
+ * (self: number, that: number): number
97
+ * } = dual((args) => args.length === 1, (self: number, that: number): number => self + that)
98
+ *
99
+ * assert.deepStrictEqual(sum(2, 3), 5)
100
+ * assert.deepStrictEqual(pipe(2, sum(3)), 5)
101
+ *
102
+ * @since 2.0.0
103
+ */
104
+ const dual = function (arity, body) {
105
+ if (typeof arity === "function") {
106
+ return function () {
107
+ if (arity(arguments)) {
108
+ // @ts-expect-error
109
+ return body.apply(this, arguments);
110
+ }
111
+ return self => body(self, ...arguments);
112
+ };
113
+ }
114
+ switch (arity) {
115
+ case 0:
116
+ case 1:
117
+ throw new RangeError(`Invalid arity ${arity}`);
118
+ case 2:
119
+ return function (a, b) {
120
+ if (arguments.length >= 2) {
121
+ return body(a, b);
122
+ }
123
+ return function (self) {
124
+ return body(self, a);
125
+ };
126
+ };
127
+ case 3:
128
+ return function (a, b, c) {
129
+ if (arguments.length >= 3) {
130
+ return body(a, b, c);
131
+ }
132
+ return function (self) {
133
+ return body(self, a, b);
134
+ };
135
+ };
136
+ case 4:
137
+ return function (a, b, c, d) {
138
+ if (arguments.length >= 4) {
139
+ return body(a, b, c, d);
140
+ }
141
+ return function (self) {
142
+ return body(self, a, b, c);
143
+ };
144
+ };
145
+ case 5:
146
+ return function (a, b, c, d, e) {
147
+ if (arguments.length >= 5) {
148
+ return body(a, b, c, d, e);
149
+ }
150
+ return function (self) {
151
+ return body(self, a, b, c, d);
152
+ };
153
+ };
154
+ default:
155
+ return function () {
156
+ if (arguments.length >= arity) {
157
+ // @ts-expect-error
158
+ return body.apply(this, arguments);
159
+ }
160
+ const args = arguments;
161
+ return function (self) {
162
+ return body(self, ...args);
163
+ };
164
+ };
165
+ }
166
+ };
167
+ /**
168
+ * Reverses the order of arguments for a curried function.
169
+ *
170
+ * @param f - A curried function that takes multiple arguments.
171
+ *
172
+ * @example
173
+ * import { flip } from "effect/Function"
174
+ *
175
+ * const f = (a: number) => (b: string) => a - b.length
176
+ *
177
+ * assert.deepStrictEqual(flip(f)('aaa')(2), -1)
178
+ *
179
+ * @since 2.0.0
180
+ */
181
+ const flip = f => (...b) => (...a) => f(...a)(...b);
182
+ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
183
+ switch (arguments.length) {
184
+ case 1:
185
+ return a;
186
+ case 2:
187
+ return ab(a);
188
+ case 3:
189
+ return bc(ab(a));
190
+ case 4:
191
+ return cd(bc(ab(a)));
192
+ case 5:
193
+ return de(cd(bc(ab(a))));
194
+ case 6:
195
+ return ef(de(cd(bc(ab(a)))));
196
+ case 7:
197
+ return fg(ef(de(cd(bc(ab(a))))));
198
+ case 8:
199
+ return gh(fg(ef(de(cd(bc(ab(a)))))));
200
+ case 9:
201
+ return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
202
+ default:
203
+ {
204
+ let ret = arguments[0];
205
+ for (let i = 1; i < arguments.length; i++) {
206
+ ret = arguments[i](ret);
207
+ }
208
+ return ret;
209
+ }
210
+ }
211
+ }
212
+
213
+ const moduleVersion = "2.2.2";
214
+
215
+ /**
216
+ * @since 2.0.0
217
+ */
218
+ const globalStoreId = /*#__PURE__*/Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
219
+ if (!(globalStoreId in globalThis)) {
220
+ globalThis[globalStoreId] = /*#__PURE__*/new Map();
221
+ }
222
+ const globalStore = globalThis[globalStoreId];
223
+ /**
224
+ * @since 2.0.0
225
+ */
226
+ const globalValue = (id, compute) => {
227
+ if (!globalStore.has(id)) {
228
+ globalStore.set(id, compute());
229
+ }
230
+ return globalStore.get(id);
231
+ };
232
+
233
+ /**
234
+ * @since 2.0.0
235
+ */
236
+ /**
237
+ * Tests if a value is a `function`.
238
+ *
239
+ * @param input - The value to test.
240
+ *
241
+ * @example
242
+ * import { isFunction } from "effect/Predicate"
243
+ *
244
+ * assert.deepStrictEqual(isFunction(isFunction), true)
245
+ *
246
+ * assert.deepStrictEqual(isFunction("function"), false)
247
+ *
248
+ * @category guards
249
+ * @since 2.0.0
250
+ */
251
+ const isFunction = isFunction$1;
252
+ const isRecordOrArray = input => typeof input === "object" && input !== null;
253
+ /**
254
+ * Tests if a value is an `object`.
255
+ *
256
+ * @param input - The value to test.
257
+ *
258
+ * @example
259
+ * import { isObject } from "effect/Predicate"
260
+ *
261
+ * assert.deepStrictEqual(isObject({}), true)
262
+ * assert.deepStrictEqual(isObject([]), true)
263
+ *
264
+ * assert.deepStrictEqual(isObject(null), false)
265
+ * assert.deepStrictEqual(isObject(undefined), false)
266
+ *
267
+ * @category guards
268
+ * @since 2.0.0
269
+ */
270
+ const isObject = input => isRecordOrArray(input) || isFunction(input);
271
+ /**
272
+ * Checks whether a value is an `object` containing a specified property key.
273
+ *
274
+ * @param property - The field to check within the object.
275
+ * @param self - The value to examine.
276
+ *
277
+ * @category guards
278
+ * @since 2.0.0
279
+ */
280
+ const hasProperty = /*#__PURE__*/dual(2, (self, property) => isObject(self) && property in self);
281
+ /**
282
+ * A guard that succeeds when the input is `null` or `undefined`.
283
+ *
284
+ * @param input - The value to test.
285
+ *
286
+ * @example
287
+ * import { isNullable } from "effect/Predicate"
288
+ *
289
+ * assert.deepStrictEqual(isNullable(null), true)
290
+ * assert.deepStrictEqual(isNullable(undefined), true)
291
+ *
292
+ * assert.deepStrictEqual(isNullable({}), false)
293
+ * assert.deepStrictEqual(isNullable([]), false)
294
+ *
295
+ * @category guards
296
+ * @since 2.0.0
297
+ */
298
+ const isNullable = input => input === null || input === undefined;
299
+
300
+ /**
301
+ * @since 2.0.0
302
+ */
303
+ const defaultIncHi = 0x14057b7e;
304
+ const defaultIncLo = 0xf767814f;
305
+ const MUL_HI = 0x5851f42d >>> 0;
306
+ const MUL_LO = 0x4c957f2d >>> 0;
307
+ const BIT_53 = 9007199254740992.0;
308
+ const BIT_27 = 134217728.0;
309
+ /**
310
+ * PCG is a family of simple fast space-efficient statistically good algorithms
311
+ * for random number generation. Unlike many general-purpose RNGs, they are also
312
+ * hard to predict.
313
+ *
314
+ * @category model
315
+ * @since 2.0.0
316
+ */
317
+ class PCGRandom {
318
+ _state;
319
+ constructor(seedHi, seedLo, incHi, incLo) {
320
+ if (isNullable(seedLo) && isNullable(seedHi)) {
321
+ seedLo = Math.random() * 0xffffffff >>> 0;
322
+ seedHi = 0;
323
+ } else if (isNullable(seedLo)) {
324
+ seedLo = seedHi;
325
+ seedHi = 0;
326
+ }
327
+ if (isNullable(incLo) && isNullable(incHi)) {
328
+ incLo = this._state ? this._state[3] : defaultIncLo;
329
+ incHi = this._state ? this._state[2] : defaultIncHi;
330
+ } else if (isNullable(incLo)) {
331
+ incLo = incHi;
332
+ incHi = 0;
333
+ }
334
+ this._state = new Int32Array([0, 0, incHi >>> 0, ((incLo || 0) | 1) >>> 0]);
335
+ this._next();
336
+ add64(this._state, this._state[0], this._state[1], seedHi >>> 0, seedLo >>> 0);
337
+ this._next();
338
+ return this;
339
+ }
340
+ /**
341
+ * Returns a copy of the internal state of this random number generator as a
342
+ * JavaScript Array.
343
+ *
344
+ * @category getters
345
+ * @since 2.0.0
346
+ */
347
+ getState() {
348
+ return [this._state[0], this._state[1], this._state[2], this._state[3]];
349
+ }
350
+ /**
351
+ * Restore state previously retrieved using `getState()`.
352
+ *
353
+ * @since 2.0.0
354
+ */
355
+ setState(state) {
356
+ this._state[0] = state[0];
357
+ this._state[1] = state[1];
358
+ this._state[2] = state[2];
359
+ this._state[3] = state[3] | 1;
360
+ }
361
+ /**
362
+ * Get a uniformly distributed 32 bit integer between [0, max).
363
+ *
364
+ * @category getter
365
+ * @since 2.0.0
366
+ */
367
+ integer(max) {
368
+ if (!max) {
369
+ return this._next();
370
+ }
371
+ max = max >>> 0;
372
+ if ((max & max - 1) === 0) {
373
+ return this._next() & max - 1; // fast path for power of 2
374
+ }
375
+ let num = 0;
376
+ const skew = (-max >>> 0) % max >>> 0;
377
+ for (num = this._next(); num < skew; num = this._next()) {
378
+ // this loop will rarely execute more than twice,
379
+ // and is intentionally empty
380
+ }
381
+ return num % max;
382
+ }
383
+ /**
384
+ * Get a uniformly distributed IEEE-754 double between 0.0 and 1.0, with
385
+ * 53 bits of precision (every bit of the mantissa is randomized).
386
+ *
387
+ * @category getters
388
+ * @since 2.0.0
389
+ */
390
+ number() {
391
+ const hi = (this._next() & 0x03ffffff) * 1.0;
392
+ const lo = (this._next() & 0x07ffffff) * 1.0;
393
+ return (hi * BIT_27 + lo) / BIT_53;
394
+ }
395
+ /** @internal */
396
+ _next() {
397
+ // save current state (what we'll use for this number)
398
+ const oldHi = this._state[0] >>> 0;
399
+ const oldLo = this._state[1] >>> 0;
400
+ // churn LCG.
401
+ mul64(this._state, oldHi, oldLo, MUL_HI, MUL_LO);
402
+ add64(this._state, this._state[0], this._state[1], this._state[2], this._state[3]);
403
+ // get least sig. 32 bits of ((oldstate >> 18) ^ oldstate) >> 27
404
+ let xsHi = oldHi >>> 18;
405
+ let xsLo = (oldLo >>> 18 | oldHi << 14) >>> 0;
406
+ xsHi = (xsHi ^ oldHi) >>> 0;
407
+ xsLo = (xsLo ^ oldLo) >>> 0;
408
+ const xorshifted = (xsLo >>> 27 | xsHi << 5) >>> 0;
409
+ // rotate xorshifted right a random amount, based on the most sig. 5 bits
410
+ // bits of the old state.
411
+ const rot = oldHi >>> 27;
412
+ const rot2 = (-rot >>> 0 & 31) >>> 0;
413
+ return (xorshifted >>> rot | xorshifted << rot2) >>> 0;
414
+ }
415
+ }
416
+ function mul64(out, aHi, aLo, bHi, bLo) {
417
+ let c1 = (aLo >>> 16) * (bLo & 0xffff) >>> 0;
418
+ let c0 = (aLo & 0xffff) * (bLo >>> 16) >>> 0;
419
+ let lo = (aLo & 0xffff) * (bLo & 0xffff) >>> 0;
420
+ let hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0;
421
+ c0 = c0 << 16 >>> 0;
422
+ lo = lo + c0 >>> 0;
423
+ if (lo >>> 0 < c0 >>> 0) {
424
+ hi = hi + 1 >>> 0;
425
+ }
426
+ c1 = c1 << 16 >>> 0;
427
+ lo = lo + c1 >>> 0;
428
+ if (lo >>> 0 < c1 >>> 0) {
429
+ hi = hi + 1 >>> 0;
430
+ }
431
+ hi = hi + Math.imul(aLo, bHi) >>> 0;
432
+ hi = hi + Math.imul(aHi, bLo) >>> 0;
433
+ out[0] = hi;
434
+ out[1] = lo;
435
+ }
436
+ // add two 64 bit numbers (given in parts), and store the result in `out`.
437
+ function add64(out, aHi, aLo, bHi, bLo) {
438
+ let hi = aHi + bHi >>> 0;
439
+ const lo = aLo + bLo >>> 0;
440
+ if (lo >>> 0 < aLo >>> 0) {
441
+ hi = hi + 1 | 0;
442
+ }
443
+ out[0] = hi;
444
+ out[1] = lo;
445
+ }
446
+
447
+ /**
448
+ * @since 2.0.0
449
+ */
450
+ /** @internal */
451
+ const randomHashCache = /*#__PURE__*/globalValue( /*#__PURE__*/Symbol.for("effect/Hash/randomHashCache"), () => new WeakMap());
452
+ /** @internal */
453
+ const pcgr = /*#__PURE__*/globalValue( /*#__PURE__*/Symbol.for("effect/Hash/pcgr"), () => new PCGRandom());
454
+ /**
455
+ * @since 2.0.0
456
+ * @category symbols
457
+ */
458
+ const symbol$1 = /*#__PURE__*/Symbol.for("effect/Hash");
459
+ /**
460
+ * @since 2.0.0
461
+ * @category hashing
462
+ */
463
+ const hash = self => {
464
+ switch (typeof self) {
465
+ case "number":
466
+ return number(self);
467
+ case "bigint":
468
+ return string(self.toString(10));
469
+ case "boolean":
470
+ return string(String(self));
471
+ case "symbol":
472
+ return string(String(self));
473
+ case "string":
474
+ return string(self);
475
+ case "undefined":
476
+ return string("undefined");
477
+ case "function":
478
+ case "object":
479
+ {
480
+ if (self === null) {
481
+ return string("null");
482
+ }
483
+ if (isHash(self)) {
484
+ return self[symbol$1]();
485
+ } else {
486
+ return random(self);
487
+ }
488
+ }
489
+ default:
490
+ throw new Error(`BUG: unhandled typeof ${typeof self} - please report an issue at https://github.com/Effect-TS/effect/issues`);
491
+ }
492
+ };
493
+ /**
494
+ * @since 2.0.0
495
+ * @category hashing
496
+ */
497
+ const random = self => {
498
+ if (!randomHashCache.has(self)) {
499
+ randomHashCache.set(self, number(pcgr.integer(Number.MAX_SAFE_INTEGER)));
500
+ }
501
+ return randomHashCache.get(self);
502
+ };
503
+ /**
504
+ * @since 2.0.0
505
+ * @category hashing
506
+ */
507
+ const combine = b => self => self * 53 ^ b;
508
+ /**
509
+ * @since 2.0.0
510
+ * @category hashing
511
+ */
512
+ const optimize = n => n & 0xbfffffff | n >>> 1 & 0x40000000;
513
+ /**
514
+ * @since 2.0.0
515
+ * @category guards
516
+ */
517
+ const isHash = u => hasProperty(u, symbol$1);
518
+ /**
519
+ * @since 2.0.0
520
+ * @category hashing
521
+ */
522
+ const number = n => {
523
+ if (n !== n || n === Infinity) {
524
+ return 0;
525
+ }
526
+ let h = n | 0;
527
+ if (h !== n) {
528
+ h ^= n * 0xffffffff;
529
+ }
530
+ while (n > 0xffffffff) {
531
+ h ^= n /= 0xffffffff;
532
+ }
533
+ return optimize(n);
534
+ };
535
+ /**
536
+ * @since 2.0.0
537
+ * @category hashing
538
+ */
539
+ const string = str => {
540
+ let h = 5381,
541
+ i = str.length;
542
+ while (i) {
543
+ h = h * 33 ^ str.charCodeAt(--i);
544
+ }
545
+ return optimize(h);
546
+ };
547
+
548
+ /**
549
+ * @since 2.0.0
550
+ * @category symbols
551
+ */
552
+ const symbol = /*#__PURE__*/Symbol.for("effect/Equal");
553
+ function equals() {
554
+ if (arguments.length === 1) {
555
+ return self => compareBoth(self, arguments[0]);
556
+ }
557
+ return compareBoth(arguments[0], arguments[1]);
558
+ }
559
+ function compareBoth(self, that) {
560
+ if (self === that) {
561
+ return true;
562
+ }
563
+ const selfType = typeof self;
564
+ if (selfType !== typeof that) {
565
+ return false;
566
+ }
567
+ if ((selfType === "object" || selfType === "function") && self !== null && that !== null) {
568
+ if (isEqual(self) && isEqual(that)) {
569
+ return hash(self) === hash(that) && self[symbol](that);
570
+ }
571
+ }
572
+ return false;
573
+ }
574
+ /**
575
+ * @since 2.0.0
576
+ * @category guards
577
+ */
578
+ const isEqual = u => hasProperty(u, symbol);
579
+
580
+ /**
581
+ * @since 2.0.0
582
+ */
583
+ /**
584
+ * @since 2.0.0
585
+ * @category symbols
586
+ */
587
+ const NodeInspectSymbol = /*#__PURE__*/Symbol.for("nodejs.util.inspect.custom");
588
+ /**
589
+ * @since 2.0.0
590
+ */
591
+ const toJSON = x => {
592
+ if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) {
593
+ return x.toJSON();
594
+ } else if (Array.isArray(x)) {
595
+ return x.map(toJSON);
596
+ }
597
+ return x;
598
+ };
599
+ /**
600
+ * @since 2.0.0
601
+ */
602
+ const format = x => JSON.stringify(x, null, 2);
603
+
604
+ /**
605
+ * @since 2.0.0
606
+ */
607
+ /**
608
+ * @since 2.0.0
609
+ */
610
+ const pipeArguments = (self, args) => {
611
+ switch (args.length) {
612
+ case 1:
613
+ return args[0](self);
614
+ case 2:
615
+ return args[1](args[0](self));
616
+ case 3:
617
+ return args[2](args[1](args[0](self)));
618
+ case 4:
619
+ return args[3](args[2](args[1](args[0](self))));
620
+ case 5:
621
+ return args[4](args[3](args[2](args[1](args[0](self)))));
622
+ case 6:
623
+ return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
624
+ case 7:
625
+ return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
626
+ case 8:
627
+ return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
628
+ case 9:
629
+ return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
630
+ default:
631
+ {
632
+ let ret = self;
633
+ for (let i = 0, len = args.length; i < len; i++) {
634
+ ret = args[i](ret);
635
+ }
636
+ return ret;
637
+ }
638
+ }
639
+ };
640
+
641
+ /** @internal */
642
+ const EffectTypeId = /*#__PURE__*/Symbol.for("effect/Effect");
643
+ /** @internal */
644
+ const StreamTypeId = /*#__PURE__*/Symbol.for("effect/Stream");
645
+ /** @internal */
646
+ const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
647
+ /** @internal */
648
+ const ChannelTypeId = /*#__PURE__*/Symbol.for("effect/Channel");
649
+ /** @internal */
650
+ const effectVariance = {
651
+ /* c8 ignore next */
652
+ _R: _ => _,
653
+ /* c8 ignore next */
654
+ _E: _ => _,
655
+ /* c8 ignore next */
656
+ _A: _ => _,
657
+ _V: moduleVersion
658
+ };
659
+ const sinkVariance = {
660
+ /* c8 ignore next */
661
+ _R: _ => _,
662
+ /* c8 ignore next */
663
+ _E: _ => _,
664
+ /* c8 ignore next */
665
+ _In: _ => _,
666
+ /* c8 ignore next */
667
+ _L: _ => _,
668
+ /* c8 ignore next */
669
+ _Z: _ => _
670
+ };
671
+ const channelVariance = {
672
+ /* c8 ignore next */
673
+ _Env: _ => _,
674
+ /* c8 ignore next */
675
+ _InErr: _ => _,
676
+ /* c8 ignore next */
677
+ _InElem: _ => _,
678
+ /* c8 ignore next */
679
+ _InDone: _ => _,
680
+ /* c8 ignore next */
681
+ _OutErr: _ => _,
682
+ /* c8 ignore next */
683
+ _OutElem: _ => _,
684
+ /* c8 ignore next */
685
+ _OutDone: _ => _
686
+ };
687
+ /** @internal */
688
+ const EffectPrototype = {
689
+ [EffectTypeId]: effectVariance,
690
+ [StreamTypeId]: effectVariance,
691
+ [SinkTypeId]: sinkVariance,
692
+ [ChannelTypeId]: channelVariance,
693
+ [symbol](that) {
694
+ return this === that;
695
+ },
696
+ [symbol$1]() {
697
+ return random(this);
698
+ },
699
+ pipe() {
700
+ return pipeArguments(this, arguments);
701
+ }
702
+ };
703
+
704
+ /**
705
+ * @since 2.0.0
706
+ */
707
+ const TypeId = /*#__PURE__*/Symbol.for("effect/Option");
708
+ const CommonProto = {
709
+ ...EffectPrototype,
710
+ [TypeId]: {
711
+ _A: _ => _
712
+ },
713
+ [NodeInspectSymbol]() {
714
+ return this.toJSON();
715
+ },
716
+ toString() {
717
+ return format(this.toJSON());
718
+ }
719
+ };
720
+ const SomeProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonProto), {
721
+ _tag: "Some",
722
+ _op: "Some",
723
+ [symbol](that) {
724
+ return isOption(that) && isSome(that) && equals(that.value, this.value);
725
+ },
726
+ [symbol$1]() {
727
+ return combine(hash(this._tag))(hash(this.value));
728
+ },
729
+ toJSON() {
730
+ return {
731
+ _id: "Option",
732
+ _tag: this._tag,
733
+ value: toJSON(this.value)
734
+ };
735
+ }
736
+ });
737
+ const NoneProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonProto), {
738
+ _tag: "None",
739
+ _op: "None",
740
+ [symbol](that) {
741
+ return isOption(that) && isNone$1(that);
742
+ },
743
+ [symbol$1]() {
744
+ return combine(hash(this._tag));
745
+ },
746
+ toJSON() {
747
+ return {
748
+ _id: "Option",
749
+ _tag: this._tag
750
+ };
751
+ }
752
+ });
753
+ /** @internal */
754
+ const isOption = input => hasProperty(input, TypeId);
755
+ /** @internal */
756
+ const isNone$1 = fa => fa._tag === "None";
757
+ /** @internal */
758
+ const isSome = fa => fa._tag === "Some";
759
+ /** @internal */
760
+ const none$1 = /*#__PURE__*/Object.create(NoneProto);
761
+ /** @internal */
762
+ const some$1 = value => {
763
+ const a = Object.create(SomeProto);
764
+ a.value = value;
765
+ return a;
766
+ };
767
+
768
+ /**
769
+ * Creates a new `Option` that represents the absence of a value.
770
+ *
771
+ * @category constructors
772
+ * @since 2.0.0
773
+ */
774
+ const none = () => none$1;
775
+ /**
776
+ * Creates a new `Option` that wraps the given value.
777
+ *
778
+ * @param value - The value to wrap.
779
+ *
780
+ * @category constructors
781
+ * @since 2.0.0
782
+ */
783
+ const some = some$1;
784
+ /**
785
+ * Determine if a `Option` is a `None`.
786
+ *
787
+ * @param self - The `Option` to check.
788
+ *
789
+ * @example
790
+ * import { some, none, isNone } from 'effect/Option'
791
+ *
792
+ * assert.deepStrictEqual(isNone(some(1)), false)
793
+ * assert.deepStrictEqual(isNone(none()), true)
794
+ *
795
+ * @category guards
796
+ * @since 2.0.0
797
+ */
798
+ const isNone = isNone$1;
799
+ /**
800
+ * Maps the `Some` side of an `Option` value to a new `Option` value.
801
+ *
802
+ * @param self - An `Option` to map
803
+ * @param f - The function to map over the value of the `Option`
804
+ *
805
+ * @category mapping
806
+ * @since 2.0.0
807
+ */
808
+ const map = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
809
+ /**
810
+ * Applies a function to the value of an `Option` and flattens the result, if the input is `Some`.
811
+ *
812
+ * @category sequencing
813
+ * @since 2.0.0
814
+ */
815
+ const flatMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : f(self.value));
816
+ /**
817
+ * Maps over the value of an `Option` and filters out `None`s.
818
+ *
819
+ * Useful when in addition to filtering you also want to change the type of the `Option`.
820
+ *
821
+ * @param self - The `Option` to map over.
822
+ * @param f - A function to apply to the value of the `Option`.
823
+ *
824
+ * @example
825
+ * import * as O from "effect/Option"
826
+ *
827
+ * const evenNumber = (n: number) => n % 2 === 0 ? O.some(n) : O.none()
828
+ *
829
+ * assert.deepStrictEqual(O.filterMap(O.none(), evenNumber), O.none())
830
+ * assert.deepStrictEqual(O.filterMap(O.some(3), evenNumber), O.none())
831
+ * assert.deepStrictEqual(O.filterMap(O.some(2), evenNumber), O.some(2))
832
+ *
833
+ * @category filtering
834
+ * @since 2.0.0
835
+ */
836
+ const filterMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : f(self.value));
837
+ /**
838
+ * Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
839
+ *
840
+ * If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
841
+ *
842
+ * @param predicate - A predicate function to apply to the `Option` value.
843
+ * @param fb - The `Option` to filter.
844
+ *
845
+ * @example
846
+ * import * as O from "effect/Option"
847
+ *
848
+ * // predicate
849
+ * const isEven = (n: number) => n % 2 === 0
850
+ *
851
+ * assert.deepStrictEqual(O.filter(O.none(), isEven), O.none())
852
+ * assert.deepStrictEqual(O.filter(O.some(3), isEven), O.none())
853
+ * assert.deepStrictEqual(O.filter(O.some(2), isEven), O.some(2))
854
+ *
855
+ * // refinement
856
+ * const isNumber = (v: unknown): v is number => typeof v === "number"
857
+ *
858
+ * assert.deepStrictEqual(O.filter(O.none(), isNumber), O.none())
859
+ * assert.deepStrictEqual(O.filter(O.some('hello'), isNumber), O.none())
860
+ * assert.deepStrictEqual(O.filter(O.some(2), isNumber), O.some(2))
861
+ *
862
+ * @category filtering
863
+ * @since 2.0.0
864
+ */
865
+ const filter = /*#__PURE__*/dual(2, (self, predicate) => filterMap(self, b => predicate(b) ? some$1(b) : none$1));
866
+
867
+ /**
868
+ * Bun currently has a bug where `setTimeout` doesn't behave correctly with a 0ms delay.
869
+ *
870
+ * @see https://github.com/oven-sh/bun/issues/3333
871
+ */
872
+ /** @internal */
873
+ typeof process === "undefined" ? false : !!process?.isBun;
874
+
49
875
  var match;
50
876
  function n(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function t(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return (e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return n(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return "Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var u=0;return function(){return u>=t.length?{done:!0}:{done:!1,value:t[u++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r=Symbol.for("@ts-pattern/matcher"),e=Symbol.for("@ts-pattern/isVariadic"),u="@ts-pattern/anonymous-select-key",i=function(n){return Boolean(n&&"object"==typeof n)},o=function(n){return n&&!!n[r]},c=function n(u,c,a){if(o(u)){var f=u[r]().match(c),s=f.matched,l=f.selections;return s&&l&&Object.keys(l).forEach(function(n){return a(n,l[n])}),s}if(i(u)){if(!i(c))return !1;if(Array.isArray(u)){if(!Array.isArray(c))return !1;for(var h,v=[],g=[],m=[],p=t(u.keys());!(h=p()).done;){var y=u[h.value];o(y)&&y[e]?m.push(y):m.length?g.push(y):v.push(y);}if(m.length){if(m.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(c.length<v.length+g.length)return !1;var d=c.slice(0,v.length),b=0===g.length?[]:c.slice(-g.length),w=c.slice(v.length,0===g.length?Infinity:-g.length);return v.every(function(t,r){return n(t,d[r],a)})&&g.every(function(t,r){return n(t,b[r],a)})&&(0===m.length||n(m[0],w,a))}return u.length===c.length&&u.every(function(t,r){return n(t,c[r],a)})}return Object.keys(u).every(function(t){var e,i=u[t];return (t in c||o(e=i)&&"optional"===e[r]().matcherType)&&n(i,c[t],a)})}return Object.is(c,u)},a=function n(t){var e,u,c;return i(t)?o(t)?null!=(e=null==(u=(c=t[r]()).getSelectionKeys)?void 0:u.call(c))?e:[]:Array.isArray(t)?f(t,n):f(Object.values(t),n):[]},f=function(n,t){return n.reduce(function(n,r){return n.concat(t(r))},[])};function l(n){return Object.assign(n,{optional:function(){return v(n)},and:function(t){return p(n,t)},or:function(t){return y(n,t)},select:function(t){return void 0===t?b(n):b(t,n)}})}function v(n){var t;return l(((t={})[r]=function(){return {match:function(t){var r={},e=function(n,t){r[n]=t;};return void 0===t?(a(n).forEach(function(n){return e(n,void 0)}),{matched:!0,selections:r}):{matched:c(n,t,e),selections:r}},getSelectionKeys:function(){return a(n)},matcherType:"optional"}},t))}function p(){var n,t=[].slice.call(arguments);return l(((n={})[r]=function(){return {match:function(n){var r={},e=function(n,t){r[n]=t;};return {matched:t.every(function(t){return c(t,n,e)}),selections:r}},getSelectionKeys:function(){return f(t,a)},matcherType:"and"}},n))}function y(){var n,t=[].slice.call(arguments);return l(((n={})[r]=function(){return {match:function(n){var r={},e=function(n,t){r[n]=t;};return f(t,a).forEach(function(n){return e(n,void 0)}),{matched:t.some(function(t){return c(t,n,e)}),selections:r}},getSelectionKeys:function(){return f(t,a)},matcherType:"or"}},n))}function d(n){var t;return (t={})[r]=function(){return {match:function(t){return {matched:Boolean(n(t))}}}},t}function b(){var n,t=[].slice.call(arguments),e="string"==typeof t[0]?t[0]:void 0,i=2===t.length?t[1]:"string"==typeof t[0]?void 0:t[0];return l(((n={})[r]=function(){return {match:function(n){var t,r=((t={})[null!=e?e:u]=n,t);return {matched:void 0===i||c(i,n,function(n,t){r[n]=t;}),selections:r}},getSelectionKeys:function(){return [null!=e?e:u].concat(void 0===i?[]:a(i))}}},n))}function w(n){return "number"==typeof n}function S(n){return "string"==typeof n}function j(n){return "bigint"==typeof n}l(d(function(n){return !0}));(function n(t){return Object.assign(l(t),{startsWith:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&n.startsWith(e)}))));var e;},endsWith:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&n.endsWith(e)}))));var e;},minLength:function(r){return n(p(t,function(n){return d(function(t){return S(t)&&t.length>=n})}(r)))},maxLength:function(r){return n(p(t,function(n){return d(function(t){return S(t)&&t.length<=n})}(r)))},includes:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&n.includes(e)}))));var e;},regex:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&Boolean(n.match(e))}))));var e;}})})(d(S));(function n(t){return Object.assign(l(t),{between:function(r,e){return n(p(t,function(n,t){return d(function(r){return w(r)&&n<=r&&t>=r})}(r,e)))},lt:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t<n})}(r)))},gt:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t>n})}(r)))},lte:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t<=n})}(r)))},gte:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t>=n})}(r)))},int:function(){return n(p(t,d(function(n){return w(n)&&Number.isInteger(n)})))},finite:function(){return n(p(t,d(function(n){return w(n)&&Number.isFinite(n)})))},positive:function(){return n(p(t,d(function(n){return w(n)&&n>0})))},negative:function(){return n(p(t,d(function(n){return w(n)&&n<0})))}})})(d(w));(function n(t){return Object.assign(l(t),{between:function(r,e){return n(p(t,function(n,t){return d(function(r){return j(r)&&n<=r&&t>=r})}(r,e)))},lt:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t<n})}(r)))},gt:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t>n})}(r)))},lte:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t<=n})}(r)))},gte:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t>=n})}(r)))},positive:function(){return n(p(t,d(function(n){return j(n)&&n>0})))},negative:function(){return n(p(t,d(function(n){return j(n)&&n<0})))}})})(d(j));l(d(function(n){return "boolean"==typeof n}));l(d(function(n){return "symbol"==typeof n}));l(d(function(n){return null==n}));var I={matched:!1,value:void 0},_=/*#__PURE__*/function(){function n(n,t){this.input=void 0,this.state=void 0,this.input=n,this.state=t;}var t=n.prototype;return t.with=function(){var t=this,r=[].slice.call(arguments);if(this.state.matched)return this;var e=r[r.length-1],i=[r[0]],o=void 0;3===r.length&&"function"==typeof r[1]?o=r[1]:r.length>2&&i.push.apply(i,r.slice(1,r.length-1));var a=!1,f={},s=function(n,t){a=!0,f[n]=t;},l=!i.some(function(n){return c(n,t.input,s)})||o&&!Boolean(o(this.input))?I:{matched:!0,value:e(a?u in f?f[u]:f:this.input,this.input)};return new n(this.input,l)},t.when=function(t,r){if(this.state.matched)return this;var e=Boolean(t(this.input));return new n(this.input,e?{matched:!0,value:r(this.input,this.input)}:I)},t.otherwise=function(n){return this.state.matched?this.state.value:n(this.input)},t.exhaustive=function(){if(this.state.matched)return this.state.value;var n;try{n=JSON.stringify(this.input);}catch(t){n=this.input;}throw new Error("Pattern matching error: no pattern matches value "+n)},t.run=function(){return this.exhaustive()},t.returnType=function(){return this},n}();match = function(n){return new _(n,I)};
51
877
 
@@ -71,7 +897,7 @@ var ensureUseCallbackHasNonEmptyDeps = createRule({
71
897
  CallExpression (node) {
72
898
  const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope();
73
899
  if (!isReactHookCall(node)) return;
74
- if (!isUseCallbackCall(node, context, pragma) && !alias.some(F.flip(isReactHookCallWithNameLoose)(node))) {
900
+ if (!isUseCallbackCall(node, context, pragma) && !alias.some(flip(isReactHookCallWithNameLoose)(node))) {
75
901
  return;
76
902
  }
77
903
  const [_, deps] = node.arguments;
@@ -82,17 +908,17 @@ var ensureUseCallbackHasNonEmptyDeps = createRule({
82
908
  });
83
909
  return;
84
910
  }
85
- const maybeDescriptor = F.pipe(match(deps).with({
911
+ const maybeDescriptor = pipe(match(deps).with({
86
912
  type: NodeType.ArrayExpression
87
- }, O.some).with({
913
+ }, some).with({
88
914
  type: NodeType.Identifier
89
915
  }, (n)=>{
90
- return F.pipe(findVariable(n.name, initialScope), O.flatMap(getVariableInit(0)), O.filter(is(NodeType.ArrayExpression)));
91
- }).otherwise(O.none), O.filter((x)=>x.elements.length === 0), O.map(()=>({
916
+ return pipe(findVariable(n.name, initialScope), flatMap(getVariableInit(0)), filter(is(NodeType.ArrayExpression)));
917
+ }).otherwise(none), filter((x)=>x.elements.length === 0), map(()=>({
92
918
  node,
93
919
  messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS"
94
920
  })));
95
- O.map(maybeDescriptor, context.report);
921
+ map(maybeDescriptor, context.report);
96
922
  }
97
923
  };
98
924
  }
@@ -120,7 +946,7 @@ var ensureUseMemoHasNonEmptyDeps = createRule({
120
946
  CallExpression (node) {
121
947
  const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope();
122
948
  if (!isReactHookCall(node)) return;
123
- if (!isUseMemoCall(node, context, pragma) && !alias.some(F.flip(isReactHookCallWithNameLoose)(node))) return;
949
+ if (!isUseMemoCall(node, context, pragma) && !alias.some(flip(isReactHookCallWithNameLoose)(node))) return;
124
950
  const [_, deps] = node.arguments;
125
951
  if (!deps) {
126
952
  context.report({
@@ -129,17 +955,17 @@ var ensureUseMemoHasNonEmptyDeps = createRule({
129
955
  });
130
956
  return;
131
957
  }
132
- const maybeDescriptor = F.pipe(match(deps).with({
958
+ const maybeDescriptor = pipe(match(deps).with({
133
959
  type: NodeType.ArrayExpression
134
- }, O.some).with({
960
+ }, some).with({
135
961
  type: NodeType.Identifier
136
962
  }, (n)=>{
137
- return F.pipe(findVariable(n.name, initialScope), O.flatMap(getVariableInit(0)), O.filter(is(NodeType.ArrayExpression)));
138
- }).otherwise(O.none), O.filter((x)=>x.elements.length === 0), O.map(()=>({
963
+ return pipe(findVariable(n.name, initialScope), flatMap(getVariableInit(0)), filter(is(NodeType.ArrayExpression)));
964
+ }).otherwise(none), filter((x)=>x.elements.length === 0), map(()=>({
139
965
  node,
140
966
  messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS"
141
967
  })));
142
- O.map(maybeDescriptor, context.report);
968
+ map(maybeDescriptor, context.report);
143
969
  }
144
970
  };
145
971
  }
@@ -174,7 +1000,7 @@ var preferUseStateLazyInitialization = createRule({
174
1000
  return {
175
1001
  CallExpression (node) {
176
1002
  if (!isReactHookCall(node)) return;
177
- if (!isUseStateCall(node, context, pragma) && !alias.some(F.flip(isReactHookCallWithNameLoose)(node))) return;
1003
+ if (!isUseStateCall(node, context, pragma) && !alias.some(flip(isReactHookCallWithNameLoose)(node))) return;
178
1004
  const [useStateInput] = node.arguments;
179
1005
  if (!useStateInput) return;
180
1006
  const nestedCallExpressions = getNestedCallExpressions(useStateInput);