@deslop/coding-standards 0.1.1077 → 0.1.1079
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/README.md +1 -1
- package/dist/{MutableRef-KfyWrSvW.mjs → MutableList-BCF17jPH.mjs} +536 -65
- package/dist/install.js +1611 -1752
- package/dist/oxlint.d.ts +12 -18
- package/dist/oxlint.js +631 -226
- package/package.json +1 -1
- package/skills/engineering/SKILL.md +36 -9
- package/skills/testing/SKILL.md +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
1
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Pipeable.js
|
|
2
2
|
/**
|
|
3
3
|
* The `Pipeable` module defines the shared interface and implementation helpers
|
|
4
4
|
* for values that support Effect-style method chaining with `.pipe(...)`.
|
|
@@ -104,7 +104,7 @@ const Class$1 = /*#__PURE__*/ function() {
|
|
|
104
104
|
return PipeableBase;
|
|
105
105
|
}();
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
107
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Function.js
|
|
108
108
|
/**
|
|
109
109
|
* Creates a function that can be called in data-first style or data-last
|
|
110
110
|
* (`pipe`-friendly) style.
|
|
@@ -399,7 +399,7 @@ function memoizeIdempotent(f) {
|
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
401
|
//#endregion
|
|
402
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
402
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/equal.js
|
|
403
403
|
/** @internal */
|
|
404
404
|
const getAllObjectKeys = (obj) => {
|
|
405
405
|
const keys = new Set(Reflect.ownKeys(obj));
|
|
@@ -420,7 +420,7 @@ const byReferenceInstances = /*#__PURE__*/ new WeakSet();
|
|
|
420
420
|
/** @internal */
|
|
421
421
|
const viewBytes = (view) => new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
422
422
|
//#endregion
|
|
423
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
423
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/hash.js
|
|
424
424
|
/**
|
|
425
425
|
* Back-edge count used to avoid caching entry-point-dependent hashes.
|
|
426
426
|
*
|
|
@@ -432,7 +432,7 @@ const addBackEdge = () => {
|
|
|
432
432
|
backEdges++;
|
|
433
433
|
};
|
|
434
434
|
//#endregion
|
|
435
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
435
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Predicate.js
|
|
436
436
|
/**
|
|
437
437
|
* Defines runtime checks for values.
|
|
438
438
|
*
|
|
@@ -1066,8 +1066,37 @@ function isError(input) {
|
|
|
1066
1066
|
function isIterable(input) {
|
|
1067
1067
|
return hasProperty(input, Symbol.iterator) || isString(input);
|
|
1068
1068
|
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Checks whether a value is a `RegExp`.
|
|
1071
|
+
*
|
|
1072
|
+
* **When to use**
|
|
1073
|
+
*
|
|
1074
|
+
* Use when you need a `Predicate` runtime guard for regular expressions.
|
|
1075
|
+
*
|
|
1076
|
+
* **Details**
|
|
1077
|
+
*
|
|
1078
|
+
* Uses `instanceof RegExp`.
|
|
1079
|
+
*
|
|
1080
|
+
* **Example** (Guarding RegExp values)
|
|
1081
|
+
*
|
|
1082
|
+
* ```ts import.meta.vitest
|
|
1083
|
+
* import { Predicate } from "effect"
|
|
1084
|
+
*
|
|
1085
|
+
* const data: unknown = /abc/
|
|
1086
|
+
*
|
|
1087
|
+
* Predicate.isRegExp(data) // => true
|
|
1088
|
+
* ```
|
|
1089
|
+
*
|
|
1090
|
+
* @see {@link isDate}
|
|
1091
|
+
* @stability stable
|
|
1092
|
+
* @category guards
|
|
1093
|
+
* @since 3.9.0
|
|
1094
|
+
*/
|
|
1095
|
+
function isRegExp(input) {
|
|
1096
|
+
return input instanceof RegExp;
|
|
1097
|
+
}
|
|
1069
1098
|
//#endregion
|
|
1070
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
1099
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Hash.js
|
|
1071
1100
|
/**
|
|
1072
1101
|
* Computes Effect hash values and defines the interface for objects that want
|
|
1073
1102
|
* to provide their own hash implementation. Hashes are small numeric
|
|
@@ -1463,7 +1492,7 @@ const randomHashCache = /*#__PURE__*/ new WeakMap();
|
|
|
1463
1492
|
const hashCache = /*#__PURE__*/ new WeakMap();
|
|
1464
1493
|
const visitedObjects = /*#__PURE__*/ new WeakSet();
|
|
1465
1494
|
//#endregion
|
|
1466
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
1495
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Equal.js
|
|
1467
1496
|
/**
|
|
1468
1497
|
* Defines the unique string identifier for the `Equal` interface.
|
|
1469
1498
|
*
|
|
@@ -1728,7 +1757,7 @@ const byReferenceUnsafe = (obj) => {
|
|
|
1728
1757
|
return obj;
|
|
1729
1758
|
};
|
|
1730
1759
|
//#endregion
|
|
1731
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
1760
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Redactable.js
|
|
1732
1761
|
/**
|
|
1733
1762
|
* Defines the symbol used to identify objects that implement the {@link Redactable}
|
|
1734
1763
|
* protocol.
|
|
@@ -1851,7 +1880,7 @@ const emptyContext = {
|
|
|
1851
1880
|
}
|
|
1852
1881
|
};
|
|
1853
1882
|
//#endregion
|
|
1854
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
1883
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Formatter.js
|
|
1855
1884
|
/**
|
|
1856
1885
|
* Formats JavaScript values into readable strings.
|
|
1857
1886
|
*
|
|
@@ -2127,7 +2156,7 @@ function isJsonPrimitiveWrapper(object) {
|
|
|
2127
2156
|
return false;
|
|
2128
2157
|
}
|
|
2129
2158
|
//#endregion
|
|
2130
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
2159
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Inspectable.js
|
|
2131
2160
|
/**
|
|
2132
2161
|
* Controls how values appear in logs and debugging output.
|
|
2133
2162
|
*
|
|
@@ -2281,7 +2310,7 @@ const BaseProto = {
|
|
|
2281
2310
|
}
|
|
2282
2311
|
};
|
|
2283
2312
|
//#endregion
|
|
2284
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
2313
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/stackTraceLimit.js
|
|
2285
2314
|
/**
|
|
2286
2315
|
* Check if `Error.stackTraceLimit` is writable.
|
|
2287
2316
|
* Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
|
|
@@ -2313,7 +2342,7 @@ const setStackTraceLimit = (value) => {
|
|
|
2313
2342
|
if (canWriteStackTraceLimit) Error.stackTraceLimit = value;
|
|
2314
2343
|
};
|
|
2315
2344
|
//#endregion
|
|
2316
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
2345
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Utils.js
|
|
2317
2346
|
/**
|
|
2318
2347
|
* Yields its wrapped value exactly once, then completes with the value sent
|
|
2319
2348
|
* back in.
|
|
@@ -2396,7 +2425,7 @@ const pickInternalCall = () => {
|
|
|
2396
2425
|
/** @internal */
|
|
2397
2426
|
const internalCall = /*#__PURE__*/ pickInternalCall();
|
|
2398
2427
|
//#endregion
|
|
2399
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
2428
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/record.js
|
|
2400
2429
|
/** @internal */
|
|
2401
2430
|
function assignProperty(self, key, value) {
|
|
2402
2431
|
if (key === "__proto__") Object.defineProperty(self, key, {
|
|
@@ -2412,7 +2441,7 @@ function assignProperties(self, source) {
|
|
|
2412
2441
|
for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProperty(self, key, source[key]);
|
|
2413
2442
|
}
|
|
2414
2443
|
//#endregion
|
|
2415
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
2444
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/core.js
|
|
2416
2445
|
/** @internal */
|
|
2417
2446
|
const EffectTypeId = `~effect/Effect`;
|
|
2418
2447
|
/** @internal */
|
|
@@ -2590,6 +2619,18 @@ const causeCombine = /*#__PURE__*/ dual(2, (self, that) => {
|
|
|
2590
2619
|
const newCause = new CauseImpl(dedupeReasons(self.reasons, that.reasons));
|
|
2591
2620
|
return equals(self, newCause) ? self : newCause;
|
|
2592
2621
|
});
|
|
2622
|
+
/**
|
|
2623
|
+
* Appends the interrupts from `interrupts` that `self` does not contain yet.
|
|
2624
|
+
* Unlike `causeCombine`, it never calls hash or equality methods, which can be
|
|
2625
|
+
* user-defined, random, or throwing.
|
|
2626
|
+
*
|
|
2627
|
+
* @internal
|
|
2628
|
+
*/
|
|
2629
|
+
const causeAddInterrupts = (self, interrupts) => {
|
|
2630
|
+
const reasons = self.reasons.slice();
|
|
2631
|
+
for (const reason of interrupts.reasons) if (isInterruptReason(reason) && !reasons.some((r) => isInterruptReason(r) && r.fiberId === reason.fiberId && r.annotations === reason.annotations)) reasons.push(reason);
|
|
2632
|
+
return reasons.length === self.reasons.length ? self : new CauseImpl(reasons);
|
|
2633
|
+
};
|
|
2593
2634
|
/** @internal */
|
|
2594
2635
|
const causeEmpty = /*#__PURE__*/ new CauseImpl([]);
|
|
2595
2636
|
/** @internal */
|
|
@@ -2719,7 +2760,7 @@ const exitFailCause = /*#__PURE__*/ makeExit({
|
|
|
2719
2760
|
cont = fiber.getCont(contE);
|
|
2720
2761
|
}
|
|
2721
2762
|
if (skippedHandler) cause = causeFromReasons(cause.reasons.filter((reason) => reason._tag !== "Fail"));
|
|
2722
|
-
cause =
|
|
2763
|
+
cause = causeAddInterrupts(cause, interruptedCause);
|
|
2723
2764
|
annotated = true;
|
|
2724
2765
|
}
|
|
2725
2766
|
return cont ? cont[contE](cause, fiber, annotated ? void 0 : this) : fiber.yieldWith(annotated ? exitFailCause(cause) : this);
|
|
@@ -2804,7 +2845,7 @@ const done = (value) => {
|
|
|
2804
2845
|
return exitFail(Done(value));
|
|
2805
2846
|
};
|
|
2806
2847
|
//#endregion
|
|
2807
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
2848
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Equivalence.js
|
|
2808
2849
|
/**
|
|
2809
2850
|
* Creates a custom equivalence relation with an optimized reference equality check.
|
|
2810
2851
|
*
|
|
@@ -2854,7 +2895,7 @@ const done = (value) => {
|
|
|
2854
2895
|
* @category constructors
|
|
2855
2896
|
* @since 2.0.0
|
|
2856
2897
|
*/
|
|
2857
|
-
const make$
|
|
2898
|
+
const make$3 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
2858
2899
|
const isStrictEquivalent = (x, y) => x === y;
|
|
2859
2900
|
/**
|
|
2860
2901
|
* Creates an equivalence relation that uses strict equality (`===`) to compare values.
|
|
@@ -2964,7 +3005,7 @@ const strictEqual = () => isStrictEquivalent;
|
|
|
2964
3005
|
* @since 4.0.0
|
|
2965
3006
|
*/
|
|
2966
3007
|
function Tuple(elements) {
|
|
2967
|
-
return make$
|
|
3008
|
+
return make$3((self, that) => {
|
|
2968
3009
|
if (self.length !== that.length) return false;
|
|
2969
3010
|
for (let i = 0; i < self.length; i++) if (!elements[i](self[i], that[i])) return false;
|
|
2970
3011
|
return true;
|
|
@@ -2974,14 +3015,14 @@ function Tuple(elements) {
|
|
|
2974
3015
|
* @since 4.0.0
|
|
2975
3016
|
*/
|
|
2976
3017
|
function Array_(item) {
|
|
2977
|
-
return make$
|
|
3018
|
+
return make$3((self, that) => {
|
|
2978
3019
|
if (self.length !== that.length) return false;
|
|
2979
3020
|
for (let i = 0; i < self.length; i++) if (!item(self[i], that[i])) return false;
|
|
2980
3021
|
return true;
|
|
2981
3022
|
});
|
|
2982
3023
|
}
|
|
2983
3024
|
//#endregion
|
|
2984
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
3025
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/option.js
|
|
2985
3026
|
/**
|
|
2986
3027
|
* @since 2.0.0
|
|
2987
3028
|
*/
|
|
@@ -3052,7 +3093,7 @@ SomeImpl.prototype = SomeProto;
|
|
|
3052
3093
|
/** @internal */
|
|
3053
3094
|
const some$2 = (value) => new SomeImpl(value);
|
|
3054
3095
|
//#endregion
|
|
3055
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
3096
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/result.js
|
|
3056
3097
|
const TypeId$1 = "~effect/Result";
|
|
3057
3098
|
const CommonProto = {
|
|
3058
3099
|
[TypeId$1]: {
|
|
@@ -3128,7 +3169,7 @@ const succeed$1 = (success) => new SuccessImpl(success);
|
|
|
3128
3169
|
/** @internal */
|
|
3129
3170
|
const fromOption$1 = /*#__PURE__*/ dual(2, (self, onNone) => isNone$1(self) ? fail$1(onNone()) : succeed$1(self.value));
|
|
3130
3171
|
//#endregion
|
|
3131
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
3172
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Order.js
|
|
3132
3173
|
/**
|
|
3133
3174
|
* Defines comparison functions for ordered values.
|
|
3134
3175
|
*
|
|
@@ -3178,7 +3219,7 @@ const fromOption$1 = /*#__PURE__*/ dual(2, (self, onNone) => isNone$1(self) ? fa
|
|
|
3178
3219
|
* @category constructors
|
|
3179
3220
|
* @since 2.0.0
|
|
3180
3221
|
*/
|
|
3181
|
-
function make$
|
|
3222
|
+
function make$2(compare) {
|
|
3182
3223
|
return (self, that) => self === that ? 0 : compare(self, that);
|
|
3183
3224
|
}
|
|
3184
3225
|
/**
|
|
@@ -3209,7 +3250,7 @@ function make$1(compare) {
|
|
|
3209
3250
|
* @category instances
|
|
3210
3251
|
* @since 4.0.0
|
|
3211
3252
|
*/
|
|
3212
|
-
const String$2 = /*#__PURE__*/ make$
|
|
3253
|
+
const String$2 = /*#__PURE__*/ make$2((self, that) => self < that ? -1 : 1);
|
|
3213
3254
|
/**
|
|
3214
3255
|
* Order instance for numbers that compares them numerically.
|
|
3215
3256
|
*
|
|
@@ -3242,7 +3283,7 @@ const String$2 = /*#__PURE__*/ make$1((self, that) => self < that ? -1 : 1);
|
|
|
3242
3283
|
* @category instances
|
|
3243
3284
|
* @since 4.0.0
|
|
3244
3285
|
*/
|
|
3245
|
-
const Number$1 = /*#__PURE__*/ make$
|
|
3286
|
+
const Number$1 = /*#__PURE__*/ make$2((self, that) => {
|
|
3246
3287
|
if (globalThis.Number.isNaN(self) && globalThis.Number.isNaN(that)) return 0;
|
|
3247
3288
|
if (globalThis.Number.isNaN(self)) return -1;
|
|
3248
3289
|
if (globalThis.Number.isNaN(that)) return 1;
|
|
@@ -3276,7 +3317,7 @@ const Number$1 = /*#__PURE__*/ make$1((self, that) => {
|
|
|
3276
3317
|
* @category instances
|
|
3277
3318
|
* @since 4.0.0
|
|
3278
3319
|
*/
|
|
3279
|
-
const BigInt = /*#__PURE__*/ make$
|
|
3320
|
+
const BigInt = /*#__PURE__*/ make$2((self, that) => self < that ? -1 : 1);
|
|
3280
3321
|
/**
|
|
3281
3322
|
* Transforms an `Order` on type `A` into an `Order` on type `B` by providing a function that
|
|
3282
3323
|
* maps values of type `B` to values of type `A`.
|
|
@@ -3310,7 +3351,7 @@ const BigInt = /*#__PURE__*/ make$1((self, that) => self < that ? -1 : 1);
|
|
|
3310
3351
|
* @category mapping
|
|
3311
3352
|
* @since 2.0.0
|
|
3312
3353
|
*/
|
|
3313
|
-
const mapInput = /*#__PURE__*/ dual(2, (self, f) => make$
|
|
3354
|
+
const mapInput = /*#__PURE__*/ dual(2, (self, f) => make$2((b1, b2) => self(f(b1), f(b2))));
|
|
3314
3355
|
/**
|
|
3315
3356
|
* Order instance for `Date` objects that compares them chronologically by their timestamp.
|
|
3316
3357
|
*
|
|
@@ -3469,7 +3510,7 @@ const isLessThanOrEqualTo = (O) => dual(2, (self, that) => O(self, that) !== 1);
|
|
|
3469
3510
|
*/
|
|
3470
3511
|
const isGreaterThanOrEqualTo = (O) => dual(2, (self, that) => O(self, that) !== -1);
|
|
3471
3512
|
//#endregion
|
|
3472
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
3513
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Option.js
|
|
3473
3514
|
/**
|
|
3474
3515
|
* Creates an `Option` representing the absence of a value.
|
|
3475
3516
|
*
|
|
@@ -4103,6 +4144,35 @@ const all = (input) => {
|
|
|
4103
4144
|
*/
|
|
4104
4145
|
const zipWith = /*#__PURE__*/ dual(3, (self, that, f) => map$3(product(self, that), ([a, b]) => f(a, b)));
|
|
4105
4146
|
/**
|
|
4147
|
+
* Converts an `Option` into an `Array`.
|
|
4148
|
+
*
|
|
4149
|
+
* **When to use**
|
|
4150
|
+
*
|
|
4151
|
+
* Use when you need to pass an `Option` to array-based APIs or spread optional
|
|
4152
|
+
* values into collections.
|
|
4153
|
+
*
|
|
4154
|
+
* **Details**
|
|
4155
|
+
*
|
|
4156
|
+
* - `Some` → single-element array `[value]`
|
|
4157
|
+
* - `None` → empty array `[]`
|
|
4158
|
+
*
|
|
4159
|
+
* **Example** (Converting to an array)
|
|
4160
|
+
*
|
|
4161
|
+
* ```ts import.meta.vitest
|
|
4162
|
+
* import { Option } from "effect"
|
|
4163
|
+
*
|
|
4164
|
+
* Option.toArray(Option.some(1)) // => [1]
|
|
4165
|
+
* Option.toArray(Option.none()) // => []
|
|
4166
|
+
* ```
|
|
4167
|
+
*
|
|
4168
|
+
* @see {@link fromIterable} for the inverse direction
|
|
4169
|
+
*
|
|
4170
|
+
* @stability stable
|
|
4171
|
+
* @category converting
|
|
4172
|
+
* @since 2.0.0
|
|
4173
|
+
*/
|
|
4174
|
+
const toArray$1 = (self) => isNone(self) ? [] : [self.value];
|
|
4175
|
+
/**
|
|
4106
4176
|
* Filters an `Option` using a predicate. Returns `None` if the predicate is
|
|
4107
4177
|
* not satisfied or the input is `None`.
|
|
4108
4178
|
*
|
|
@@ -4239,14 +4309,14 @@ const contains$1 = /*#__PURE__*/ containsWith$1(/*#__PURE__*/ asEquivalence());
|
|
|
4239
4309
|
*/
|
|
4240
4310
|
const exists = /*#__PURE__*/ dual(2, (self, refinement) => isNone(self) ? false : refinement(self.value));
|
|
4241
4311
|
//#endregion
|
|
4242
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
4312
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/array.js
|
|
4243
4313
|
/**
|
|
4244
4314
|
* @since 2.0.0
|
|
4245
4315
|
*/
|
|
4246
4316
|
/** @internal */
|
|
4247
4317
|
const isArrayNonEmpty$1 = (self) => self.length > 0;
|
|
4248
4318
|
//#endregion
|
|
4249
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
4319
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/count.js
|
|
4250
4320
|
/**
|
|
4251
4321
|
* Normalizes a collection count to a non-negative integer. `NaN` and
|
|
4252
4322
|
* non-positive values become `0`; positive infinity is preserved.
|
|
@@ -4255,7 +4325,7 @@ const isArrayNonEmpty$1 = (self) => self.length > 0;
|
|
|
4255
4325
|
*/
|
|
4256
4326
|
const normalize = (n) => n > 0 ? Math.floor(n) : 0;
|
|
4257
4327
|
//#endregion
|
|
4258
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
4328
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Result.js
|
|
4259
4329
|
/**
|
|
4260
4330
|
* Creates a `Result` holding a `Success` value.
|
|
4261
4331
|
*
|
|
@@ -4547,7 +4617,7 @@ const getOrThrow = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, onFailure) => {
|
|
|
4547
4617
|
*/
|
|
4548
4618
|
const flatMap$1 = /*#__PURE__*/ dual(2, (self, f) => isFailure(self) ? fail(self.failure) : f(self.success));
|
|
4549
4619
|
//#endregion
|
|
4550
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
4620
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Iterable.js
|
|
4551
4621
|
/**
|
|
4552
4622
|
* Returns the first element that satisfies the specified
|
|
4553
4623
|
* predicate, or `None` if no such element exists.
|
|
@@ -4601,7 +4671,7 @@ const findFirst$1 = /*#__PURE__*/ dual(2, (self, f) => {
|
|
|
4601
4671
|
return none();
|
|
4602
4672
|
});
|
|
4603
4673
|
//#endregion
|
|
4604
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
4674
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Record.js
|
|
4605
4675
|
/**
|
|
4606
4676
|
* Builds a record from an iterable of key-value pairs.
|
|
4607
4677
|
*
|
|
@@ -4768,8 +4838,63 @@ const keys = (self) => Object.keys(self);
|
|
|
4768
4838
|
* @since 2.0.0
|
|
4769
4839
|
*/
|
|
4770
4840
|
const values = (self) => collect(self, (_, a) => a);
|
|
4841
|
+
/**
|
|
4842
|
+
* Checks whether all the keys and values in one record are also found in another record.
|
|
4843
|
+
* Uses the provided equivalence function to compare values.
|
|
4844
|
+
*
|
|
4845
|
+
* **Example** (Checking subrecords with a custom equivalence)
|
|
4846
|
+
*
|
|
4847
|
+
* ```ts import.meta.vitest
|
|
4848
|
+
* import { Equivalence, Record } from "effect"
|
|
4849
|
+
*
|
|
4850
|
+
* const isSubrecord = Record.isSubrecordBy(
|
|
4851
|
+
* Equivalence.make<string>((self, that) => self.toLowerCase() === that.toLowerCase())
|
|
4852
|
+
* )
|
|
4853
|
+
*
|
|
4854
|
+
* const required: Record.ReadonlyRecord<string, string> = { role: "Admin" }
|
|
4855
|
+
* const available: Record.ReadonlyRecord<string, string> = {
|
|
4856
|
+
* role: "admin",
|
|
4857
|
+
* status: "active"
|
|
4858
|
+
* }
|
|
4859
|
+
*
|
|
4860
|
+
* isSubrecord(required, available) // => true
|
|
4861
|
+
* isSubrecord({ role: "Admin", status: "inactive" }, available) // => false
|
|
4862
|
+
* isSubrecord(required, { role: "editor", status: "active" }) // => false
|
|
4863
|
+
* ```
|
|
4864
|
+
*
|
|
4865
|
+
* @stability stable
|
|
4866
|
+
* @category predicates
|
|
4867
|
+
* @since 2.0.0
|
|
4868
|
+
*/
|
|
4869
|
+
const isSubrecordBy = (equivalence) => dual(2, (self, that) => {
|
|
4870
|
+
for (const key of keys(self)) if (!has(that, key) || !equivalence(self[key], that[key])) return false;
|
|
4871
|
+
return true;
|
|
4872
|
+
});
|
|
4873
|
+
/**
|
|
4874
|
+
* Create an `Equivalence` for records using the provided `Equivalence` for values.
|
|
4875
|
+
* Two records are considered equivalent if they have the same keys and their corresponding values are equivalent.
|
|
4876
|
+
*
|
|
4877
|
+
* **Example** (Comparing records with a value equivalence)
|
|
4878
|
+
*
|
|
4879
|
+
* ```ts import.meta.vitest
|
|
4880
|
+
* import { Equal, Record } from "effect"
|
|
4881
|
+
*
|
|
4882
|
+
* const recordEquivalence = Record.makeEquivalence(Equal.asEquivalence<number>())
|
|
4883
|
+
*
|
|
4884
|
+
* recordEquivalence({ a: 1, b: 2 }, { a: 1, b: 2 }) // => true
|
|
4885
|
+
* recordEquivalence({ a: 1, b: 2 }, { a: 1, b: 3 }) // => false
|
|
4886
|
+
* ```
|
|
4887
|
+
*
|
|
4888
|
+
* @stability stable
|
|
4889
|
+
* @category instances
|
|
4890
|
+
* @since 4.0.0
|
|
4891
|
+
*/
|
|
4892
|
+
const makeEquivalence$1 = (equivalence) => {
|
|
4893
|
+
const is = isSubrecordBy(equivalence);
|
|
4894
|
+
return (self, that) => is(self, that) && is(that, self);
|
|
4895
|
+
};
|
|
4771
4896
|
//#endregion
|
|
4772
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
4897
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Array.js
|
|
4773
4898
|
/**
|
|
4774
4899
|
* Works with JavaScript arrays, readonly arrays, and non-empty arrays.
|
|
4775
4900
|
*
|
|
@@ -4872,8 +4997,10 @@ const ensure = (self) => Array$1.isArray(self) ? self : [self];
|
|
|
4872
4997
|
*
|
|
4873
4998
|
* **Details**
|
|
4874
4999
|
*
|
|
4875
|
-
* `onNonEmpty` receives a `
|
|
4876
|
-
*
|
|
5000
|
+
* `onNonEmpty` receives a `NonEmptyArray` for mutable arrays and a
|
|
5001
|
+
* `NonEmptyReadonlyArray` otherwise. Data-last calls default to the readonly
|
|
5002
|
+
* callback, so the returned function still accepts `ReadonlyArray`. Supports
|
|
5003
|
+
* both data-first and data-last usage.
|
|
4877
5004
|
*
|
|
4878
5005
|
* **Example** (Branching on emptiness)
|
|
4879
5006
|
*
|
|
@@ -4898,6 +5025,41 @@ const ensure = (self) => Array$1.isArray(self) ? self : [self];
|
|
|
4898
5025
|
*/
|
|
4899
5026
|
const match$1 = /*#__PURE__*/ dual(2, (self, { onEmpty, onNonEmpty }) => isReadonlyArrayNonEmpty(self) ? onNonEmpty(self) : onEmpty());
|
|
4900
5027
|
/**
|
|
5028
|
+
* Pattern-matches on an array from the right, providing all elements except the
|
|
5029
|
+
* last and the last element separately.
|
|
5030
|
+
*
|
|
5031
|
+
* **When to use**
|
|
5032
|
+
*
|
|
5033
|
+
* Use when you need to branch on an array and handle the non-empty case as the
|
|
5034
|
+
* elements before the last plus the last element.
|
|
5035
|
+
*
|
|
5036
|
+
* **Details**
|
|
5037
|
+
*
|
|
5038
|
+
* `onNonEmpty` receives `(init, last)` where `init` is everything but the last element.
|
|
5039
|
+
*
|
|
5040
|
+
* **Example** (Destructuring init and last)
|
|
5041
|
+
*
|
|
5042
|
+
* ```ts import.meta.vitest
|
|
5043
|
+
* import { Array } from "effect"
|
|
5044
|
+
*
|
|
5045
|
+
* const matchRight = Array.matchRight({
|
|
5046
|
+
* onEmpty: () => "empty",
|
|
5047
|
+
* onNonEmpty: (init, last) => `init: ${init.length}, last: ${last}`
|
|
5048
|
+
* })
|
|
5049
|
+
*
|
|
5050
|
+
* matchRight([]) // => "empty"
|
|
5051
|
+
* matchRight([1, 2, 3]) // => "init: 2, last: 3"
|
|
5052
|
+
* ```
|
|
5053
|
+
*
|
|
5054
|
+
* @see {@link match} — receives the full non-empty array
|
|
5055
|
+
* @see {@link matchLeft} — destructures into head + tail
|
|
5056
|
+
*
|
|
5057
|
+
* @stability stable
|
|
5058
|
+
* @category pattern matching
|
|
5059
|
+
* @since 2.0.0
|
|
5060
|
+
*/
|
|
5061
|
+
const matchRight = /*#__PURE__*/ dual(2, (self, { onEmpty, onNonEmpty }) => isReadonlyArrayNonEmpty(self) ? onNonEmpty(initNonEmpty(self), lastNonEmpty(self)) : onEmpty());
|
|
5062
|
+
/**
|
|
4901
5063
|
* Adds a single element to the front of an iterable, returning a `NonEmptyArray`.
|
|
4902
5064
|
*
|
|
4903
5065
|
* **When to use**
|
|
@@ -4944,7 +5106,7 @@ const prepend = /*#__PURE__*/ dual(2, (self, head) => [head, ...self]);
|
|
|
4944
5106
|
* @category combining
|
|
4945
5107
|
* @since 2.0.0
|
|
4946
5108
|
*/
|
|
4947
|
-
const append = /*#__PURE__*/ dual(2, (self, last) => [...self, last]);
|
|
5109
|
+
const append$1 = /*#__PURE__*/ dual(2, (self, last) => [...self, last]);
|
|
4948
5110
|
/**
|
|
4949
5111
|
* Concatenates two iterables into a single array.
|
|
4950
5112
|
*
|
|
@@ -5189,68 +5351,61 @@ const last = (self) => isReadonlyArrayNonEmpty(self) ? some$1(lastNonEmpty(self)
|
|
|
5189
5351
|
* @since 2.0.0
|
|
5190
5352
|
*/
|
|
5191
5353
|
const lastNonEmpty = (self) => self[self.length - 1];
|
|
5192
|
-
const clampCount = (n, length) => Math.min(normalize(n), length);
|
|
5193
5354
|
/**
|
|
5194
|
-
*
|
|
5355
|
+
* Returns all elements except the last of a `NonEmptyReadonlyArray`.
|
|
5195
5356
|
*
|
|
5196
5357
|
* **When to use**
|
|
5197
5358
|
*
|
|
5198
|
-
* Use to
|
|
5199
|
-
*
|
|
5200
|
-
* **Details**
|
|
5359
|
+
* Use to get all elements before the last when the array is known to be non-empty.
|
|
5201
5360
|
*
|
|
5202
|
-
*
|
|
5203
|
-
* Returns an empty array when `n <= 0`.
|
|
5204
|
-
*
|
|
5205
|
-
* **Example** (Taking from the start)
|
|
5361
|
+
* **Example** (Getting init of a non-empty array)
|
|
5206
5362
|
*
|
|
5207
5363
|
* ```ts import.meta.vitest
|
|
5208
5364
|
* import { Array } from "effect"
|
|
5209
5365
|
*
|
|
5210
|
-
* Array.
|
|
5366
|
+
* Array.initNonEmpty([1, 2, 3, 4]) // => [1, 2, 3]
|
|
5211
5367
|
* ```
|
|
5212
5368
|
*
|
|
5213
|
-
* @see {@link
|
|
5214
|
-
* @see {@link
|
|
5215
|
-
* @see {@link drop} for removing elements from the start
|
|
5369
|
+
* @see {@link init} — safe version for possibly-empty arrays
|
|
5370
|
+
* @see {@link tailNonEmpty} — all elements except the first
|
|
5216
5371
|
*
|
|
5217
5372
|
* @stability stable
|
|
5218
5373
|
* @category getters
|
|
5219
5374
|
* @since 2.0.0
|
|
5220
5375
|
*/
|
|
5221
|
-
const
|
|
5222
|
-
|
|
5223
|
-
return input.slice(0, clampCount(n, input.length));
|
|
5224
|
-
});
|
|
5376
|
+
const initNonEmpty = (self) => self.slice(0, -1);
|
|
5377
|
+
const clampCount = (n, length) => Math.min(normalize(n), length);
|
|
5225
5378
|
/**
|
|
5226
|
-
*
|
|
5379
|
+
* Keeps the first `n` elements, creating a new array.
|
|
5227
5380
|
*
|
|
5228
5381
|
* **When to use**
|
|
5229
5382
|
*
|
|
5230
|
-
* Use to
|
|
5383
|
+
* Use to keep up to the first `n` elements from an iterable as a new array.
|
|
5231
5384
|
*
|
|
5232
5385
|
* **Details**
|
|
5233
5386
|
*
|
|
5234
5387
|
* `n` is rounded down and clamped to `[0, length]`. `NaN` is treated as `0`.
|
|
5388
|
+
* Returns an empty array when `n <= 0`.
|
|
5235
5389
|
*
|
|
5236
|
-
* **Example** (
|
|
5390
|
+
* **Example** (Taking from the start)
|
|
5237
5391
|
*
|
|
5238
5392
|
* ```ts import.meta.vitest
|
|
5239
5393
|
* import { Array } from "effect"
|
|
5240
5394
|
*
|
|
5241
|
-
* Array.
|
|
5395
|
+
* Array.take([1, 2, 3, 4, 5], 3) // => [1, 2, 3]
|
|
5242
5396
|
* ```
|
|
5243
5397
|
*
|
|
5244
|
-
* @see {@link
|
|
5245
|
-
* @see {@link
|
|
5398
|
+
* @see {@link takeRight} for keeping elements from the end
|
|
5399
|
+
* @see {@link takeWhile} for keeping an initial prefix while a predicate holds
|
|
5400
|
+
* @see {@link drop} for removing elements from the start
|
|
5246
5401
|
*
|
|
5247
5402
|
* @stability stable
|
|
5248
5403
|
* @category getters
|
|
5249
5404
|
* @since 2.0.0
|
|
5250
5405
|
*/
|
|
5251
|
-
const
|
|
5406
|
+
const take$1 = /*#__PURE__*/ dual(2, (self, n) => {
|
|
5252
5407
|
const input = fromIterable(self);
|
|
5253
|
-
return input.slice(0,
|
|
5408
|
+
return input.slice(0, clampCount(n, input.length));
|
|
5254
5409
|
});
|
|
5255
5410
|
/**
|
|
5256
5411
|
* Returns the index of the first element matching the predicate, wrapped in an
|
|
@@ -5799,6 +5954,38 @@ const makeEquivalence = Array_;
|
|
|
5799
5954
|
*/
|
|
5800
5955
|
const forEach = /*#__PURE__*/ dual(2, (self, f) => fromIterable(self).forEach((a, i) => f(a, i)));
|
|
5801
5956
|
/**
|
|
5957
|
+
* Removes duplicates using a custom equivalence, preserving the order of the
|
|
5958
|
+
* first occurrence.
|
|
5959
|
+
*
|
|
5960
|
+
* **When to use**
|
|
5961
|
+
*
|
|
5962
|
+
* Use to remove all duplicate elements with a custom equivalence when default
|
|
5963
|
+
* equality is not appropriate.
|
|
5964
|
+
*
|
|
5965
|
+
* **Example** (Deduplicating with custom equality)
|
|
5966
|
+
*
|
|
5967
|
+
* ```ts import.meta.vitest
|
|
5968
|
+
* import { Array } from "effect"
|
|
5969
|
+
*
|
|
5970
|
+
* Array.dedupeWith([1, 2, 2, 3, 3, 3], (a, b) => a === b) // => [1, 2, 3]
|
|
5971
|
+
* ```
|
|
5972
|
+
*
|
|
5973
|
+
* @see {@link dedupe} — uses default equality
|
|
5974
|
+
* @see {@link dedupeAdjacentWith} — only dedupes consecutive elements
|
|
5975
|
+
*
|
|
5976
|
+
* @stability stable
|
|
5977
|
+
* @category deduplication
|
|
5978
|
+
* @since 2.0.0
|
|
5979
|
+
*/
|
|
5980
|
+
const dedupeWith = /*#__PURE__*/ dual(2, (self, isEquivalent) => {
|
|
5981
|
+
const out = [];
|
|
5982
|
+
next: for (const r of fromIterable(self)) {
|
|
5983
|
+
for (let i = 0; i < out.length; i++) if (isEquivalent(r, out[i])) continue next;
|
|
5984
|
+
out.push(r);
|
|
5985
|
+
}
|
|
5986
|
+
return out;
|
|
5987
|
+
});
|
|
5988
|
+
/**
|
|
5802
5989
|
* Removes duplicates using `Equal.equivalence()`, preserving the order of the
|
|
5803
5990
|
* first occurrence.
|
|
5804
5991
|
*
|
|
@@ -6156,8 +6343,25 @@ const startsWith = (searchString, position) => (self) => self.startsWith(searchS
|
|
|
6156
6343
|
* @since 2.0.0
|
|
6157
6344
|
*/
|
|
6158
6345
|
const match = (regExp) => (self) => fromNullOr(self.match(regExp));
|
|
6346
|
+
/**
|
|
6347
|
+
* Replaces all occurrences of a substring or pattern in a string.
|
|
6348
|
+
*
|
|
6349
|
+
* **Example** (Replacing all matches)
|
|
6350
|
+
*
|
|
6351
|
+
* ```ts import.meta.vitest
|
|
6352
|
+
* import { pipe, String } from "effect"
|
|
6353
|
+
*
|
|
6354
|
+
* pipe("ababb", String.replaceAll("b", "c")) // => "acacc"
|
|
6355
|
+
* pipe("ababb", String.replaceAll(/ba/g, "cc")) // => "accbb"
|
|
6356
|
+
* ```
|
|
6357
|
+
*
|
|
6358
|
+
* @stability stable
|
|
6359
|
+
* @category transforming
|
|
6360
|
+
* @since 2.0.0
|
|
6361
|
+
*/
|
|
6362
|
+
const replaceAll = (searchValue, replaceValue) => (self) => self.replaceAll(searchValue, replaceValue);
|
|
6159
6363
|
//#endregion
|
|
6160
|
-
//#region ../../node_modules/.pnpm/effect@4.0.
|
|
6364
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/MutableRef.js
|
|
6161
6365
|
const TypeId = "~effect/MutableRef";
|
|
6162
6366
|
const MutableRefProto = {
|
|
6163
6367
|
[TypeId]: TypeId,
|
|
@@ -6202,7 +6406,7 @@ const MutableRefProto = {
|
|
|
6202
6406
|
* @category constructors
|
|
6203
6407
|
* @since 2.0.0
|
|
6204
6408
|
*/
|
|
6205
|
-
const make = (value) => {
|
|
6409
|
+
const make$1 = (value) => {
|
|
6206
6410
|
const ref = Object.create(MutableRefProto);
|
|
6207
6411
|
ref.current = value;
|
|
6208
6412
|
return ref;
|
|
@@ -6358,4 +6562,271 @@ const set = /*#__PURE__*/ dual(2, (self, value) => {
|
|
|
6358
6562
|
*/
|
|
6359
6563
|
const update = /*#__PURE__*/ dual(2, (self, f) => set(self, f(get(self))));
|
|
6360
6564
|
//#endregion
|
|
6361
|
-
|
|
6565
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/MutableList.js
|
|
6566
|
+
/**
|
|
6567
|
+
* Defines the unique symbol used to represent an empty result when taking elements from a MutableList.
|
|
6568
|
+
* This symbol is returned by `take` when the list is empty, allowing for safe type checking.
|
|
6569
|
+
*
|
|
6570
|
+
* **When to use**
|
|
6571
|
+
*
|
|
6572
|
+
* Use to detect that `take` returned no element before handling the result as a
|
|
6573
|
+
* list item.
|
|
6574
|
+
*
|
|
6575
|
+
* **Example** (Checking for empty results)
|
|
6576
|
+
*
|
|
6577
|
+
* ```ts import.meta.vitest
|
|
6578
|
+
* import { MutableList } from "effect"
|
|
6579
|
+
*
|
|
6580
|
+
* const list = MutableList.make<string>()
|
|
6581
|
+
*
|
|
6582
|
+
* MutableList.take(list) === MutableList.Empty // => true
|
|
6583
|
+
* ```
|
|
6584
|
+
*
|
|
6585
|
+
* @stability stable
|
|
6586
|
+
* @category symbols
|
|
6587
|
+
* @since 4.0.0
|
|
6588
|
+
*/
|
|
6589
|
+
const Empty = /*#__PURE__*/ Symbol.for("effect/MutableList/Empty");
|
|
6590
|
+
/**
|
|
6591
|
+
* Creates an empty MutableList.
|
|
6592
|
+
*
|
|
6593
|
+
* **Example** (Creating an empty mutable list)
|
|
6594
|
+
*
|
|
6595
|
+
* ```ts import.meta.vitest
|
|
6596
|
+
* import { MutableList } from "effect"
|
|
6597
|
+
*
|
|
6598
|
+
* const list = MutableList.make<string>()
|
|
6599
|
+
*
|
|
6600
|
+
* list.length // => 0
|
|
6601
|
+
* MutableList.append(list, "first")
|
|
6602
|
+
* MutableList.take(list) // => "first"
|
|
6603
|
+
* list.length // => 0
|
|
6604
|
+
* ```
|
|
6605
|
+
*
|
|
6606
|
+
* @stability stable
|
|
6607
|
+
* @category constructors
|
|
6608
|
+
* @since 2.0.0
|
|
6609
|
+
*/
|
|
6610
|
+
const make = () => ({
|
|
6611
|
+
head: void 0,
|
|
6612
|
+
tail: void 0,
|
|
6613
|
+
length: 0
|
|
6614
|
+
});
|
|
6615
|
+
const compactHead = (self) => {
|
|
6616
|
+
const head = self.head;
|
|
6617
|
+
if (head.offset >= 1024 && head === self.tail && head.mutable && (head.array.length - head.offset) * 8 <= head.offset) self.head = self.tail = {
|
|
6618
|
+
array: head.array.slice(head.offset),
|
|
6619
|
+
mutable: true,
|
|
6620
|
+
offset: 0,
|
|
6621
|
+
next: void 0
|
|
6622
|
+
};
|
|
6623
|
+
};
|
|
6624
|
+
const emptyBucket = () => ({
|
|
6625
|
+
array: [],
|
|
6626
|
+
mutable: true,
|
|
6627
|
+
offset: 0,
|
|
6628
|
+
next: void 0
|
|
6629
|
+
});
|
|
6630
|
+
/**
|
|
6631
|
+
* Appends an element to the end of the MutableList.
|
|
6632
|
+
* This operation is optimized for high-frequency usage.
|
|
6633
|
+
*
|
|
6634
|
+
* **Example** (Appending elements)
|
|
6635
|
+
*
|
|
6636
|
+
* ```ts import.meta.vitest
|
|
6637
|
+
* import { MutableList } from "effect"
|
|
6638
|
+
*
|
|
6639
|
+
* const list = MutableList.make<number>()
|
|
6640
|
+
* MutableList.append(list, 1)
|
|
6641
|
+
* MutableList.append(list, 2)
|
|
6642
|
+
* MutableList.append(list, 3)
|
|
6643
|
+
*
|
|
6644
|
+
* MutableList.toArray(list) // => [1, 2, 3]
|
|
6645
|
+
* list.length // => 3
|
|
6646
|
+
* ```
|
|
6647
|
+
*
|
|
6648
|
+
* @stability stable
|
|
6649
|
+
* @category mutations
|
|
6650
|
+
* @since 2.0.0
|
|
6651
|
+
*/
|
|
6652
|
+
const append = (self, message) => {
|
|
6653
|
+
if (!self.tail) self.head = self.tail = emptyBucket();
|
|
6654
|
+
else if (!self.tail.mutable) {
|
|
6655
|
+
self.tail.next = emptyBucket();
|
|
6656
|
+
self.tail = self.tail.next;
|
|
6657
|
+
}
|
|
6658
|
+
self.tail.array.push(message);
|
|
6659
|
+
self.length++;
|
|
6660
|
+
};
|
|
6661
|
+
/**
|
|
6662
|
+
* Removes all elements from the MutableList, resetting it to an empty state.
|
|
6663
|
+
* This operation is highly optimized and releases all internal memory.
|
|
6664
|
+
*
|
|
6665
|
+
* **Example** (Clearing a mutable list)
|
|
6666
|
+
*
|
|
6667
|
+
* ```ts import.meta.vitest
|
|
6668
|
+
* import { MutableList } from "effect"
|
|
6669
|
+
*
|
|
6670
|
+
* const list = MutableList.make<number>()
|
|
6671
|
+
* MutableList.appendAll(list, [1, 2, 3, 4, 5])
|
|
6672
|
+
*
|
|
6673
|
+
* MutableList.clear(list)
|
|
6674
|
+
*
|
|
6675
|
+
* MutableList.toArray(list) // => []
|
|
6676
|
+
* list.length // => 0
|
|
6677
|
+
* MutableList.take(list) === MutableList.Empty // => true
|
|
6678
|
+
* ```
|
|
6679
|
+
*
|
|
6680
|
+
* @stability stable
|
|
6681
|
+
* @category mutations
|
|
6682
|
+
* @since 4.0.0
|
|
6683
|
+
*/
|
|
6684
|
+
const clear = (self) => {
|
|
6685
|
+
self.head = self.tail = void 0;
|
|
6686
|
+
self.length = 0;
|
|
6687
|
+
};
|
|
6688
|
+
/**
|
|
6689
|
+
* Takes up to N elements from the beginning of the MutableList and returns them as an array.
|
|
6690
|
+
* The taken elements are removed from the list. This operation is optimized for performance
|
|
6691
|
+
* and includes zero-copy optimizations when possible.
|
|
6692
|
+
*
|
|
6693
|
+
* **Details**
|
|
6694
|
+
*
|
|
6695
|
+
* Finite fractional values of `n` are rounded down. `NaN` and non-positive
|
|
6696
|
+
* values leave the list unchanged and return an empty array.
|
|
6697
|
+
*
|
|
6698
|
+
* **Example** (Taking batches)
|
|
6699
|
+
*
|
|
6700
|
+
* ```ts import.meta.vitest
|
|
6701
|
+
* import { MutableList } from "effect"
|
|
6702
|
+
*
|
|
6703
|
+
* const list = MutableList.make<number>()
|
|
6704
|
+
* MutableList.appendAll(list, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
|
6705
|
+
*
|
|
6706
|
+
* MutableList.takeN(list, 3) // => [1, 2, 3]
|
|
6707
|
+
* MutableList.toArray(list) // => [4, 5, 6, 7, 8, 9, 10]
|
|
6708
|
+
* list.length // => 7
|
|
6709
|
+
* ```
|
|
6710
|
+
*
|
|
6711
|
+
* @stability stable
|
|
6712
|
+
* @category mutations
|
|
6713
|
+
* @since 4.0.0
|
|
6714
|
+
*/
|
|
6715
|
+
const takeN = (self, n) => {
|
|
6716
|
+
n = normalize(n);
|
|
6717
|
+
if (n <= 0 || !self.head) return [];
|
|
6718
|
+
n = Math.min(n, self.length);
|
|
6719
|
+
if (n === self.length && self.head?.offset === 0 && !self.head.next) {
|
|
6720
|
+
const array = self.head.array;
|
|
6721
|
+
clear(self);
|
|
6722
|
+
return array;
|
|
6723
|
+
}
|
|
6724
|
+
const array = new Array(n);
|
|
6725
|
+
let index = 0;
|
|
6726
|
+
let chunk = self.head;
|
|
6727
|
+
while (chunk) {
|
|
6728
|
+
while (chunk.offset < chunk.array.length) {
|
|
6729
|
+
array[index++] = chunk.array[chunk.offset];
|
|
6730
|
+
if (chunk.mutable) chunk.array[chunk.offset] = void 0;
|
|
6731
|
+
chunk.offset++;
|
|
6732
|
+
if (index === n) {
|
|
6733
|
+
self.head = chunk.offset === chunk.array.length && chunk.next ? chunk.next : chunk;
|
|
6734
|
+
self.length -= n;
|
|
6735
|
+
if (self.length === 0) clear(self);
|
|
6736
|
+
else compactHead(self);
|
|
6737
|
+
return array;
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
chunk = chunk.next;
|
|
6741
|
+
}
|
|
6742
|
+
clear(self);
|
|
6743
|
+
return array;
|
|
6744
|
+
};
|
|
6745
|
+
/**
|
|
6746
|
+
* Takes a single element from the beginning of the MutableList.
|
|
6747
|
+
* Returns the element if available, or the Empty symbol if the list is empty.
|
|
6748
|
+
* The taken element is removed from the list.
|
|
6749
|
+
*
|
|
6750
|
+
* **Example** (Taking one element)
|
|
6751
|
+
*
|
|
6752
|
+
* ```ts import.meta.vitest
|
|
6753
|
+
* import { MutableList } from "effect"
|
|
6754
|
+
*
|
|
6755
|
+
* const list = MutableList.make<string>()
|
|
6756
|
+
* MutableList.appendAll(list, ["first", "second", "third"])
|
|
6757
|
+
*
|
|
6758
|
+
* MutableList.take(list) // => "first"
|
|
6759
|
+
* MutableList.toArray(list) // => ["second", "third"]
|
|
6760
|
+
* list.length // => 2
|
|
6761
|
+
* ```
|
|
6762
|
+
*
|
|
6763
|
+
* @stability stable
|
|
6764
|
+
* @category mutations
|
|
6765
|
+
* @since 4.0.0
|
|
6766
|
+
*/
|
|
6767
|
+
const take = (self) => {
|
|
6768
|
+
if (!self.head) return Empty;
|
|
6769
|
+
const message = self.head.array[self.head.offset];
|
|
6770
|
+
if (self.head.mutable) self.head.array[self.head.offset] = void 0;
|
|
6771
|
+
self.head.offset++;
|
|
6772
|
+
self.length--;
|
|
6773
|
+
if (self.head.offset === self.head.array.length) {
|
|
6774
|
+
if (self.head.next) self.head = self.head.next;
|
|
6775
|
+
else clear(self);
|
|
6776
|
+
} else compactHead(self);
|
|
6777
|
+
return message;
|
|
6778
|
+
};
|
|
6779
|
+
/**
|
|
6780
|
+
* Copies up to `n` elements from the beginning of the `MutableList` into a new
|
|
6781
|
+
* array without modifying the list.
|
|
6782
|
+
*
|
|
6783
|
+
* **When to use**
|
|
6784
|
+
*
|
|
6785
|
+
* Use when you need to inspect or snapshot a bounded prefix of the list without
|
|
6786
|
+
* consuming it.
|
|
6787
|
+
*
|
|
6788
|
+
* **Details**
|
|
6789
|
+
*
|
|
6790
|
+
* Finite fractional values of `n` are rounded down. `NaN` and non-positive
|
|
6791
|
+
* values return an empty array.
|
|
6792
|
+
*
|
|
6793
|
+
* @see {@link takeN} for removing up to `n` values and returning them as an array
|
|
6794
|
+
*
|
|
6795
|
+
* @stability stable
|
|
6796
|
+
* @category converting
|
|
6797
|
+
* @since 4.0.0
|
|
6798
|
+
*/
|
|
6799
|
+
const toArrayN = (self, n) => {
|
|
6800
|
+
n = normalize(n);
|
|
6801
|
+
if (n <= 0) return [];
|
|
6802
|
+
const length = Math.min(n, self.length);
|
|
6803
|
+
const out = new Array(length);
|
|
6804
|
+
let index = 0;
|
|
6805
|
+
let bucket = self.head;
|
|
6806
|
+
while (bucket) {
|
|
6807
|
+
for (let i = bucket.offset; i < bucket.array.length; i++) {
|
|
6808
|
+
out[index++] = bucket.array[i];
|
|
6809
|
+
if (index === length) return out;
|
|
6810
|
+
}
|
|
6811
|
+
bucket = bucket.next;
|
|
6812
|
+
}
|
|
6813
|
+
return out;
|
|
6814
|
+
};
|
|
6815
|
+
/**
|
|
6816
|
+
* Copies all current elements of the `MutableList` into a new array without
|
|
6817
|
+
* modifying the list.
|
|
6818
|
+
*
|
|
6819
|
+
* **When to use**
|
|
6820
|
+
*
|
|
6821
|
+
* Use when you need a snapshot of all current elements while keeping the list
|
|
6822
|
+
* unchanged.
|
|
6823
|
+
*
|
|
6824
|
+
* @see {@link takeAll} for converting all elements to an array and clearing the list
|
|
6825
|
+
*
|
|
6826
|
+
* @stability stable
|
|
6827
|
+
* @category converting
|
|
6828
|
+
* @since 4.0.0
|
|
6829
|
+
*/
|
|
6830
|
+
const toArray = (self) => toArrayN(self, self.length);
|
|
6831
|
+
//#endregion
|
|
6832
|
+
export { prepend as $, redact as $n, strictEqual as $t, filter as A, isCause as An, isString as Ar, getOrUndefined as At, getSomes as B, assignProperty as Bn, identity as Br, zipWith as Bt, contains as C, contE as Cn, isNullish as Cr, filter$1 as Ct, empty as D, exitFail as Dn, isPropertyKey as Dr, fromNullishOr as Dt, dedupeWith as E, exitDie as En, isObjectKeyword as Er, flatten$1 as Et, flatMap as F, isFailReason as Fn, constTrue as Fr, match$3 as Ft, isReadonlyArrayNonEmpty as G, NodeInspectSymbol as Gn, Prototype as Gr, isGreaterThan as Gt, isArrayEmpty as H, getStackTraceLimit as Hn, memoizeIdempotent as Hr, Date$1 as Ht, flatten as I, isInterruptReason as In, constUndefined as Ir, none as It, makeEquivalence as J, formatDate as Jn, isLessThanOrEqualTo as Jt, join as K, toStringUnknown as Kn, pipeArguments as Kr, isGreaterThanOrEqualTo as Kt, forEach as L, makePrimitive as Ln, constVoid as Lr, orElse as Lt, findFirst as M, isDone as Mn, isUndefined as Mr, isSome as Mt, findFirstIndex as N, isEffect as Nn, isUnknown as Nr, liftThrowable as Nt, ensure as O, exitFailCause as On, isReadonlyObject as Or, fromUndefinedOr as Ot, findLast as P, isExit as Pn, constFalse as Pr, map$3 as Pt, of as Q, currentFiberTypeId as Qn, make$3 as Qt, fromIterable as R, makePrimitiveProto as Rn, constant as Rr, some$1 as Rt, appendAll as S, contAll as Sn, isNotUndefined as Sr, exists as St, dedupe as T, evaluate as Tn, isObject as Tr, flatMap$2 as Tt, isArrayNonEmpty as U, setStackTraceLimit as Un, pipe as Ur, Number$1 as Ut, head as V, internalCall as Vn, memoize as Vr, BigInt as Vt, isCanonicalArrayIndex as W, BaseProto as Wn, Class$1 as Wr, String$2 as Wt, match$1 as X, formatPath as Xn, mapInput as Xt, map as Y, formatJson as Yn, make$2 as Yt, matchRight as Z, formatPropertyKey as Zn, Tuple as Zt, trimEnd as _, causeEmpty as _n, isError as _r, match$2 as _t, takeN as a, Fail as an, array as ar, get$2 as at, taggedEnum as b, constEmptyAnnotations as bn, isNotNull as br, all as bt, make$1 as c, ReasonBase as cn, number as cr, remove as ct, includes as d, Yield as dn, structure as dr, flatMap$1 as dt, CauseImpl as en, symbolRedactable as er, reduce as et, match as f, args as fn, structureKeys as fr, fromOption as ft, trim as g, causeDie as gn, isBoolean as gr, map$2 as gt, startsWith as h, causeCombine as hn, isBigInt as hr, isSuccess as ht, take as i, ExitTypeId as in, symbol as ir, fromEntries as it, filterMap as j, isDieReason as jn, isTagged as jr, isNone as jt, every as k, exitSucceed as kn, isRegExp as kr, getOrElse as kt, update as l, StackTraceKey as ln, optimize as lr, values as lt, split as m, causeAnnotate as mn, hasProperty as mr, isFailure as mt, clear as n, Done as nn, byReferenceUnsafe as nr, sort as nt, toArray as o, InterruptorStackTrace as on, combine as or, makeEquivalence$1 as ot, replaceAll as p, causeAddInterrupts as pn, symbol$1 as pr, getOrThrow as pt, last as q, format as qn, isLessThan as qt, make as r, Error$2 as rn, equals as rr, take$1 as rt, get as s, PipeInspectableProto as sn, hash as sr, map$1 as st, append as t, Die as tn, asEquivalence as tr, some as tt, Order as u, TaggedError$1 as un, string as ur, fail as ut, Error$1 as v, causeFail as vn, isFunction as vr, succeed as vt, containsWith as w, done as wn, isNumber as wr, firstSomeOf as wt, append$1 as x, contA as xn, isNotNullish as xr, contains$1 as xt, TaggedError as y, causeFromReasons as yn, isIterable as yr, normalize as yt, get$1 as z, withFiber as zn, dual as zr, toArray$1 as zt };
|