massaman 0.3.0 → 0.5.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/README.md +4 -4
- package/dist/array/index.d.mts +2 -2
- package/dist/array/index.mjs +2 -2
- package/dist/{array-C8MqjyiP.mjs → array-glQHknc3.mjs} +3 -3
- package/dist/{array-C8MqjyiP.mjs.map → array-glQHknc3.mjs.map} +1 -1
- package/dist/bigint/index.d.mts +2 -0
- package/dist/bigint/index.mjs +2 -0
- package/dist/control/index.d.mts +3 -3
- package/dist/control/index.mjs +1 -1
- package/dist/{control-Dg2fwHB7.mjs → control-DCdm8IH6.mjs} +1 -1
- package/dist/{control-Dg2fwHB7.mjs.map → control-DCdm8IH6.mjs.map} +1 -1
- package/dist/conversion/index.d.mts +1 -1
- package/dist/conversion/index.mjs +1 -1
- package/dist/{conversion-ByBXBR5i.mjs → conversion-BB912-15.mjs} +1 -1
- package/dist/{conversion-ByBXBR5i.mjs.map → conversion-BB912-15.mjs.map} +1 -1
- package/dist/fp/index.d.mts +2 -0
- package/dist/fp/index.mjs +2 -0
- package/dist/function/index.d.mts +2 -2
- package/dist/function/index.mjs +1 -1
- package/dist/{function-2-6QB4m7.mjs → function-Brosl7-Y.mjs} +1 -1
- package/dist/{function-2-6QB4m7.mjs.map → function-Brosl7-Y.mjs.map} +1 -1
- package/dist/{index-mfIoxwxy.d.mts → index-BPYJOreI.d.mts} +3 -4
- package/dist/index-BPYJOreI.d.mts.map +1 -0
- package/dist/{index-BjmDP8W9.d.mts → index-C7dxY5U-.d.mts} +1 -1
- package/dist/index-C7dxY5U-.d.mts.map +1 -0
- package/dist/{index-Bp3ol0vr.d.mts → index-D5q3I26j.d.mts} +2 -3
- package/dist/index-D5q3I26j.d.mts.map +1 -0
- package/dist/{index-g2aw5tc_.d.mts → index-D7DGVrkN.d.mts} +3 -4
- package/dist/index-D7DGVrkN.d.mts.map +1 -0
- package/dist/index-DTrYN2UY.d.mts +20 -0
- package/dist/index-DTrYN2UY.d.mts.map +1 -0
- package/dist/index-DcVpX2Bb.d.mts +43 -0
- package/dist/index-DcVpX2Bb.d.mts.map +1 -0
- package/dist/{index-D5l6I7QH.d.mts → index-DlZyDxI_.d.mts} +1 -2
- package/dist/index-DlZyDxI_.d.mts.map +1 -0
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +11 -11
- package/dist/match/index.d.mts +2 -2
- package/dist/match/index.mjs +1 -1
- package/dist/match-fBetfaIa.mjs +49 -0
- package/dist/match-fBetfaIa.mjs.map +1 -0
- package/dist/math/index.d.mts +2 -2
- package/dist/math/index.mjs +2 -2
- package/dist/object/index.d.mts +2 -2
- package/dist/object/index.mjs +2 -2
- package/dist/object-CILtZbTT.mjs +27 -0
- package/dist/{object-BHnp9Sr9.mjs.map → object-CILtZbTT.mjs.map} +1 -1
- package/dist/predicate/index.d.mts +2 -2
- package/dist/predicate/index.mjs +2 -2
- package/dist/{predicate-DtTBffBT.mjs → predicate-CleUejOb.mjs} +3 -3
- package/dist/{predicate-DtTBffBT.mjs.map → predicate-CleUejOb.mjs.map} +1 -1
- package/dist/promise/index.d.mts +2 -2
- package/dist/promise/index.mjs +2 -2
- package/dist/string/index.d.mts +2 -2
- package/dist/string/index.mjs +2 -2
- package/dist/{types-X6LqLWno.d.mts → types-BsimcHZS.d.mts} +1 -1
- package/dist/types-BsimcHZS.d.mts.map +1 -0
- package/package.json +17 -10
- package/dist/index-BjmDP8W9.d.mts.map +0 -1
- package/dist/index-Bp3ol0vr.d.mts.map +0 -1
- package/dist/index-D5l6I7QH.d.mts.map +0 -1
- package/dist/index-DtnKhaAD.d.mts +0 -39
- package/dist/index-DtnKhaAD.d.mts.map +0 -1
- package/dist/index-g2aw5tc_.d.mts.map +0 -1
- package/dist/index-keGHab-v.d.mts +0 -20
- package/dist/index-keGHab-v.d.mts.map +0 -1
- package/dist/index-mfIoxwxy.d.mts.map +0 -1
- package/dist/match-CG_v2C4Q.mjs +0 -44
- package/dist/match-CG_v2C4Q.mjs.map +0 -1
- package/dist/object-BHnp9Sr9.mjs +0 -27
- package/dist/types-X6LqLWno.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/zrosenbauer/massaman/main/.github/assets/banner.
|
|
2
|
+
<img src="https://raw.githubusercontent.com/zrosenbauer/massaman/main/.github/assets/banner.svg" alt="massaman" width="100%" />
|
|
3
3
|
<p><strong>Functional programming utilities for TypeScript. Result types, pattern matching, async pipelines. Fully typed.</strong></p>
|
|
4
4
|
|
|
5
5
|
<a href="https://github.com/zrosenbauer/massaman/actions/workflows/ci.yml"><img src="https://github.com/zrosenbauer/massaman/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
- Rust's `match` in TypeScript: exhaustive pattern matching via re-exported [ts-pattern](https://github.com/gvergnaud/ts-pattern).
|
|
14
14
|
- Rust's `Result` in TypeScript: compose fallible operations without throws (`attempt`, `attemptAsync`, `ok`, `err`, `isOk`, `unwrap`).
|
|
15
15
|
- Functional programming, fully typed: `flow`, `flowAsync`, `tap`, `when`, `ifElse`, and point-free combinators with end-to-end inference.
|
|
16
|
-
- The missing pieces around [es-toolkit](https://es-toolkit.dev): variadic-narrowing predicates, async composition, and consistent error normalization
|
|
17
|
-
- Tree-shakeable:
|
|
16
|
+
- The missing pieces around [es-toolkit](https://es-toolkit.dev): variadic-narrowing predicates, async composition, and consistent error normalization alongside its array, object, string, and math utilities.
|
|
17
|
+
- Tree-shakeable: focused subpath exports, ESM-only, `sideEffects: false`. Import only what you use.
|
|
18
18
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
@@ -26,7 +26,7 @@ npm install massaman
|
|
|
26
26
|
|
|
27
27
|
### From ts-pattern
|
|
28
28
|
|
|
29
|
-
The `
|
|
29
|
+
The `match` subpath re-exports [ts-pattern](https://github.com/gvergnaud/ts-pattern) and adds `P.ok` and `P.err` for Massaman results.
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
32
|
import { match, P } from 'massaman/match'
|
package/dist/array/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { adjust, ascend, at, chunk, compact, countBy, descend, difference, differenceBy, differenceWith, drop, dropRepeats, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last,
|
|
1
|
+
import { $ as union, A as isSubset, B as pullAt, C as forEachRight, D as intersection, E as initial, F as maxBy, G as shuffle, H as remove, I as minBy, J as take, K as sortBy, L as orderBy, M as keyBy, N as last, O as intersectionBy, P as mapAsync, Q as toFilled, R as partition, S as forEachAsync, St as adjust, T as head, U as sample, V as reduceAsync, W as sampleSize, X as takeRightWhile, Y as takeRight, Z as takeWhile, _ as flatMap, _t as descend, a as combinations, at as unzip, b as flatten, bt as reduceWhile, c as difference, ct as without, d as drop, dt as xorWith, et as unionBy, f as dropRight, ft as zip, g as filterAsync, gt as ascend, h as fill, ht as unfold, i as chunkBy, it as uniqWith, j as isSubsetWith, k as intersectionWith, l as differenceBy, lt as xor, m as dropWhile, mt as zipWith, n as cartesianProduct, nt as uniq, o as compact, ot as unzipWith, p as dropRightWhile, pt as zipObject, q as tail, r as chunk, rt as uniqBy, s as countBy, st as windowed, t as at, tt as unionWith, u as differenceWith, ut as xorBy, v as flatMapAsync, vt as sortWith, w as groupBy, x as flattenDeep, xt as dropRepeats, y as flatMapDeep, yt as scan, z as pull } from "../index-BPYJOreI.mjs";
|
|
2
|
+
export { adjust, ascend, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, descend, difference, differenceBy, differenceWith, drop, dropRepeats, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, reduceWhile, remove, sample, sampleSize, scan, shuffle, sortBy, sortWith, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, unfold, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
package/dist/array/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { adjust, ascend, at, chunk, compact, countBy, descend, difference, differenceBy, differenceWith, drop, dropRepeats, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last,
|
|
1
|
+
import { $ as union, A as isSubset, B as pullAt, C as forEachRight, D as intersection, E as initial, F as maxBy, G as shuffle, H as remove, I as minBy, J as take, K as sortBy, L as orderBy, M as keyBy, N as last, O as intersectionBy, P as mapAsync, Q as toFilled, R as partition, S as forEachAsync, St as adjust, T as head, U as sample, V as reduceAsync, W as sampleSize, X as takeRightWhile, Y as takeRight, Z as takeWhile, _ as flatMap, _t as descend, a as combinations, at as unzip, b as flatten, bt as reduceWhile, c as difference, ct as without, d as drop, dt as xorWith, et as unionBy, f as dropRight, ft as zip, g as filterAsync, gt as ascend, h as fill, ht as unfold, i as chunkBy, it as uniqWith, j as isSubsetWith, k as intersectionWith, l as differenceBy, lt as xor, m as dropWhile, mt as zipWith, n as cartesianProduct, nt as uniq, o as compact, ot as unzipWith, p as dropRightWhile, pt as zipObject, q as tail, r as chunk, rt as uniqBy, s as countBy, st as windowed, t as at, tt as unionWith, u as differenceWith, ut as xorBy, v as flatMapAsync, vt as sortWith, w as groupBy, x as flattenDeep, xt as dropRepeats, y as flatMapDeep, yt as scan, z as pull } from "../array-glQHknc3.mjs";
|
|
2
|
+
export { adjust, ascend, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, descend, difference, differenceBy, differenceWith, drop, dropRepeats, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, reduceWhile, remove, sample, sampleSize, scan, shuffle, sortBy, sortWith, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, unfold, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { at, chunk, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last,
|
|
1
|
+
import { at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith } from "es-toolkit/array";
|
|
2
2
|
//#region src/array/adjust.ts
|
|
3
3
|
/**
|
|
4
4
|
* Applies a function to the element at the given index, returning a new array.
|
|
@@ -186,6 +186,6 @@ function unfold(fn, seed) {
|
|
|
186
186
|
return result;
|
|
187
187
|
}
|
|
188
188
|
//#endregion
|
|
189
|
-
export {
|
|
189
|
+
export { union as $, isSubset as A, pullAt as B, forEachRight as C, intersection as D, initial as E, maxBy as F, shuffle as G, remove as H, minBy as I, take as J, sortBy as K, orderBy as L, keyBy as M, last as N, intersectionBy as O, mapAsync as P, toFilled as Q, partition as R, forEachAsync as S, adjust as St, head as T, sample as U, reduceAsync as V, sampleSize as W, takeRightWhile as X, takeRight as Y, takeWhile as Z, flatMap as _, descend as _t, combinations as a, unzip as at, flatten as b, reduceWhile as bt, difference as c, without as ct, drop as d, xorWith as dt, unionBy as et, dropRight as f, zip as ft, filterAsync as g, ascend as gt, fill as h, unfold as ht, chunkBy as i, uniqWith as it, isSubsetWith as j, intersectionWith as k, differenceBy as l, xor as lt, dropWhile as m, zipWith as mt, cartesianProduct as n, uniq as nt, compact as o, unzipWith as ot, dropRightWhile as p, zipObject as pt, tail as q, chunk as r, uniqBy as rt, countBy as s, windowed as st, at as t, unionWith as tt, differenceWith as u, xorBy as ut, flatMapAsync as v, sortWith as vt, groupBy as w, flattenDeep as x, dropRepeats as xt, flatMapDeep as y, scan as yt, pull as z };
|
|
190
190
|
|
|
191
|
-
//# sourceMappingURL=array-
|
|
191
|
+
//# sourceMappingURL=array-glQHknc3.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-
|
|
1
|
+
{"version":3,"file":"array-glQHknc3.mjs","names":[],"sources":["../src/array/adjust.ts","../src/array/dropRepeats.ts","../src/array/reduceWhile.ts","../src/array/scan.ts","../src/array/sorting.ts","../src/array/unfold.ts"],"sourcesContent":["/**\n * Applies a function to the element at the given index, returning a new array.\n *\n * The original array is not modified. If the index is out of bounds, the\n * array is returned unchanged.\n *\n * @example\n * ```ts\n * adjust([1, 2, 3], 1, (n) => n * 10)\n * // [1, 20, 3]\n * ```\n */\nexport function adjust<T>(array: readonly T[], index: number, fn: (value: T) => T): T[] {\n const result = [...array]\n if (index >= 0 && index < array.length) {\n // oxlint-disable-next-line security/detect-object-injection -- Numeric array index parameter, not user-controlled key\n result[index] = fn(result[index])\n }\n return result\n}\n","/**\n * Removes consecutively repeated elements from an array using strict\n * equality (`===`).\n *\n * Only adjacent duplicates are removed — non-adjacent duplicates are kept.\n * Use {@link uniq} from es-toolkit to remove all duplicates regardless of position.\n *\n * Quirks (inherent to `===`):\n * - `NaN !== NaN`, so adjacent `NaN`s are *not* collapsed.\n * - `-0 === 0`, so adjacent `-0` and `0` *are* collapsed.\n * - Object/array elements compare by reference, not structure.\n *\n * @example\n * ```ts\n * dropRepeats([1, 1, 2, 3, 3, 2, 1])\n * // [1, 2, 3, 2, 1]\n * ```\n */\nexport function dropRepeats<T>(array: readonly T[]): T[] {\n return array.reduce<T[]>((acc, item, index) => {\n if (index === 0 || item !== array[index - 1]) {\n acc.push(item)\n }\n return acc\n }, [])\n}\n","/**\n * Like `reduce` but stops early when the predicate returns `false`.\n *\n * The predicate receives the current accumulator and element. When it\n * returns `false`, the current accumulator is returned without processing\n * the remaining elements.\n *\n * @example\n * ```ts\n * // Sum until we hit a negative number\n * reduceWhile(\n * [1, 2, 3, -1, 5],\n * (acc, n) => n >= 0,\n * (acc, n) => acc + n,\n * 0,\n * )\n * // 6\n * ```\n */\nexport function reduceWhile<T, R>(\n array: readonly T[],\n predicate: (accumulator: R, value: T) => boolean,\n fn: (accumulator: R, value: T, index: number) => R,\n initial: R\n): R {\n // oxlint-disable-next-line functional/no-let -- iterative impl avoids stack overflow on large arrays\n let acc = initial\n // oxlint-disable-next-line functional/no-let -- iterative impl avoids stack overflow on large arrays\n for (let index = 0; index < array.length; index += 1) {\n // oxlint-disable-next-line security/detect-object-injection -- Locally computed numeric array index\n const value = array[index]\n if (!predicate(acc, value)) {\n return acc\n }\n acc = fn(acc, value, index)\n }\n return acc\n}\n","/**\n * Like `reduce` but returns an array of all intermediate accumulator values.\n *\n * The result array starts with the initial value and ends with the final\n * accumulator, so its length is `array.length + 1`.\n *\n * @example\n * ```ts\n * scan([1, 2, 3, 4], (acc, n) => acc + n, 0)\n * // [0, 1, 3, 6, 10]\n * ```\n */\nexport function scan<T, R>(\n array: readonly T[],\n fn: (accumulator: R, value: T, index: number) => R,\n initial: R\n): R[] {\n return array.reduce<R[]>(\n (result, item, index) => {\n const prev = result[result.length - 1]\n result.push(fn(prev, item, index))\n return result\n },\n [initial]\n )\n}\n","/**\n * Creates an ascending comparator from an accessor function.\n *\n * @example\n * ```ts\n * users.sort(ascend(u => u.name))\n * ```\n */\nexport function ascend<T>(fn: (value: T) => number | string): (a: T, b: T) => number {\n return (a: T, b: T) => {\n const aa = fn(a)\n const bb = fn(b)\n if (aa < bb) {\n return -1\n }\n if (aa > bb) {\n return 1\n }\n return 0\n }\n}\n\n/**\n * Creates a descending comparator from an accessor function.\n *\n * @example\n * ```ts\n * users.sort(descend(u => u.age))\n * ```\n */\nexport function descend<T>(fn: (value: T) => number | string): (a: T, b: T) => number {\n return (a: T, b: T) => {\n const aa = fn(a)\n const bb = fn(b)\n if (aa > bb) {\n return -1\n }\n if (aa < bb) {\n return 1\n }\n return 0\n }\n}\n\n/**\n * Sorts an array using multiple comparators in priority order.\n *\n * The first comparator has highest priority. When it returns 0 (tie),\n * the next comparator is used, and so on.\n *\n * @example\n * ```ts\n * sortWith(users, [\n * ascend(u => u.department),\n * descend(u => u.age),\n * ])\n * ```\n */\nexport function sortWith<T>(\n array: readonly T[],\n comparators: ReadonlyArray<(a: T, b: T) => number>\n): T[] {\n return [...array].toSorted((a, b) => {\n for (const cmp of comparators) {\n const result = cmp(a, b)\n if (result !== 0) {\n return result\n }\n }\n return 0\n })\n}\n","/**\n * Builds an array from a seed value using an iterator function.\n *\n * The iterator receives the current seed and returns either a `[value, nextSeed]`\n * tuple to continue, or `false` to stop.\n *\n * Dual of `reduce` — reduce collapses a list into a value, unfold expands\n * a value into a list.\n *\n * **Termination is the caller's responsibility.** If `fn` never returns\n * `false`, `unfold` will run until memory is exhausted. For bounded\n * generation, encode a counter or limit into the seed.\n *\n * @example\n * ```ts\n * unfold((n) => (n > 0 ? [n, n - 1] : false), 5)\n * // [5, 4, 3, 2, 1]\n * ```\n */\nexport function unfold<T, R>(fn: (seed: T) => [R, T] | false, seed: T): R[] {\n const result: R[] = []\n // oxlint-disable-next-line functional/no-let -- iterative impl avoids stack overflow on large outputs\n let current = seed\n // oxlint-disable-next-line functional/no-let -- iterative impl avoids stack overflow on large outputs\n let pair = fn(current)\n while (pair !== false) {\n result.push(pair[0])\n current = pair[1]\n pair = fn(current)\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,OAAU,OAAqB,OAAe,IAA0B;CACtF,MAAM,SAAS,CAAC,GAAG,KAAK;CACxB,IAAI,SAAS,KAAK,QAAQ,MAAM,QAE9B,OAAO,SAAS,GAAG,OAAO,MAAM;CAElC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;ACDA,SAAgB,YAAe,OAA0B;CACvD,OAAO,MAAM,QAAa,KAAK,MAAM,UAAU;EAC7C,IAAI,UAAU,KAAK,SAAS,MAAM,QAAQ,IACxC,IAAI,KAAK,IAAI;EAEf,OAAO;CACT,GAAG,CAAC,CAAC;AACP;;;;;;;;;;;;;;;;;;;;;;ACNA,SAAgB,YACd,OACA,WACA,IACA,SACG;CAEH,IAAI,MAAM;CAEV,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;EAEpD,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,UAAU,KAAK,KAAK,GACvB,OAAO;EAET,MAAM,GAAG,KAAK,OAAO,KAAK;CAC5B;CACA,OAAO;AACT;;;;;;;;;;;;;;;ACzBA,SAAgB,KACd,OACA,IACA,SACK;CACL,OAAO,MAAM,QACV,QAAQ,MAAM,UAAU;EACvB,MAAM,OAAO,OAAO,OAAO,SAAS;EACpC,OAAO,KAAK,GAAG,MAAM,MAAM,KAAK,CAAC;EACjC,OAAO;CACT,GACA,CAAC,OAAO,CACV;AACF;;;;;;;;;;;ACjBA,SAAgB,OAAU,IAA2D;CACnF,QAAQ,GAAM,MAAS;EACrB,MAAM,KAAK,GAAG,CAAC;EACf,MAAM,KAAK,GAAG,CAAC;EACf,IAAI,KAAK,IACP,OAAO;EAET,IAAI,KAAK,IACP,OAAO;EAET,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,QAAW,IAA2D;CACpF,QAAQ,GAAM,MAAS;EACrB,MAAM,KAAK,GAAG,CAAC;EACf,MAAM,KAAK,GAAG,CAAC;EACf,IAAI,KAAK,IACP,OAAO;EAET,IAAI,KAAK,IACP,OAAO;EAET,OAAO;CACT;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,SACd,OACA,aACK;CACL,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,UAAU,GAAG,MAAM;EACnC,KAAK,MAAM,OAAO,aAAa;GAC7B,MAAM,SAAS,IAAI,GAAG,CAAC;GACvB,IAAI,WAAW,GACb,OAAO;EAEX;EACA,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;ACpDA,SAAgB,OAAa,IAAiC,MAAc;CAC1E,MAAM,SAAc,CAAC;CAErB,IAAI,UAAU;CAEd,IAAI,OAAO,GAAG,OAAO;CACrB,OAAO,SAAS,OAAO;EACrB,OAAO,KAAK,KAAK,EAAE;EACnB,UAAU,KAAK;EACf,OAAO,GAAG,OAAO;CACnB;CACA,OAAO;AACT"}
|
package/dist/control/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as Ok, r as Result, t as Err } from "../types-
|
|
2
|
-
import { a as todo, c as isOk, d as attempt, f as attemptAsync, i as unimplemented, l as ok, n as invariant, o as err, r as unreachable, s as isErr, t as assert, u as unwrap } from "../index-
|
|
3
|
-
export { Err, Ok, Result, assert, attempt, attemptAsync, err, invariant, isErr, isOk, ok, todo, unimplemented, unreachable, unwrap };
|
|
1
|
+
import { n as Ok, r as Result, t as Err } from "../types-BsimcHZS.mjs";
|
|
2
|
+
import { a as todo, c as isOk, d as attempt, f as attemptAsync, i as unimplemented, l as ok, n as invariant, o as err, r as unreachable, s as isErr, t as assert, u as unwrap } from "../index-D5q3I26j.mjs";
|
|
3
|
+
export { type Err, type Ok, type Result, assert, attempt, attemptAsync, err, invariant, isErr, isOk, ok, todo, unimplemented, unreachable, unwrap };
|
package/dist/control/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as todo, c as err, d as ok, f as unwrap, i as unimplemented, l as isErr, n as invariant, o as attempt, r as unreachable, s as attemptAsync, t as assert, u as isOk } from "../control-
|
|
1
|
+
import { a as todo, c as err, d as ok, f as unwrap, i as unimplemented, l as isErr, n as invariant, o as attempt, r as unreachable, s as attemptAsync, t as assert, u as isOk } from "../control-DCdm8IH6.mjs";
|
|
2
2
|
export { assert, attempt, attemptAsync, err, invariant, isErr, isOk, ok, todo, unimplemented, unreachable, unwrap };
|
|
@@ -240,4 +240,4 @@ function unreachable(message) {
|
|
|
240
240
|
//#endregion
|
|
241
241
|
export { todo as a, err as c, ok as d, unwrap as f, unimplemented as i, isErr as l, invariant as n, attempt as o, unreachable as r, attemptAsync as s, assert as t, isOk as u };
|
|
242
242
|
|
|
243
|
-
//# sourceMappingURL=control-
|
|
243
|
+
//# sourceMappingURL=control-DCdm8IH6.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-
|
|
1
|
+
{"version":3,"file":"control-DCdm8IH6.mjs","names":[],"sources":["../src/control/result.ts","../src/control/attempt.ts","../src/control/todo.ts","../src/control/unimplemented.ts","../src/control/unreachable.ts"],"sourcesContent":["import { isNil } from 'es-toolkit/predicate'\n\nimport type { Err, Ok, Result } from './types.js'\n\n/**\n * Minimal error coercion used internally by `err()`. Kept local to avoid\n * pulling the full conversion module into the `massaman/control` bundle.\n * For richer stringification (Maps, Sets, Errors with own props, circular\n * refs), import `toError` from `massaman/conversion`.\n */\nfunction coerceError(thrown: unknown): Error {\n if (thrown instanceof Error) {\n return thrown\n }\n if (typeof thrown === 'string') {\n return new Error(thrown)\n }\n try {\n const message = JSON.stringify(thrown) ?? String(thrown)\n return new Error(message, { cause: thrown })\n } catch {\n return new Error(String(thrown), { cause: thrown })\n }\n}\n\n/**\n * Creates a success result wrapping the given value.\n *\n * @param value - The success value\n * @returns An `Ok` result containing the value\n *\n * @example\n * ```ts\n * const result = ok(42)\n * // { ok: true, value: 42 }\n * ```\n */\nexport function ok<T>(value: T): Ok<T> {\n return { ok: true, value, error: null }\n}\n\n/**\n * Creates a failure result wrapping the given error.\n *\n * @param error - The error value\n * @returns An `Err` result containing the error\n *\n * @example\n * ```ts\n * const result = err(new Error('fail'))\n * // { ok: false, error: Error('fail') }\n * ```\n */\nexport function err(error: unknown): Err {\n return { ok: false, value: null, error: coerceError(error) }\n}\n\n/**\n * Type guard that narrows a `Result` to `Ok`.\n *\n * @param result - The result to check\n * @returns `true` if the result is `Ok`\n *\n * @example\n * ```ts\n * const result = attempt(() => JSON.parse('{}'))\n * if (isOk(result)) {\n * console.log(result.value)\n * }\n * ```\n */\nexport function isOk<T>(result: Result<T>): result is Ok<T> {\n return result.ok === true\n}\n\n/**\n * Type guard that narrows a `Result` to `Err`.\n *\n * @param result - The result to check\n * @returns `true` if the result is `Err`\n *\n * @example\n * ```ts\n * const result = attempt(() => JSON.parse('bad'))\n * if (isErr(result)) {\n * console.error(result.error)\n * }\n * ```\n */\nexport function isErr<T>(result: Result<T>): result is Err {\n return result.ok === false\n}\n\n/**\n * Extract the value from an `Ok` result, or throw on `Err`.\n *\n * When called without a message, throws the original error.\n * When called with a message, throws a new Error with that message\n * and the original error as `cause` (like Rust's `expect`).\n *\n * @param result - The result to unwrap\n * @param message - Optional custom error message (Rust `expect` behavior)\n * @returns The unwrapped value\n *\n * @example\n * ```ts\n * const value = unwrap(ok(42)) // 42\n * unwrap(err('fail')) // throws Error('fail')\n * unwrap(err('fail'), 'config required') // throws Error('config required', { cause: Error('fail') })\n * ```\n */\nexport function unwrap<T>(result: Result<T>, message?: string): T {\n if (result.ok) {\n return result.value\n }\n if (!isNil(message)) {\n throw new Error(message, { cause: result.error })\n }\n throw result.error\n}\n","import { err, ok } from './result.js'\nimport type { Result } from './types.js'\n\n/**\n * Executes a synchronous function and wraps the outcome in a `Result`.\n * Returns `Ok` with the return value on success, `Err` with the thrown value on failure.\n *\n * @param fn - The function to execute\n * @returns A `Result` containing either the value or the error\n *\n * @example\n * ```ts\n * const result = attempt(() => JSON.parse('{\"a\":1}'))\n * if (isOk(result)) {\n * console.log(result.value) // { a: 1 }\n * }\n * ```\n */\nexport function attempt<T>(fn: () => T): Result<T> {\n try {\n return ok(fn())\n } catch (error) {\n return err(error)\n }\n}\n\n/**\n * Executes an asynchronous function and wraps the outcome in a `Result`.\n * Returns `Ok` with the resolved value on success, `Err` with the rejection reason on failure.\n *\n * @param fn - The async function to execute\n * @returns A promise resolving to a `Result` containing either the value or the error\n *\n * @example\n * ```ts\n * const result = await attemptAsync(() => fetch('/api/data'))\n * if (isErr(result)) {\n * console.error(result.error)\n * }\n * ```\n */\nexport async function attemptAsync<T>(fn: () => Promise<T>): Promise<Result<T>> {\n try {\n return ok(await fn())\n } catch (error) {\n return err(error)\n }\n}\n","import { isNil } from 'es-toolkit/predicate'\n\n/**\n * Stub for a code path you intend to write but haven't. Throws at runtime,\n * returns `never` so it typechecks in any position.\n *\n * For paths you intentionally don't support, see `unimplemented`.\n * For paths that should be impossible, see `unreachable`.\n *\n * @param message - Optional context appended to the thrown error\n * @returns Never returns — always throws\n *\n * @example\n * ```ts\n * function parseConfig(raw: string): Config {\n * return todo('waiting on schema decision')\n * }\n * ```\n */\nexport function todo(message?: string): never {\n if (isNil(message)) {\n throw new Error('not yet implemented')\n }\n throw new Error(`not yet implemented: ${message}`)\n}\n","import { isNil } from 'es-toolkit/predicate'\n\n/**\n * Marks a code path as intentionally unsupported. Throws at runtime, returns\n * `never` so it typechecks in any position.\n *\n * For work you plan to finish later, see `todo`.\n * For paths that should be impossible, see `unreachable`.\n *\n * @param message - Optional context appended to the thrown error\n * @returns Never returns — always throws\n *\n * @example\n * ```ts\n * type Driver = 'postgres' | 'sqlite' | 'mysql'\n *\n * function migrate(driver: Driver): void {\n * return match(driver)\n * .with('postgres', runPgMigration)\n * .with('sqlite', runSqliteMigration)\n * .with('mysql', () => unimplemented('mysql driver intentionally unsupported'))\n * .exhaustive()\n * }\n * ```\n */\nexport function unimplemented(message?: string): never {\n if (isNil(message)) {\n throw new Error('not implemented')\n }\n throw new Error(`not implemented: ${message}`)\n}\n","import { isNil } from 'es-toolkit/predicate'\n\n/**\n * Marks a code path as logically impossible. Throws at runtime if execution\n * gets there. Returns `never` so it typechecks in any position.\n *\n * For work you plan to finish later, see `todo`.\n * For paths you intentionally don't support, see `unimplemented`.\n *\n * @param message - Optional context appended to the thrown error\n * @returns Never returns — always throws\n *\n * @example\n * ```ts\n * function parseDigit(input: string): number {\n * const parsed = Number.parseInt(input, 10)\n * if (Number.isNaN(parsed)) {\n * return unreachable('caller pre-validated')\n * }\n * return parsed\n * }\n * ```\n */\nexport function unreachable(message?: string): never {\n if (isNil(message)) {\n throw new Error('entered unreachable code')\n }\n throw new Error(`entered unreachable code: ${message}`)\n}\n"],"mappings":";;;;;;;;;AAUA,SAAS,YAAY,QAAwB;CAC3C,IAAI,kBAAkB,OACpB,OAAO;CAET,IAAI,OAAO,WAAW,UACpB,OAAO,IAAI,MAAM,MAAM;CAEzB,IAAI;EACF,MAAM,UAAU,KAAK,UAAU,MAAM,KAAK,OAAO,MAAM;EACvD,OAAO,IAAI,MAAM,SAAS,EAAE,OAAO,OAAO,CAAC;CAC7C,QAAQ;EACN,OAAO,IAAI,MAAM,OAAO,MAAM,GAAG,EAAE,OAAO,OAAO,CAAC;CACpD;AACF;;;;;;;;;;;;;AAcA,SAAgB,GAAM,OAAiB;CACrC,OAAO;EAAE,IAAI;EAAM;EAAO,OAAO;CAAK;AACxC;;;;;;;;;;;;;AAcA,SAAgB,IAAI,OAAqB;CACvC,OAAO;EAAE,IAAI;EAAO,OAAO;EAAM,OAAO,YAAY,KAAK;CAAE;AAC7D;;;;;;;;;;;;;;;AAgBA,SAAgB,KAAQ,QAAoC;CAC1D,OAAO,OAAO,OAAO;AACvB;;;;;;;;;;;;;;;AAgBA,SAAgB,MAAS,QAAkC;CACzD,OAAO,OAAO,OAAO;AACvB;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,OAAU,QAAmB,SAAqB;CAChE,IAAI,OAAO,IACT,OAAO,OAAO;CAEhB,IAAI,CAAC,MAAM,OAAO,GAChB,MAAM,IAAI,MAAM,SAAS,EAAE,OAAO,OAAO,MAAM,CAAC;CAElD,MAAM,OAAO;AACf;;;;;;;;;;;;;;;;;;ACrGA,SAAgB,QAAW,IAAwB;CACjD,IAAI;EACF,OAAO,GAAG,GAAG,CAAC;CAChB,SAAS,OAAO;EACd,OAAO,IAAI,KAAK;CAClB;AACF;;;;;;;;;;;;;;;;AAiBA,eAAsB,aAAgB,IAA0C;CAC9E,IAAI;EACF,OAAO,GAAG,MAAM,GAAG,CAAC;CACtB,SAAS,OAAO;EACd,OAAO,IAAI,KAAK;CAClB;AACF;;;;;;;;;;;;;;;;;;;;AC5BA,SAAgB,KAAK,SAAyB;CAC5C,IAAI,MAAM,OAAO,GACf,MAAM,IAAI,MAAM,qBAAqB;CAEvC,MAAM,IAAI,MAAM,wBAAwB,SAAS;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;;ACCA,SAAgB,cAAc,SAAyB;CACrD,IAAI,MAAM,OAAO,GACf,MAAM,IAAI,MAAM,iBAAiB;CAEnC,MAAM,IAAI,MAAM,oBAAoB,SAAS;AAC/C;;;;;;;;;;;;;;;;;;;;;;;;ACPA,SAAgB,YAAY,SAAyB;CACnD,IAAI,MAAM,OAAO,GACf,MAAM,IAAI,MAAM,0BAA0B;CAE5C,MAAM,IAAI,MAAM,6BAA6B,SAAS;AACxD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as toFinite, c as toString, i as toError, n as toArray, o as toInteger, r as toBoolean, s as toNumber, t as stringify } from "../index-
|
|
1
|
+
import { a as toFinite, c as toString, i as toError, n as toArray, o as toInteger, r as toBoolean, s as toNumber, t as stringify } from "../index-C7dxY5U-.mjs";
|
|
2
2
|
export { stringify, toArray, toBoolean, toError, toFinite, toInteger, toNumber, toString };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as toFinite, c as toString, i as toError, n as toArray, o as toInteger, r as toBoolean, s as toNumber, t as stringify } from "../conversion-
|
|
1
|
+
import { a as toFinite, c as toString, i as toError, n as toArray, o as toInteger, r as toBoolean, s as toNumber, t as stringify } from "../conversion-BB912-15.mjs";
|
|
2
2
|
export { stringify, toArray, toBoolean, toError, toFinite, toInteger, toNumber, toString };
|
|
@@ -186,4 +186,4 @@ function toBoolean(value) {
|
|
|
186
186
|
//#endregion
|
|
187
187
|
export { toFinite as a, toString as c, toError as i, toArray as n, toInteger as o, toBoolean as r, toNumber as s, stringify as t };
|
|
188
188
|
|
|
189
|
-
//# sourceMappingURL=conversion-
|
|
189
|
+
//# sourceMappingURL=conversion-BB912-15.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-
|
|
1
|
+
{"version":3,"file":"conversion-BB912-15.mjs","names":[],"sources":["../src/conversion/convert.ts"],"sourcesContent":["import { isError, isMap, isNil, isPrimitive, isSet, isString } from 'es-toolkit/predicate'\n\n/**\n * Coerces an unknown thrown value into a proper `Error` instance.\n *\n * Handles the common cases where libraries throw non-`Error` values\n * (e.g. plain API response bodies, arrays, Maps) that would otherwise\n * serialize as `[object Object]` in error messages.\n *\n * @param thrown - The caught value from a `catch` block.\n * @returns An `Error` with a meaningful `.message`. If `thrown` is\n * already an `Error`, it is returned as-is. The original value is\n * preserved as `.cause` for debugging.\n *\n * @example\n * ```ts\n * try {\n * await riskyCall()\n * } catch (thrown) {\n * const error = toError(thrown)\n * console.error(error.message)\n * }\n * ```\n */\nexport function toError(thrown: unknown): Error {\n if (isError(thrown)) {\n return thrown\n }\n if (isString(thrown)) {\n return new Error(thrown)\n }\n return new Error(stringify(thrown), { cause: thrown })\n}\n\n/**\n * Produces a human-readable string from any unknown value.\n *\n * Uses `JSON.stringify` for structured types (plain objects, arrays)\n * so the message contains actual content instead of `[object Object]`.\n * Maps and Sets are converted to their array representation first.\n * Falls back to `String()` for primitives or when serialization fails\n * (e.g. circular references).\n *\n * @param value - The value to stringify.\n * @returns A meaningful string representation.\n *\n * @example\n * ```ts\n * stringify({ status: 400 }) // '{\"status\":400}'\n * stringify(new Map([['k', 'v']])) // '[[\"k\",\"v\"]]'\n * stringify(null) // 'null'\n * stringify(42) // '42'\n * ```\n */\nexport function stringify(value: unknown): string {\n if (isNil(value) || isPrimitive(value)) {\n return String(value)\n }\n try {\n return JSON.stringify(toSerializable(value))\n } catch {\n return String(value)\n }\n}\n\n/**\n * Convert types that `JSON.stringify` handles poorly into\n * serializable equivalents, recursively walking objects and arrays.\n *\n * - `Map` -> array of `[key, value]` entries (recursed)\n * - `Set` -> array of values (recursed)\n * - `Error` -> plain object with `name`, `message`, `stack`, and enumerable props\n * - Arrays and plain objects are recursed\n * - Uses a `WeakSet` to detect and break circular references\n */\nfunction toSerializable(value: unknown, seen: WeakSet<object> = new WeakSet()): unknown {\n if (isNil(value) || isPrimitive(value)) {\n return value\n }\n\n const obj = value as object\n if (seen.has(obj)) {\n return '[Circular]'\n }\n seen.add(obj)\n\n if (isError(value)) {\n const errorObj: Record<string, unknown> = {\n name: value.name,\n message: value.message,\n stack: value.stack,\n }\n for (const key of Object.keys(value)) {\n // oxlint-disable-next-line security/detect-object-injection -- safe: key from Object.keys\n errorObj[key] = toSerializable((value as unknown as Record<string, unknown>)[key], seen)\n }\n return errorObj\n }\n\n if (isMap(value)) {\n return Array.from(value.entries()).map(([k, v]) => [\n toSerializable(k, seen),\n toSerializable(v, seen),\n ])\n }\n\n if (isSet(value)) {\n return Array.from(value).map((v) => toSerializable(v, seen))\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => toSerializable(v, seen))\n }\n\n const result: Record<string, unknown> = {}\n for (const key of Object.keys(value as Record<string, unknown>)) {\n // oxlint-disable-next-line security/detect-object-injection -- safe: key from Object.keys\n result[key] = toSerializable((value as Record<string, unknown>)[key], seen)\n }\n return result\n}\n\n/**\n * Converts a value to a number.\n *\n * Thin wrapper over `Number(value)` — kept as a stable surface so callers\n * don't depend directly on the global constructor's semantics (which have\n * shifted in the past, e.g. `Number(BigInt)`, and may again).\n *\n * @example\n * ```ts\n * toNumber('42') // 42\n * toNumber(null) // 0\n * ```\n */\nexport function toNumber(value: unknown): number {\n return Number(value)\n}\n\n/**\n * Converts a value to a string.\n *\n * Thin wrapper over `String(value)` — kept as a stable surface against\n * future global-constructor changes.\n *\n * @example\n * ```ts\n * toString(42) // '42'\n * toString(null) // 'null'\n * ```\n */\nexport function toString(value: unknown): string {\n return String(value)\n}\n\n/**\n * Converts a value to an integer by calling {@link toNumber} and truncating.\n *\n * @example\n * ```ts\n * toInteger('4.9') // 4\n * toInteger(null) // 0\n * ```\n */\nexport function toInteger(value: unknown): number {\n return Math.trunc(toNumber(value))\n}\n\n/**\n * Converts a value to a finite number.\n *\n * Returns `0` for non-finite results (`NaN`, `Infinity`, `-Infinity`).\n *\n * @example\n * ```ts\n * toFinite('3.14') // 3.14\n * toFinite(Infinity) // 0\n * ```\n */\nexport function toFinite(value: unknown): number {\n const n = Number(value)\n if (Number.isFinite(n)) {\n return n\n }\n return 0\n}\n\n/**\n * Converts a value to an array.\n *\n * - Arrays are returned as-is.\n * - Iterables (strings, Sets, Maps) are spread into an array.\n * - `null` / `undefined` return `[]`.\n * - All other values are wrapped in a single-element array.\n *\n * @example\n * ```ts\n * toArray(new Set([1, 2])) // [1, 2]\n * toArray('abc') // ['a', 'b', 'c']\n * toArray(null) // []\n * toArray(42) // [42]\n * ```\n */\nexport function toArray<T>(value: Iterable<T> | T | null | undefined): T[] {\n if (value == null) {\n return []\n }\n if (Array.isArray(value)) {\n return value as T[]\n }\n if (typeof (value as unknown as Record<symbol, unknown>)[Symbol.iterator] === 'function') {\n return Array.from(value as Iterable<T>)\n }\n return [value as T]\n}\n\n/**\n * Converts a value to a boolean.\n *\n * Thin wrapper over `Boolean(value)` — kept as a stable surface against\n * future global-constructor changes.\n *\n * @example\n * ```ts\n * toBoolean(1) // true\n * toBoolean(0) // false\n * toBoolean('') // false\n * ```\n */\nexport function toBoolean(value: unknown): boolean {\n return Boolean(value)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,QAAQ,QAAwB;CAC9C,IAAI,QAAQ,MAAM,GAChB,OAAO;CAET,IAAI,SAAS,MAAM,GACjB,OAAO,IAAI,MAAM,MAAM;CAEzB,OAAO,IAAI,MAAM,UAAU,MAAM,GAAG,EAAE,OAAO,OAAO,CAAC;AACvD;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,UAAU,OAAwB;CAChD,IAAI,MAAM,KAAK,KAAK,YAAY,KAAK,GACnC,OAAO,OAAO,KAAK;CAErB,IAAI;EACF,OAAO,KAAK,UAAU,eAAe,KAAK,CAAC;CAC7C,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;;;;;;;;;;;AAYA,SAAS,eAAe,OAAgB,uBAAwB,IAAI,QAAQ,GAAY;CACtF,IAAI,MAAM,KAAK,KAAK,YAAY,KAAK,GACnC,OAAO;CAGT,MAAM,MAAM;CACZ,IAAI,KAAK,IAAI,GAAG,GACd,OAAO;CAET,KAAK,IAAI,GAAG;CAEZ,IAAI,QAAQ,KAAK,GAAG;EAClB,MAAM,WAAoC;GACxC,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,OAAO,MAAM;EACf;EACA,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAEjC,SAAS,OAAO,eAAgB,MAA6C,MAAM,IAAI;EAEzF,OAAO;CACT;CAEA,IAAI,MAAM,KAAK,GACb,OAAO,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CACjD,eAAe,GAAG,IAAI,GACtB,eAAe,GAAG,IAAI,CACxB,CAAC;CAGH,IAAI,MAAM,KAAK,GACb,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,KAAK,MAAM,eAAe,GAAG,IAAI,CAAC;CAG7D,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,MAAM,eAAe,GAAG,IAAI,CAAC;CAGjD,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAgC,GAE5D,OAAO,OAAO,eAAgB,MAAkC,MAAM,IAAI;CAE5E,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,SAAS,OAAwB;CAC/C,OAAO,OAAO,KAAK;AACrB;;;;;;;;;;;;;AAcA,SAAgB,SAAS,OAAwB;CAC/C,OAAO,OAAO,KAAK;AACrB;;;;;;;;;;AAWA,SAAgB,UAAU,OAAwB;CAChD,OAAO,KAAK,MAAM,SAAS,KAAK,CAAC;AACnC;;;;;;;;;;;;AAaA,SAAgB,SAAS,OAAwB;CAC/C,MAAM,IAAI,OAAO,KAAK;CACtB,IAAI,OAAO,SAAS,CAAC,GACnB,OAAO;CAET,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,SAAgB,QAAW,OAAgD;CACzE,IAAI,SAAS,MACX,OAAO,CAAC;CAEV,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAET,IAAI,OAAQ,MAA6C,OAAO,cAAc,YAC5E,OAAO,MAAM,KAAK,KAAoB;CAExC,OAAO,CAAC,KAAU;AACpB;;;;;;;;;;;;;;AAeA,SAAgB,UAAU,OAAyB;CACjD,OAAO,QAAQ,KAAK;AACtB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith } from "es-toolkit/fp";
|
|
2
|
+
export { type WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith } from "es-toolkit/fp";
|
|
2
|
+
export { add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as unless, C as retry, D as flowAsync, E as unary, M as call, N as callAsync, O as tap, S as rest, T as throttle, _ as negate, a as ThrottledFunction, b as partial, c as asyncNoop, d as curryRight, f as debounce, g as memoize, h as identity, i as ThrottleOptions, j as when, k as ifElse, l as before, m as flowRight, n as DebouncedFunction, o as after, p as flow, r as MemoizeCache, s as ary, t as DebounceOptions, u as curry, v as noop, w as spread, x as partialRight, y as once } from "../index-
|
|
2
|
-
export { DebounceOptions, DebouncedFunction, MemoizeCache, ThrottleOptions, ThrottledFunction, after, ary, asyncNoop, before, call, callAsync, curry, curryRight, debounce, flow, flowAsync, flowRight, identity, ifElse, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, tap, throttle, unary, unless, when };
|
|
1
|
+
import { A as unless, C as retry, D as flowAsync, E as unary, M as call, N as callAsync, O as tap, S as rest, T as throttle, _ as negate, a as ThrottledFunction, b as partial, c as asyncNoop, d as curryRight, f as debounce, g as memoize, h as identity, i as ThrottleOptions, j as when, k as ifElse, l as before, m as flowRight, n as DebouncedFunction, o as after, p as flow, r as MemoizeCache, s as ary, t as DebounceOptions, u as curry, v as noop, w as spread, x as partialRight, y as once } from "../index-DlZyDxI_.mjs";
|
|
2
|
+
export { type DebounceOptions, type DebouncedFunction, type MemoizeCache, type ThrottleOptions, type ThrottledFunction, after, ary, asyncNoop, before, call, callAsync, curry, curryRight, debounce, flow, flowAsync, flowRight, identity, ifElse, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, tap, throttle, unary, unless, when };
|
package/dist/function/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as tap, D as call, E as when, O as callAsync, S as flowAsync, T as unless, _ as rest, a as curry, b as throttle, c as flow, d as memoize, f as negate, g as partialRight, h as partial, i as before, l as flowRight, m as once, n as ary, o as curryRight, p as noop, r as asyncNoop, s as debounce, t as after, u as identity, v as retry, w as ifElse, x as unary, y as spread } from "../function-
|
|
1
|
+
import { C as tap, D as call, E as when, O as callAsync, S as flowAsync, T as unless, _ as rest, a as curry, b as throttle, c as flow, d as memoize, f as negate, g as partialRight, h as partial, i as before, l as flowRight, m as once, n as ary, o as curryRight, p as noop, r as asyncNoop, s as debounce, t as after, u as identity, v as retry, w as ifElse, x as unary, y as spread } from "../function-Brosl7-Y.mjs";
|
|
2
2
|
export { after, ary, asyncNoop, before, call, callAsync, curry, curryRight, debounce, flow, flowAsync, flowRight, identity, ifElse, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, tap, throttle, unary, unless, when };
|
|
@@ -119,4 +119,4 @@ function flowAsync(first, ...rest) {
|
|
|
119
119
|
//#endregion
|
|
120
120
|
export { tap as C, call as D, when as E, callAsync as O, flowAsync as S, unless as T, rest as _, curry as a, throttle as b, flow as c, memoize as d, negate as f, partialRight as g, partial as h, before as i, flowRight as l, once as m, ary as n, curryRight as o, noop as p, asyncNoop as r, debounce as s, after as t, identity as u, retry as v, ifElse as w, unary as x, spread as y };
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=function-
|
|
122
|
+
//# sourceMappingURL=function-Brosl7-Y.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-
|
|
1
|
+
{"version":3,"file":"function-Brosl7-Y.mjs","names":[],"sources":["../src/function/call.ts","../src/function/branching.ts","../src/function/tap.ts","../src/function/flowAsync.ts"],"sourcesContent":["/**\n * Invokes a function with the provided arguments and returns the result.\n *\n * Equivalent to `fn(...args)` — exists as a stable, named surface for the\n * \"apply function to args\" operation. Use inside `.map(call)` over arrays\n * of thunks, or anywhere a value-position function-call is clearer than an\n * inline arrow.\n *\n * @example\n * ```ts\n * call(Math.max, 1, 2, 3) // 3\n * [getUser, getAccount, getPrefs].map((fn) => call(fn))\n * ```\n */\nexport function call<A extends readonly unknown[], R>(fn: (...args: A) => R, ...args: A): R {\n return fn(...args)\n}\n\n/**\n * Invokes a function returning a Promise with the provided arguments.\n *\n * Async-typed sibling of {@link call} — equivalent to `fn(...args)` for\n * promise-returning functions, but the signature constrains the return to\n * `Promise<R>` so it composes cleanly inside async pipelines.\n *\n * @example\n * ```ts\n * const user = await callAsync(fetchUser, 'user-123')\n * ```\n */\nexport async function callAsync<A extends readonly unknown[], R>(\n fn: (...args: A) => Promise<R>,\n ...args: A\n): Promise<R> {\n return fn(...args)\n}\n","/**\n * Returns a function that applies a transform only when a predicate passes,\n * otherwise returns the value unchanged.\n *\n * @example\n * ```ts\n * const trimIfString = when(isString, (s: string) => s.trim())\n * trimIfString(' hello ') // 'hello'\n * ```\n */\nexport function when<T>(predicate: (value: T) => boolean, fn: (value: T) => T): (value: T) => T {\n return (value: T) => {\n if (predicate(value)) {\n return fn(value)\n }\n return value\n }\n}\n\n/**\n * Returns a function that applies a transform only when a predicate fails,\n * otherwise returns the value unchanged.\n *\n * Complement of {@link when}.\n *\n * @example\n * ```ts\n * const ensureArray = unless(Array.isArray, (v) => [v])\n * ensureArray(42) // [42]\n * ensureArray([1]) // [1]\n * ```\n */\nexport function unless<T>(predicate: (value: T) => boolean, fn: (value: T) => T): (value: T) => T {\n return (value: T) => {\n if (predicate(value)) {\n return value\n }\n return fn(value)\n }\n}\n\n/**\n * Returns a function that branches between two functions based on a predicate.\n *\n * @example\n * ```ts\n * const format = ifElse(\n * (n: number) => n > 0,\n * (n) => `+${n}`,\n * (n) => `${n}`,\n * )\n * format(5) // '+5'\n * format(-3) // '-3'\n * ```\n */\nexport function ifElse<T, R>(\n predicate: (value: T) => boolean,\n onTrue: (value: T) => R,\n onFalse: (value: T) => R\n): (value: T) => R {\n return (value: T) => {\n if (predicate(value)) {\n return onTrue(value)\n }\n return onFalse(value)\n }\n}\n","/**\n * Returns a function that runs a side-effect and returns the value unchanged.\n *\n * Useful for debugging inside `flow` pipelines without breaking the chain.\n *\n * @example\n * ```ts\n * const process = flow(\n * fetchUsers,\n * tap(users => console.log('count:', users.length)),\n * filterActive,\n * )\n * ```\n */\nexport function tap<T>(fn: (value: T) => unknown): (value: T) => T {\n return (value: T) => {\n fn(value)\n return value\n }\n}\n","import type { DangerouslyAllowAny } from '../types/internal.js'\n\ntype MaybePromise<T> = T | Promise<T>\n\n/**\n * Creates an async pipeline that awaits each step before passing the result\n * to the next function. Like {@link flow} from es-toolkit but async-aware.\n *\n * Each function can return a value or a Promise — `flowAsync` always returns\n * a Promise that resolves to the final step's awaited result.\n *\n * @example\n * ```ts\n * const getUsername = flowAsync(\n * (id: string) => fetchUser(id), // Promise<User>\n * (user) => user.name, // string\n * (name) => name.toUpperCase(),\n * )\n * await getUsername('123') // 'ALICE'\n * ```\n */\nexport function flowAsync<A extends readonly unknown[], R1>(\n f1: (...args: A) => MaybePromise<R1>\n): (...args: A) => Promise<Awaited<R1>>\nexport function flowAsync<A extends readonly unknown[], R1, R2>(\n f1: (...args: A) => MaybePromise<R1>,\n f2: (a: Awaited<R1>) => MaybePromise<R2>\n): (...args: A) => Promise<Awaited<R2>>\nexport function flowAsync<A extends readonly unknown[], R1, R2, R3>(\n f1: (...args: A) => MaybePromise<R1>,\n f2: (a: Awaited<R1>) => MaybePromise<R2>,\n f3: (a: Awaited<R2>) => MaybePromise<R3>\n): (...args: A) => Promise<Awaited<R3>>\nexport function flowAsync<A extends readonly unknown[], R1, R2, R3, R4>(\n f1: (...args: A) => MaybePromise<R1>,\n f2: (a: Awaited<R1>) => MaybePromise<R2>,\n f3: (a: Awaited<R2>) => MaybePromise<R3>,\n f4: (a: Awaited<R3>) => MaybePromise<R4>\n): (...args: A) => Promise<Awaited<R4>>\nexport function flowAsync<A extends readonly unknown[], R1, R2, R3, R4, R5>(\n f1: (...args: A) => MaybePromise<R1>,\n f2: (a: Awaited<R1>) => MaybePromise<R2>,\n f3: (a: Awaited<R2>) => MaybePromise<R3>,\n f4: (a: Awaited<R3>) => MaybePromise<R4>,\n f5: (a: Awaited<R4>) => MaybePromise<R5>\n): (...args: A) => Promise<Awaited<R5>>\nexport function flowAsync<A extends readonly unknown[], R1, R2, R3, R4, R5, R6>(\n f1: (...args: A) => MaybePromise<R1>,\n f2: (a: Awaited<R1>) => MaybePromise<R2>,\n f3: (a: Awaited<R2>) => MaybePromise<R3>,\n f4: (a: Awaited<R3>) => MaybePromise<R4>,\n f5: (a: Awaited<R4>) => MaybePromise<R5>,\n f6: (a: Awaited<R5>) => MaybePromise<R6>\n): (...args: A) => Promise<Awaited<R6>>\nexport function flowAsync<A extends readonly unknown[], R1, R2, R3, R4, R5, R6, R7>(\n f1: (...args: A) => MaybePromise<R1>,\n f2: (a: Awaited<R1>) => MaybePromise<R2>,\n f3: (a: Awaited<R2>) => MaybePromise<R3>,\n f4: (a: Awaited<R3>) => MaybePromise<R4>,\n f5: (a: Awaited<R4>) => MaybePromise<R5>,\n f6: (a: Awaited<R5>) => MaybePromise<R6>,\n f7: (a: Awaited<R6>) => MaybePromise<R7>\n): (...args: A) => Promise<Awaited<R7>>\nexport function flowAsync(\n first: (...args: readonly DangerouslyAllowAny[]) => unknown,\n ...rest: ReadonlyArray<(arg: DangerouslyAllowAny) => unknown>\n): (...args: readonly unknown[]) => Promise<unknown> {\n return async (...args: readonly unknown[]) =>\n rest.reduce<Promise<unknown>>(async (acc, fn) => fn(await acc), Promise.resolve(first(...args)))\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,SAAgB,KAAsC,IAAuB,GAAG,MAAY;CAC1F,OAAO,GAAG,GAAG,IAAI;AACnB;;;;;;;;;;;;;AAcA,eAAsB,UACpB,IACA,GAAG,MACS;CACZ,OAAO,GAAG,GAAG,IAAI;AACnB;;;;;;;;;;;;;ACzBA,SAAgB,KAAQ,WAAkC,IAAsC;CAC9F,QAAQ,UAAa;EACnB,IAAI,UAAU,KAAK,GACjB,OAAO,GAAG,KAAK;EAEjB,OAAO;CACT;AACF;;;;;;;;;;;;;;AAeA,SAAgB,OAAU,WAAkC,IAAsC;CAChG,QAAQ,UAAa;EACnB,IAAI,UAAU,KAAK,GACjB,OAAO;EAET,OAAO,GAAG,KAAK;CACjB;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,OACd,WACA,QACA,SACiB;CACjB,QAAQ,UAAa;EACnB,IAAI,UAAU,KAAK,GACjB,OAAO,OAAO,KAAK;EAErB,OAAO,QAAQ,KAAK;CACtB;AACF;;;;;;;;;;;;;;;;;ACpDA,SAAgB,IAAO,IAA4C;CACjE,QAAQ,UAAa;EACnB,GAAG,KAAK;EACR,OAAO;CACT;AACF;;;AC4CA,SAAgB,UACd,OACA,GAAG,MACgD;CACnD,OAAO,OAAO,GAAG,SACf,KAAK,OAAyB,OAAO,KAAK,OAAO,GAAG,MAAM,GAAG,GAAG,QAAQ,QAAQ,MAAM,GAAG,IAAI,CAAC,CAAC;AACnG"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { at, chunk, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last,
|
|
2
|
-
|
|
1
|
+
import { at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith } from "es-toolkit/array";
|
|
3
2
|
//#region src/array/adjust.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Applies a function to the element at the given index, returning a new array.
|
|
@@ -130,5 +129,5 @@ declare function sortWith<T>(array: readonly T[], comparators: ReadonlyArray<(a:
|
|
|
130
129
|
*/
|
|
131
130
|
declare function unfold<T, R>(fn: (seed: T) => [R, T] | false, seed: T): R[];
|
|
132
131
|
//#endregion
|
|
133
|
-
export {
|
|
134
|
-
//# sourceMappingURL=index-
|
|
132
|
+
export { union as $, isSubset as A, pullAt as B, forEachRight as C, intersection as D, initial as E, maxBy as F, shuffle as G, remove as H, minBy as I, take as J, sortBy as K, orderBy as L, keyBy as M, last as N, intersectionBy as O, mapAsync as P, toFilled as Q, partition as R, forEachAsync as S, adjust as St, head as T, sample as U, reduceAsync as V, sampleSize as W, takeRightWhile as X, takeRight as Y, takeWhile as Z, flatMap as _, descend as _t, combinations as a, unzip as at, flatten as b, reduceWhile as bt, difference as c, without as ct, drop as d, xorWith as dt, unionBy as et, dropRight as f, zip as ft, filterAsync as g, ascend as gt, fill as h, unfold as ht, chunkBy as i, uniqWith as it, isSubsetWith as j, intersectionWith as k, differenceBy as l, xor as lt, dropWhile as m, zipWith as mt, cartesianProduct as n, uniq as nt, compact as o, unzipWith as ot, dropRightWhile as p, zipObject as pt, tail as q, chunk as r, uniqBy as rt, countBy as s, windowed as st, at as t, unionWith as tt, differenceWith as u, xorBy as ut, flatMapAsync as v, sortWith as vt, groupBy as w, flattenDeep as x, dropRepeats as xt, flatMapDeep as y, scan as yt, pull as z };
|
|
133
|
+
//# sourceMappingURL=index-BPYJOreI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BPYJOreI.d.mts","names":[],"sources":["../src/array/adjust.ts","../src/array/dropRepeats.ts","../src/array/reduceWhile.ts","../src/array/scan.ts","../src/array/sorting.ts","../src/array/unfold.ts"],"mappings":";;;;;;;;;;;;;;iBAYgB,OAAO,GAAG,gBAAgB,KAAK,eAAe,KAAK,OAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;iBCMpE,YAAY,GAAG,gBAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;iBCCrC,YAAY,GAAG,GAC7B,gBAAgB,KAChB,YAAY,aAAa,GAAG,OAAO,eACnC,KAAK,aAAa,GAAG,OAAO,GAAG,kBAAkB,GACjD,SAAS,IACR;;;;;;;;;;;;;;;iBCZa,KAAK,GAAG,GACtB,gBAAgB,KAChB,KAAK,aAAa,GAAG,OAAO,GAAG,kBAAkB,GACjD,SAAS,IACR;;;;;;;;;;;iBCRa,OAAO,GAAG,KAAK,OAAO,yBAAyB,GAAG,GAAG,GAAG;;;;;;;;;iBAsBxD,QAAQ,GAAG,KAAK,OAAO,yBAAyB,GAAG,GAAG,GAAG;;;;;;;;;;;;;;;iBA4BzD,SAAS,GACvB,gBAAgB,KAChB,aAAa,eAAe,GAAG,GAAG,GAAG,gBACpC;;;;;;;;;;;;;;;;;;;;;;iBC1Ca,OAAO,GAAG,GAAG,KAAK,MAAM,OAAO,GAAG,YAAY,MAAM,IAAI"}
|
|
@@ -125,4 +125,4 @@ declare function toArray<T>(value: Iterable<T> | T | null | undefined): T[];
|
|
|
125
125
|
declare function toBoolean(value: unknown): boolean;
|
|
126
126
|
//#endregion
|
|
127
127
|
export { toFinite as a, toString as c, toError as i, toArray as n, toInteger as o, toBoolean as r, toNumber as s, stringify as t };
|
|
128
|
-
//# sourceMappingURL=index-
|
|
128
|
+
//# sourceMappingURL=index-C7dxY5U-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C7dxY5U-.d.mts","names":[],"sources":["../src/conversion/convert.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBAwBgB,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;iBA8B1B,UAAU;;;;;;;;;;;;;;iBAiFV,SAAS;;;;;;;;;;;;;iBAgBT,SAAS;;;;;;;;;;iBAaT,UAAU;;;;;;;;;;;;iBAeV,SAAS;;;;;;;;;;;;;;;;;iBAwBT,QAAQ,GAAG,OAAO,SAAS,KAAK,uBAAuB;;;;;;;;;;;;;;iBA0BvD,UAAU"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as Ok, r as Result, t as Err } from "./types-
|
|
1
|
+
import { n as Ok, r as Result, t as Err } from "./types-BsimcHZS.mjs";
|
|
2
2
|
import { assert, invariant } from "es-toolkit/util";
|
|
3
|
-
|
|
4
3
|
//#region src/control/attempt.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Executes a synchronous function and wraps the outcome in a `Result`.
|
|
@@ -183,4 +182,4 @@ declare function unimplemented(message?: string): never;
|
|
|
183
182
|
declare function unreachable(message?: string): never;
|
|
184
183
|
//#endregion
|
|
185
184
|
export { todo as a, isOk as c, attempt as d, attemptAsync as f, unimplemented as i, ok as l, invariant as n, err as o, unreachable as r, isErr as s, assert as t, unwrap as u };
|
|
186
|
-
//# sourceMappingURL=index-
|
|
185
|
+
//# sourceMappingURL=index-D5q3I26j.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D5q3I26j.d.mts","names":[],"sources":["../src/control/attempt.ts","../src/control/result.ts","../src/control/todo.ts","../src/control/unimplemented.ts","../src/control/unreachable.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBAkBgB,QAAQ,GAAG,UAAU,IAAI,OAAO;;;;;;;;;;;;;;;;iBAuB1B,aAAa,GAAG,UAAU,QAAQ,KAAK,QAAQ,OAAO;;;;;;;;;;;;;;;iBCJ5D,GAAG,GAAG,OAAO,IAAI,GAAG;;;;;;;;;;;;;iBAgBpB,IAAI,iBAAiB;;;;;;;;;;;;;;;iBAkBrB,KAAK,GAAG,QAAQ,OAAO,KAAK,UAAU,GAAG;;;;;;;;;;;;;;;iBAkBzC,MAAM,GAAG,QAAQ,OAAO,KAAK,UAAU;;;;;;;;;;;;;;;;;;;iBAsBvC,OAAO,GAAG,QAAQ,OAAO,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;iBC5FhD,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;iBCML,cAAc;;;;;;;;;;;;;;;;;;;;;;;;iBCFd,YAAY"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError as isError$1, isFile, isFunction, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap as isMap$1, isNil as isNil$1, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive as isPrimitive$1, isPromise, isRegExp, isSet as isSet$1, isString as isString$1, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet } from "es-toolkit/predicate";
|
|
2
|
-
|
|
1
|
+
import { isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError as isError$1, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap as isMap$1, isNil as isNil$1, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive as isPrimitive$1, isPromise, isRegExp, isSet as isSet$1, isString as isString$1, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet } from "es-toolkit/predicate";
|
|
3
2
|
//#region src/types/internal.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Explicit alias for `any` that makes dangerous intent visible at the call site.
|
|
@@ -182,5 +181,5 @@ declare function isInteger(value: unknown): value is number;
|
|
|
182
181
|
*/
|
|
183
182
|
declare function isNaN(value: unknown): value is number;
|
|
184
183
|
//#endregion
|
|
185
|
-
export {
|
|
186
|
-
//# sourceMappingURL=index-
|
|
184
|
+
export { isString$1 as A, isNaN as B, isNull as C, isPromise as D, isPrimitive$1 as E, isWeakSet as F, both as G, isObject as H, isArray as I, either as K, isEmpty as L, isTypedArray as M, isUndefined as N, isRegExp as O, isWeakMap as P, isFiniteNumber as R, isNotNil as S, isPlainObject as T, allPass as U, isNotEmpty as V, anyPass as W, isJSONValue as _, isBuffer as a, isNil$1 as b, isEqual as c, isFile as d, isFunction as f, isJSONObject as g, isJSONArray as h, isBrowser as i, isSymbol as j, isSet$1 as k, isEqualWith as l, isJSON as m, isBlob as n, isDate as o, isIterable as p, isBoolean as r, isEmptyObject as s, isArrayBuffer as t, isError$1 as u, isLength as v, isNumber as w, isNode as x, isMap$1 as y, isInteger as z };
|
|
185
|
+
//# sourceMappingURL=index-D7DGVrkN.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D7DGVrkN.d.mts","names":[],"sources":["../src/types/internal.ts","../src/predicate/combinators.ts","../src/predicate/guards.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAkBY;;;;;;;;;;;;;;;;;;;;;iBCEI,QAAQ,GAAG,2BAA2B,OAAO;iBAC7C,QAAQ,WAAW,eAAe,OAAO,kCACvD,YAAY,MACV,OAAO,WAAW,QAAQ,SAAS,WAAW,MAAM,oBAAoB,QAAQ;;;;;;;;;;;;;;;;;;iBAwBpE,QAAQ,GAAG,2BAA2B,OAAO;iBAC7C,QAAQ,WAAW,eAAe,OAAO,kCACvD,YAAY,MACV,OAAO,WAAW,QAAQ,SAAS,WAAW,MAAM,QAAQ;;;;;;;;;;;;;iBAmBhD,KAAK,GAAG,UAAU,GAAG,UAAU,GAC7C,IAAI,OAAO,MAAM,SAAS,GAC1B,IAAI,OAAO,MAAM,SAAS,KACxB,OAAO,MAAM,SAAS,IAAI;iBACd,KAAK,GAAG,IAAI,OAAO,eAAe,IAAI,OAAO,iBAAiB,OAAO;;;;;;;;;;;;;iBAiBrE,OAAO,GAAG,UAAU,GAAG,UAAU,GAC/C,IAAI,OAAO,MAAM,SAAS,GAC1B,IAAI,OAAO,MAAM,SAAS,KACxB,OAAO,MAAM,SAAS,IAAI;iBACd,OAAO,GAAG,IAAI,OAAO,eAAe,IAAI,OAAO,iBAAiB,OAAO;;;;;KAYlF,QAAQ,KAAK,YAAY,OAAO,wBAAwB,eAAe,KAAK;;;;;KAM5E,WAAW,MAAM,WAAW,eAAe,aAAa,iBAAiB;KAEzE,oBAAoB,MAAM,qBAAqB,GAAG,8BACrD,SAAS,cAEP;;;;;;;;;;;;iBC5GY,QAAQ,iBAAiB;;;;;;;;;;;;;iBAgBzB,SAAS,iBAAiB;;;;;;;;;;;;;;;;;iBAoB1B,QAAQ;;;;;;;;;;iBAmBR,WAAW;;;;;;;;;;iBAaX,eAAe,iBAAiB;;;;;;;;;;iBAahC,UAAU,iBAAiB;;;;;;;;;;iBAa3B,MAAM,iBAAiB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { clone, cloneDeep, cloneDeepWith, deepFreeze, findKey, flattenObject, invert, mapKeys, mapKeysAsync, mapValues, mapValuesAsync, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toConstantCaseKeys, toKebabCaseKeys, toMerged, toPascalCaseKeys, toSnakeCaseKeys } from "es-toolkit/object";
|
|
2
|
+
import { ToCamelCaseKeys, ToConstantCaseKeys, ToKebabCaseKeys, ToPascalCaseKeys, ToSnakeCaseKeys } from "es-toolkit/types";
|
|
3
|
+
//#region src/object/evolve.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Applies a spec of transformation functions to matching keys of an object,
|
|
6
|
+
* returning a new object. Keys not in the spec are copied as-is.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* evolve({ name: ' Alice ', age: 29, role: 'admin' }, {
|
|
11
|
+
* name: (s) => s.trim(),
|
|
12
|
+
* age: (n) => n + 1,
|
|
13
|
+
* })
|
|
14
|
+
* // { name: 'Alice', age: 30, role: 'admin' }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare function evolve<T extends Record<string, unknown>>(obj: T, spec: { [K in keyof T]?: (value: T[K]) => T[K]; }): T;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { evolve as A, sortKeys as C, toMerged as D, toKebabCaseKeys as E, toPascalCaseKeys as O, pickBy as S, toConstantCaseKeys as T, merge as _, ToSnakeCaseKeys as a, omitBy as b, cloneDeepWith as c, flattenObject as d, invert as f, mapValuesAsync as g, mapValues as h, ToPascalCaseKeys as i, toSnakeCaseKeys as k, deepFreeze as l, mapKeysAsync as m, ToConstantCaseKeys as n, clone as o, mapKeys as p, ToKebabCaseKeys as r, cloneDeep as s, ToCamelCaseKeys as t, findKey as u, mergeWith as v, toCamelCaseKeys as w, pick as x, omit as y };
|
|
20
|
+
//# sourceMappingURL=index-DTrYN2UY.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DTrYN2UY.d.mts","names":[],"sources":["../src/object/evolve.ts"],"mappings":";;;;;;;;;;;;;;;;iBAagB,OAAO,UAAU,yBAC/B,KAAK,GACL,SAAS,WAAW,MAAM,OAAO,EAAE,OAAO,EAAE,QAC3C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { n as Ok$1, t as Err$1 } from "./types-BsimcHZS.mjs";
|
|
2
|
+
import { NonExhaustiveError, P, Pattern, isMatching, match as match$1 } from "ts-pattern";
|
|
3
|
+
//#region src/match/match.d.ts
|
|
4
|
+
declare function okPattern(): {
|
|
5
|
+
ok: true;
|
|
6
|
+
};
|
|
7
|
+
declare function okPattern<const pattern extends P.Pattern<unknown>>(pattern: pattern): {
|
|
8
|
+
ok: true;
|
|
9
|
+
value: pattern;
|
|
10
|
+
};
|
|
11
|
+
declare function errPattern(): {
|
|
12
|
+
ok: false;
|
|
13
|
+
};
|
|
14
|
+
declare function errPattern<const pattern extends P.Pattern<unknown>>(pattern: pattern): {
|
|
15
|
+
ok: false;
|
|
16
|
+
error: pattern;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Extended ts-pattern `P` namespace. Carries everything ts-pattern exports
|
|
20
|
+
* (`P.string`, `P.number`, `P.array`, `P.when`, …) plus `P.ok()` / `P.err()`
|
|
21
|
+
* for matching `Result` values and their contents.
|
|
22
|
+
*
|
|
23
|
+
* For the `P.Pattern<T>` type shorthand, import `Pattern` standalone from
|
|
24
|
+
* `massaman/match` — it's the form ts-pattern's own docs recommend.
|
|
25
|
+
*/
|
|
26
|
+
declare const P$1: typeof P & {
|
|
27
|
+
ok: typeof okPattern;
|
|
28
|
+
err: typeof errPattern;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The `Ok` variant of a `Result<T>`. Re-exported here so the value-side
|
|
32
|
+
* patterns and the type-side `Ok<T>` live in one module — any consumer
|
|
33
|
+
* import gets both type and value namespaces without cross-module merge
|
|
34
|
+
* issues (TS2300).
|
|
35
|
+
*/
|
|
36
|
+
type Ok<T> = Ok$1<T>;
|
|
37
|
+
/**
|
|
38
|
+
* The `Err` variant of a `Result<T>`. See {@link Ok} for the co-location note.
|
|
39
|
+
*/
|
|
40
|
+
type Err = Err$1;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Err as a, match$1 as i, Pattern as n, Ok as o, isMatching as r, P$1 as s, NonExhaustiveError as t };
|
|
43
|
+
//# sourceMappingURL=index-DcVpX2Bb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DcVpX2Bb.d.mts","names":[],"sources":["../src/match/match.ts"],"mappings":";;;iBAuBS;EAAe;;iBACf,gBAAgB,gBAAgB,EAAI,kBAC3C,SAAS;EACN;EAAU,OAAO;;iBASb;EAAgB;;iBAChB,iBAAiB,gBAAgB,EAAI,kBAC5C,SAAS;EACN;EAAW,OAAO;;;;;;;;;;cAiBV,YAAU;EAAQ,WAAW;EAAW,YAAY;;;;;;;;KAYrD,GAAG,KAAK,KAAO;;;;KAKf,MAAM"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DebounceOptions, DebouncedFunction, MemoizeCache, ThrottleOptions, ThrottledFunction, after, ary, asyncNoop, before, curry, curryRight, debounce, flow, flowRight, identity, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, throttle, unary } from "es-toolkit/function";
|
|
2
|
-
|
|
3
2
|
//#region src/function/call.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Invokes a function with the provided arguments and returns the result.
|
|
@@ -117,4 +116,4 @@ declare function flowAsync<A extends readonly unknown[], R1, R2, R3, R4, R5, R6>
|
|
|
117
116
|
declare function flowAsync<A extends readonly unknown[], R1, R2, R3, R4, R5, R6, R7>(f1: (...args: A) => MaybePromise<R1>, f2: (a: Awaited<R1>) => MaybePromise<R2>, f3: (a: Awaited<R2>) => MaybePromise<R3>, f4: (a: Awaited<R3>) => MaybePromise<R4>, f5: (a: Awaited<R4>) => MaybePromise<R5>, f6: (a: Awaited<R5>) => MaybePromise<R6>, f7: (a: Awaited<R6>) => MaybePromise<R7>): (...args: A) => Promise<Awaited<R7>>;
|
|
118
117
|
//#endregion
|
|
119
118
|
export { unless as A, retry as C, flowAsync as D, unary as E, call as M, callAsync as N, tap as O, rest as S, throttle as T, negate as _, ThrottledFunction as a, partial as b, asyncNoop as c, curryRight as d, debounce as f, memoize as g, identity as h, ThrottleOptions as i, when as j, ifElse as k, before as l, flowRight as m, DebouncedFunction as n, after as o, flow as p, MemoizeCache as r, ary as s, DebounceOptions as t, curry as u, noop as v, spread as w, partialRight as x, once as y };
|
|
120
|
-
//# sourceMappingURL=index-
|
|
119
|
+
//# sourceMappingURL=index-DlZyDxI_.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DlZyDxI_.d.mts","names":[],"sources":["../src/function/call.ts","../src/function/branching.ts","../src/function/tap.ts","../src/function/flowAsync.ts"],"mappings":";;;;;;;;;;;;;;;;iBAcgB,KAAK,8BAA8B,GAAG,QAAQ,MAAM,MAAM,MAAM,MAAM,IAAI;;;;;;;;;;;;;iBAgBpE,UAAU,8BAA8B,GAC5D,QAAQ,MAAM,MAAM,QAAQ,OACzB,MAAM,IACR,QAAQ;;;;;;;;;;;;;iBCvBK,KAAK,GAAG,YAAY,OAAO,eAAe,KAAK,OAAO,MAAM,KAAK,OAAO,MAAM;;;;;;;;;;;;;;iBAsB9E,OAAO,GAAG,YAAY,OAAO,eAAe,KAAK,OAAO,MAAM,KAAK,OAAO,MAAM;;;;;;;;;;;;;;;iBAuBhF,OAAO,GAAG,GACxB,YAAY,OAAO,eACnB,SAAS,OAAO,MAAM,GACtB,UAAU,OAAO,MAAM,KACrB,OAAO,MAAM;;;;;;;;;;;;;;;;;iBC7CD,IAAI,GAAG,KAAK,OAAO,iBAAiB,OAAO,MAAM;;;KCZ5D,aAAa,KAAK,IAAI,QAAQ;;;;;;;;;;;;;;;;;;iBAmBnB,UAAU,8BAA8B,IACtD,QAAQ,MAAM,MAAM,aAAa,UAC5B,MAAM,MAAM,QAAQ,QAAQ;iBACnB,UAAU,8BAA8B,IAAI,IAC1D,QAAQ,MAAM,MAAM,aAAa,KACjC,KAAK,GAAG,QAAQ,QAAQ,aAAa,UAChC,MAAM,MAAM,QAAQ,QAAQ;iBACnB,UAAU,8BAA8B,IAAI,IAAI,IAC9D,QAAQ,MAAM,MAAM,aAAa,KACjC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,UAChC,MAAM,MAAM,QAAQ,QAAQ;iBACnB,UAAU,8BAA8B,IAAI,IAAI,IAAI,IAClE,QAAQ,MAAM,MAAM,aAAa,KACjC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,UAChC,MAAM,MAAM,QAAQ,QAAQ;iBACnB,UAAU,8BAA8B,IAAI,IAAI,IAAI,IAAI,IACtE,QAAQ,MAAM,MAAM,aAAa,KACjC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,UAChC,MAAM,MAAM,QAAQ,QAAQ;iBACnB,UAAU,8BAA8B,IAAI,IAAI,IAAI,IAAI,IAAI,IAC1E,QAAQ,MAAM,MAAM,aAAa,KACjC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,UAChC,MAAM,MAAM,QAAQ,QAAQ;iBACnB,UAAU,8BAA8B,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAC9E,QAAQ,MAAM,MAAM,aAAa,KACjC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,KACrC,KAAK,GAAG,QAAQ,QAAQ,aAAa,UAChC,MAAM,MAAM,QAAQ,QAAQ"}
|