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