massaman 0.0.1-rc.2 → 0.2.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.
Files changed (42) hide show
  1. package/README.md +82 -99
  2. package/dist/array/index.d.mts +1 -1
  3. package/dist/array-C8MqjyiP.mjs.map +1 -1
  4. package/dist/control/index.d.mts +2 -1
  5. package/dist/conversion/index.d.mts +1 -1
  6. package/dist/conversion-ByBXBR5i.mjs.map +1 -1
  7. package/dist/function/index.d.mts +1 -1
  8. package/dist/{index-Br9PO6mU.d.mts → index-BHb3Vge_.d.mts} +3 -42
  9. package/dist/index-BHb3Vge_.d.mts.map +1 -0
  10. package/dist/{index-COFf0Pih.d.mts → index-BjmDP8W9.d.mts} +1 -1
  11. package/dist/{index-COFf0Pih.d.mts.map → index-BjmDP8W9.d.mts.map} +1 -1
  12. package/dist/{index-DqsBQ7Pp.d.mts → index-D5l6I7QH.d.mts} +1 -1
  13. package/dist/{index-DqsBQ7Pp.d.mts.map → index-D5l6I7QH.d.mts.map} +1 -1
  14. package/dist/index-DtnKhaAD.d.mts +39 -0
  15. package/dist/index-DtnKhaAD.d.mts.map +1 -0
  16. package/dist/{index-BuBpCB73.d.mts → index-g2aw5tc_.d.mts} +16 -27
  17. package/dist/index-g2aw5tc_.d.mts.map +1 -0
  18. package/dist/{index-BkyNt8th.d.mts → index-keGHab-v.d.mts} +1 -1
  19. package/dist/index-keGHab-v.d.mts.map +1 -0
  20. package/dist/{index-Dw_tuZdb.d.mts → index-mfIoxwxy.d.mts} +1 -1
  21. package/dist/{index-Dw_tuZdb.d.mts.map → index-mfIoxwxy.d.mts.map} +1 -1
  22. package/dist/index.d.mts +8 -7
  23. package/dist/index.mjs +2 -2
  24. package/dist/match/index.d.mts +2 -0
  25. package/dist/match/index.mjs +2 -0
  26. package/dist/match-CG_v2C4Q.mjs +44 -0
  27. package/dist/match-CG_v2C4Q.mjs.map +1 -0
  28. package/dist/object/index.d.mts +1 -1
  29. package/dist/object-BHnp9Sr9.mjs.map +1 -1
  30. package/dist/predicate/index.d.mts +1 -1
  31. package/dist/predicate/index.mjs +1 -1
  32. package/dist/{predicate-CYzSOMLW.mjs → predicate-DtTBffBT.mjs} +13 -5
  33. package/dist/predicate-DtTBffBT.mjs.map +1 -0
  34. package/dist/types-X6LqLWno.d.mts +42 -0
  35. package/dist/types-X6LqLWno.d.mts.map +1 -0
  36. package/package.json +6 -5
  37. package/dist/index-BkyNt8th.d.mts.map +0 -1
  38. package/dist/index-Br9PO6mU.d.mts.map +0 -1
  39. package/dist/index-BuBpCB73.d.mts.map +0 -1
  40. package/dist/pattern/index.d.mts +0 -2
  41. package/dist/pattern/index.mjs +0 -2
  42. package/dist/predicate-CYzSOMLW.mjs.map +0 -1
package/README.md CHANGED
@@ -1,138 +1,121 @@
1
- # massaman
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/zrosenbauer/massaman/main/.github/assets/banner.png" alt="massaman" width="100%" />
3
+ <p><strong>Functional programming utilities for TypeScript. Result types, pattern matching, async pipelines. Fully typed.</strong></p>
2
4
 
3
- [![npm](https://img.shields.io/npm/v/massaman/rc?label=npm%40rc&color=B45309)](https://www.npmjs.com/package/massaman)
4
- [![types](https://img.shields.io/npm/types/massaman?color=3178c6)](https://www.typescriptlang.org/)
5
- [![license](https://img.shields.io/npm/l/massaman?color=475569)](./LICENSE)
6
- [![status](https://img.shields.io/badge/status-release%20candidate-B45309)](#status)
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>
6
+ <a href="https://www.npmjs.com/package/massaman"><img src="https://img.shields.io/npm/v/massaman" alt="npm version" /></a>
7
+ <a href="https://github.com/zrosenbauer/massaman/blob/main/LICENSE"><img src="https://img.shields.io/github/license/zrosenbauer/massaman" alt="License" /></a>
7
8
 
8
- Functional programming utilities for TypeScript — a curated unified surface over [es-toolkit](https://es-toolkit.slash.page) and [ts-pattern](https://github.com/gvergnaud/ts-pattern), with Result-style error handling, variadic-narrowing predicates, async-aware composition, and pattern matching.
9
+ </div>
9
10
 
10
- ## Status
11
+ ## Features
11
12
 
12
- Release candidate. The public API is frozen no breaking changes will land before `1.0.0`. Feedback welcome via [issues](https://github.com/zrosenbauer/massaman/issues).
13
+ - Rust's `match` in TypeScript: exhaustive pattern matching via re-exported [ts-pattern](https://github.com/gvergnaud/ts-pattern).
14
+ - Rust's `Result` in TypeScript: compose fallible operations without throws (`attempt`, `attemptAsync`, `ok`, `err`, `isOk`, `unwrap`).
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 on top of the array/object/string/math utilities you already love.
17
+ - Tree-shakeable: 12 focused subpath exports, ESM-only, `sideEffects: false`. Import only what you use.
13
18
 
14
19
  ## Install
15
20
 
16
21
  ```bash
17
- npm install massaman@rc
18
- # or
19
- pnpm add massaman@rc
20
- # or
21
- yarn add massaman@rc
22
+ npm install massaman
22
23
  ```
23
24
 
24
- ## Quick start
25
+ ## Usage
25
26
 
26
- ```ts
27
- import { flow, attempt, isOk } from 'massaman'
27
+ ### From ts-pattern
28
28
 
29
- const parseUser = flow(JSON.parse, (u) => u.name.trim())
29
+ The `pattern` subpath is a transparent re-export of [ts-pattern](https://github.com/gvergnaud/ts-pattern). Exhaustive matching with full TypeScript inference.
30
30
 
31
- const result = attempt(() => parseUser(rawInput))
32
- if (isOk(result)) {
33
- return result.value
34
- }
35
- return 'unknown'
36
- ```
31
+ ```ts
32
+ import { match, P } from 'massaman/match'
37
33
 
38
- ## Features
34
+ const status = match(action)
35
+ .with({ type: 'load' }, () => 'loading')
36
+ .with({ type: 'success' }, () => 'done')
37
+ .with({ type: 'error', msg: P.string }, ({ msg }) => `failed: ${msg}`)
38
+ .exhaustive()
39
+ ```
39
40
 
40
- | Feature | Description |
41
- | ---------------------------------- | -------------------------------------------------------------------------------------------------------- |
42
- | **Unified FP surface** | Array, object, string, function, math, predicate, promise — one curated import root, tree-shakeable. |
43
- | **Result-style error handling** | `attempt` / `attemptAsync` / `ok` / `err` / `isOk` / `isErr` / `unwrap` — no thrown exceptions. |
44
- | **Pattern matching** | Full [ts-pattern](https://github.com/gvergnaud/ts-pattern) re-export under `massaman/pattern`. |
45
- | **Variadic type-guard narrowing** | `allPass([isString, isNotEmpty])` returns a guard that narrows to `string` — composes any arity. |
46
- | **Async-aware pipelines** | `flowAsync` chains promise-returning functions with end-to-end type inference (up to 7 steps). |
47
- | **Safe error normalization** | `toError` + `stringify` handle non-`Error` throws, circular refs, Maps/Sets — no more `[object Object]`. |
48
- | **Branching combinators** | `when` / `unless` / `ifElse` for point-free conditionals inside `flow` pipelines. |
49
- | **100% test coverage** | Enforced by CI — every line, branch, and function is verified. |
50
- | **ESM-only, `sideEffects: false`** | 12 subpath exports, tree-shakeable, zero side effects. |
41
+ ### From es-toolkit
51
42
 
52
- ## Usage
43
+ Most of the surface (`array`, `object`, `string`, `function`, `math`) is a transparent re-export of [es-toolkit](https://es-toolkit.dev). Same names, same behavior, same docs.
53
44
 
54
45
  ```ts
55
- import { flow, compact, uniq, toArray } from 'massaman'
46
+ import { chunk, groupBy } from 'massaman'
56
47
 
57
- const normalize = flow(toArray, compact, uniq)
58
- normalize([1, null, 2, 1, null]) // [1, 2]
48
+ chunk([1, 2, 3, 4, 5], 2)
49
+ // [[1, 2], [3, 4], [5]]
50
+
51
+ groupBy(['apple', 'avocado', 'banana', 'blueberry'], (s) => s[0])
52
+ // { a: ['apple', 'avocado'], b: ['banana', 'blueberry'] }
59
53
  ```
60
54
 
61
- ```ts
62
- import { match, P } from 'massaman/pattern'
55
+ ### Custom: Result and async composition
63
56
 
64
- const label = match(status)
65
- .with('active', () => 'Live')
66
- .with('draft', () => 'Draft')
67
- .with(P._, () => 'N/A')
68
- .exhaustive()
69
- ```
57
+ Built on top of those re-exports, `massaman/control` adds Result-style error handling that never throws across a boundary.
70
58
 
71
59
  ```ts
72
- import { attempt, isOk } from 'massaman/control'
60
+ import { attemptAsync, isOk } from 'massaman/control'
61
+
62
+ const result = await attemptAsync(() => fetch('/api/user').then((r) => r.json()))
73
63
 
74
- const result = attempt(() => JSON.parse(raw))
75
64
  if (isOk(result)) {
76
65
  console.log(result.value)
77
66
  } else {
78
- console.error(result.error)
67
+ console.error(result.error.message)
79
68
  }
80
69
  ```
81
70
 
71
+ ## Why?
72
+
73
+ Two Rust patterns I keep wanting in TypeScript: `match` for exhaustive branching, and `Result` for errors that compose without throws.
74
+
75
+ In Rust:
76
+
77
+ ```rust
78
+ match action {
79
+ Action::Load => "loading",
80
+ Action::Success => "done",
81
+ Action::Error(msg) => &format!("failed: {}", msg),
82
+ }
83
+
84
+ let parsed: Result<User, Error> = serde_json::from_str(raw);
85
+ match parsed {
86
+ Ok(user) => println!("got: {}", user.name),
87
+ Err(err) => eprintln!("failed: {}", err),
88
+ }
89
+ ```
90
+
91
+ The equivalent in TypeScript using `massaman`:
92
+
82
93
  ```ts
83
- import { allPass } from 'massaman/predicate'
84
- import { isString } from 'es-toolkit/predicate'
85
- import { isNotEmpty } from 'massaman/predicate'
94
+ import { match, P } from 'massaman/match'
95
+ import { attempt, isOk } from 'massaman/control'
96
+
97
+ match(action)
98
+ .with({ type: 'load' }, () => 'loading')
99
+ .with({ type: 'success' }, () => 'done')
100
+ .with({ type: 'error', msg: P.string }, ({ msg }) => `failed: ${msg}`)
101
+ .exhaustive()
86
102
 
87
- const isNonEmptyString = allPass([isString, isNotEmpty])
88
- if (isNonEmptyString(x)) {
89
- // x is narrowed to string
103
+ const parsed = attempt(() => JSON.parse(raw) as User)
104
+ if (isOk(parsed)) {
105
+ console.log(`got: ${parsed.value.name}`)
106
+ } else {
107
+ console.error(`failed: ${parsed.error.message}`)
90
108
  }
91
109
  ```
92
110
 
93
- ## Modules
94
-
95
- | Subpath | Description |
96
- | --------------------- | -------------------------------------------------------------------------- |
97
- | `massaman` | Root barrel — re-exports everything below |
98
- | `massaman/array` | Array utilities (chunk, groupBy, sortWith, scan, unfold, …) |
99
- | `massaman/object` | Object utilities (evolve, pick, omit, merge, mapKeys, …) |
100
- | `massaman/function` | Composition (flow, flowAsync, tap, call, curry, when, unless, ifElse, …) |
101
- | `massaman/predicate` | Type guards, combinators with variadic narrowing |
102
- | `massaman/conversion` | Coercion + safe stringification (toError, stringify, toNumber, toArray, …) |
103
- | `massaman/string` | String transforms (camelCase, kebabCase, trim, …) |
104
- | `massaman/math` | Numeric utilities (clamp, sum, mean, range, …) |
105
- | `massaman/promise` | Async helpers (delay, timeout, Mutex, Semaphore) |
106
- | `massaman/control` | Result-style error handling (attempt, ok, err, isOk, isErr, unwrap, …) |
107
- | `massaman/pattern` | Pattern matching (match, P, isMatching) |
108
- | `massaman/error` | Error types (AbortError, TimeoutError) |
109
-
110
- ## Custom utilities
111
-
112
- Utilities not in es-toolkit or ts-pattern — implemented in this package:
113
-
114
- | Module | Utility | Description |
115
- | ------------ | ------------------------------------------------ | -------------------------------------------------------------- |
116
- | `array` | `adjust`, `scan`, `unfold`, `dropRepeats` | Index update, accumulator scan, seed unfold, consecutive dedup |
117
- | `array` | `reduceWhile`, `ascend`, `descend`, `sortWith` | Short-circuit reduce, comparator factories, multi-key sort |
118
- | `function` | `flowAsync`, `tap` | Async composition, side-effect-in-pipeline |
119
- | `function` | `when`, `unless`, `ifElse`, `call`, `callAsync` | Point-free conditionals, named application |
120
- | `object` | `evolve` | Apply transforms per key |
121
- | `predicate` | `allPass`, `anyPass`, `both`, `either` | Variadic-narrowing predicate combinators |
122
- | `predicate` | `isArray`, `isObject`, `isEmpty`, `isNotEmpty` | Type guards + emptiness |
123
- | `predicate` | `isFiniteNumber`, `isInteger`, `isNaN` | Strict numeric guards (shadowing the broken global `isNaN`) |
124
- | `control` | `attempt`, `attemptAsync` | Wrap throwing/rejecting code into a `Result` |
125
- | `control` | `ok`, `err`, `isOk`, `isErr`, `unwrap` | Construct, narrow, and unwrap a `Result` |
126
- | `conversion` | `toError`, `stringify` | Normalize unknown thrown values + safe JSON of any value |
127
- | `conversion` | `toNumber`, `toString`, `toBoolean`, `toInteger` | Stable coercion primitives |
128
- | `conversion` | `toFinite`, `toArray` | Safe coercion with fallback semantics |
129
-
130
- ## Requirements
131
-
132
- - Node.js >= 24.0.0
133
- - ESM only (`require()` / CommonJS is not supported)
134
- - TypeScript >= 5.9 recommended (variadic narrowing benefits from recent inference)
111
+ `massaman` brings both patterns to TypeScript, layered over [es-toolkit](https://es-toolkit.dev) and [ts-pattern](https://github.com/gvergnaud/ts-pattern), plus a thin set of utilities filling the gaps: async-aware composition, variadic-narrowing predicates, and consistent error normalization.
112
+
113
+ More on the philosophy at [zrosenbauer.com/gui/blog](https://zrosenbauer.com/gui/blog).
114
+
115
+ ## Contributing
116
+
117
+ See [CONTRIBUTING.md](https://github.com/zrosenbauer/massaman/blob/main/CONTRIBUTING.md) for development setup, conventions, and PR process.
135
118
 
136
119
  ## License
137
120
 
138
- MIT © Zac Rosenbauer
121
+ [MIT](LICENSE)
@@ -1,2 +1,2 @@
1
- import { $ as unionWith, A as last, B as remove, C as initial, D as isSubset, E as intersectionWith, F as orderBy, G as tail, H as sampleSize, I as partition, J as takeRightWhile, K as take, L as pull, M as mapAsync, N as maxBy, O as isSubsetWith, P as minBy, Q as unionBy, R as pullAt, S as head, T as intersectionBy, U as shuffle, V as sample, W as sortBy, X as toFilled, Y as takeWhile, Z as union, _ as flatten, _t as scan, a as difference, at as windowed, b as forEachRight, bt as adjust, c as drop, ct as xorBy, d as dropWhile, dt as zipObject, et as uniq, f as fill, ft as zipWith, g as flatMapDeep, gt as sortWith, h as flatMapAsync, ht as descend, i as countBy, it as unzipWith, j as limitAsync, k as keyBy, l as dropRight, lt as xorWith, m as flatMap, mt as ascend, n as chunk, nt as uniqWith, o as differenceBy, ot as without, p as filterAsync, pt as unfold, q as takeRight, r as compact, rt as unzip, s as differenceWith, st as xor, t as at, tt as uniqBy, u as dropRightWhile, ut as zip, v as flattenDeep, vt as reduceWhile, w as intersection, x as groupBy, y as forEachAsync, yt as dropRepeats, z as reduceAsync } from "../index-Dw_tuZdb.mjs";
1
+ import { $ as unionWith, A as last, B as remove, C as initial, D as isSubset, E as intersectionWith, F as orderBy, G as tail, H as sampleSize, I as partition, J as takeRightWhile, K as take, L as pull, M as mapAsync, N as maxBy, O as isSubsetWith, P as minBy, Q as unionBy, R as pullAt, S as head, T as intersectionBy, U as shuffle, V as sample, W as sortBy, X as toFilled, Y as takeWhile, Z as union, _ as flatten, _t as scan, a as difference, at as windowed, b as forEachRight, bt as adjust, c as drop, ct as xorBy, d as dropWhile, dt as zipObject, et as uniq, f as fill, ft as zipWith, g as flatMapDeep, gt as sortWith, h as flatMapAsync, ht as descend, i as countBy, it as unzipWith, j as limitAsync, k as keyBy, l as dropRight, lt as xorWith, m as flatMap, mt as ascend, n as chunk, nt as uniqWith, o as differenceBy, ot as without, p as filterAsync, pt as unfold, q as takeRight, r as compact, rt as unzip, s as differenceWith, st as xor, t as at, tt as uniqBy, u as dropRightWhile, ut as zip, v as flattenDeep, vt as reduceWhile, w as intersection, x as groupBy, y as forEachAsync, yt as dropRepeats, z as reduceAsync } from "../index-mfIoxwxy.mjs";
2
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, limitAsync, 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 +1 @@
1
- {"version":3,"file":"array-C8MqjyiP.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","/* oxlint-disable functional/no-let -- iterative impl avoids stack overflow on large arrays */\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 let acc = initial\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","/* oxlint-disable functional/no-let -- iterative impl avoids stack overflow on large outputs */\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 let current = seed\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,MAAM;CACzB,IAAI,SAAS,KAAK,QAAQ,MAAM,QAE9B,OAAO,SAAS,GAAG,OAAO,OAAO;CAEnC,OAAO;;;;;;;;;;;;;;;;;;;;;;ACAT,SAAgB,YAAe,OAA0B;CACvD,OAAO,MAAM,QAAa,KAAK,MAAM,UAAU;EAC7C,IAAI,UAAU,KAAK,SAAS,MAAM,QAAQ,IACxC,IAAI,KAAK,KAAK;EAEhB,OAAO;IACN,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACHR,SAAgB,YACd,OACA,WACA,IACA,SACG;CACH,IAAI,MAAM;CACV,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;EAEpD,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,UAAU,KAAK,MAAM,EACxB,OAAO;EAET,MAAM,GAAG,KAAK,OAAO,MAAM;;CAE7B,OAAO;;;;;;;;;;;;;;;;ACxBT,SAAgB,KACd,OACA,IACA,SACK;CACL,OAAO,MAAM,QACV,QAAQ,MAAM,UAAU;EACvB,MAAM,OAAO,OAAO,OAAO,SAAS;EACpC,OAAO,KAAK,GAAG,MAAM,MAAM,MAAM,CAAC;EAClC,OAAO;IAET,CAAC,QAAQ,CACV;;;;;;;;;;;;AChBH,SAAgB,OAAU,IAA2D;CACnF,QAAQ,GAAM,MAAS;EACrB,MAAM,KAAK,GAAG,EAAE;EAChB,MAAM,KAAK,GAAG,EAAE;EAChB,IAAI,KAAK,IACP,OAAO;EAET,IAAI,KAAK,IACP,OAAO;EAET,OAAO;;;;;;;;;;;AAYX,SAAgB,QAAW,IAA2D;CACpF,QAAQ,GAAM,MAAS;EACrB,MAAM,KAAK,GAAG,EAAE;EAChB,MAAM,KAAK,GAAG,EAAE;EAChB,IAAI,KAAK,IACP,OAAO;EAET,IAAI,KAAK,IACP,OAAO;EAET,OAAO;;;;;;;;;;;;;;;;;AAkBX,SAAgB,SACd,OACA,aACK;CACL,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,MAAM;EACnC,KAAK,MAAM,OAAO,aAAa;GAC7B,MAAM,SAAS,IAAI,GAAG,EAAE;GACxB,IAAI,WAAW,GACb,OAAO;;EAGX,OAAO;GACP;;;;;;;;;;;;;;;;;;;;;;;ACjDJ,SAAgB,OAAa,IAAiC,MAAc;CAC1E,MAAM,SAAc,EAAE;CACtB,IAAI,UAAU;CACd,IAAI,OAAO,GAAG,QAAQ;CACtB,OAAO,SAAS,OAAO;EACrB,OAAO,KAAK,KAAK,GAAG;EACpB,UAAU,KAAK;EACf,OAAO,GAAG,QAAQ;;CAEpB,OAAO"}
1
+ {"version":3,"file":"array-C8MqjyiP.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,MAAM;CACzB,IAAI,SAAS,KAAK,QAAQ,MAAM,QAE9B,OAAO,SAAS,GAAG,OAAO,OAAO;CAEnC,OAAO;;;;;;;;;;;;;;;;;;;;;;ACAT,SAAgB,YAAe,OAA0B;CACvD,OAAO,MAAM,QAAa,KAAK,MAAM,UAAU;EAC7C,IAAI,UAAU,KAAK,SAAS,MAAM,QAAQ,IACxC,IAAI,KAAK,KAAK;EAEhB,OAAO;IACN,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACLR,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,MAAM,EACxB,OAAO;EAET,MAAM,GAAG,KAAK,OAAO,MAAM;;CAE7B,OAAO;;;;;;;;;;;;;;;;ACxBT,SAAgB,KACd,OACA,IACA,SACK;CACL,OAAO,MAAM,QACV,QAAQ,MAAM,UAAU;EACvB,MAAM,OAAO,OAAO,OAAO,SAAS;EACpC,OAAO,KAAK,GAAG,MAAM,MAAM,MAAM,CAAC;EAClC,OAAO;IAET,CAAC,QAAQ,CACV;;;;;;;;;;;;AChBH,SAAgB,OAAU,IAA2D;CACnF,QAAQ,GAAM,MAAS;EACrB,MAAM,KAAK,GAAG,EAAE;EAChB,MAAM,KAAK,GAAG,EAAE;EAChB,IAAI,KAAK,IACP,OAAO;EAET,IAAI,KAAK,IACP,OAAO;EAET,OAAO;;;;;;;;;;;AAYX,SAAgB,QAAW,IAA2D;CACpF,QAAQ,GAAM,MAAS;EACrB,MAAM,KAAK,GAAG,EAAE;EAChB,MAAM,KAAK,GAAG,EAAE;EAChB,IAAI,KAAK,IACP,OAAO;EAET,IAAI,KAAK,IACP,OAAO;EAET,OAAO;;;;;;;;;;;;;;;;;AAkBX,SAAgB,SACd,OACA,aACK;CACL,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,MAAM;EACnC,KAAK,MAAM,OAAO,aAAa;GAC7B,MAAM,SAAS,IAAI,GAAG,EAAE;GACxB,IAAI,WAAW,GACb,OAAO;;EAGX,OAAO;GACP;;;;;;;;;;;;;;;;;;;;;;;ACnDJ,SAAgB,OAAa,IAAiC,MAAc;CAC1E,MAAM,SAAc,EAAE;CAEtB,IAAI,UAAU;CAEd,IAAI,OAAO,GAAG,QAAQ;CACtB,OAAO,SAAS,OAAO;EACrB,OAAO,KAAK,KAAK,GAAG;EACpB,UAAU,KAAK;EACf,OAAO,GAAG,QAAQ;;CAEpB,OAAO"}
@@ -1,2 +1,3 @@
1
- import { a as isOk, c as attempt, d as Ok, f as Result, i as isErr, l as attemptAsync, n as invariant, o as ok, r as err, s as unwrap, t as assert, u as Err } from "../index-Br9PO6mU.mjs";
1
+ import { n as Ok, r as Result, t as Err } from "../types-X6LqLWno.mjs";
2
+ import { a as isOk, c as attempt, i as isErr, l as attemptAsync, n as invariant, o as ok, r as err, s as unwrap, t as assert } from "../index-BHb3Vge_.mjs";
2
3
  export { Err, Ok, Result, assert, attempt, attemptAsync, err, invariant, isErr, isOk, ok, unwrap };
@@ -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-COFf0Pih.mjs";
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-BjmDP8W9.mjs";
2
2
  export { stringify, toArray, toBoolean, toError, toFinite, toInteger, toNumber, toString };
@@ -1 +1 @@
1
- {"version":3,"file":"conversion-ByBXBR5i.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// private helpers\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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AG,KAAK,CAAC;CAGlD,MAAM,SAAkC,EAAE;CAC1C,KAAK,MAAM,OAAO,OAAO,KAAK,MAAiC,EAE7D,OAAO,OAAO,eAAgB,MAAkC,MAAM,KAAK;CAE7E,OAAO;;;;;;;;;;;;;;;AAgBT,SAAgB,SAAS,OAAwB;CAC/C,OAAO,OAAO,MAAM;;;;;;;;;;;;;;AAetB,SAAgB,SAAS,OAAwB;CAC/C,OAAO,OAAO,MAAM;;;;;;;;;;;AAYtB,SAAgB,UAAU,OAAwB;CAChD,OAAO,KAAK,MAAM,SAAS,MAAM,CAAC;;;;;;;;;;;;;AAcpC,SAAgB,SAAS,OAAwB;CAC/C,MAAM,IAAI,OAAO,MAAM;CACvB,IAAI,OAAO,SAAS,EAAE,EACpB,OAAO;CAET,OAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,QAAW,OAAgD;CACzE,IAAI,SAAS,MACX,OAAO,EAAE;CAEX,IAAI,MAAM,QAAQ,MAAM,EACtB,OAAO;CAET,IAAI,OAAQ,MAA6C,OAAO,cAAc,YAC5E,OAAO,MAAM,KAAK,MAAqB;CAEzC,OAAO,CAAC,MAAW;;;;;;;;;;;;;;;AAgBrB,SAAgB,UAAU,OAAyB;CACjD,OAAO,QAAQ,MAAM"}
1
+ {"version":3,"file":"conversion-ByBXBR5i.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,OAAO,EACjB,OAAO;CAET,IAAI,SAAS,OAAO,EAClB,OAAO,IAAI,MAAM,OAAO;CAE1B,OAAO,IAAI,MAAM,UAAU,OAAO,EAAE,EAAE,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,SAAgB,UAAU,OAAwB;CAChD,IAAI,MAAM,MAAM,IAAI,YAAY,MAAM,EACpC,OAAO,OAAO,MAAM;CAEtB,IAAI;EACF,OAAO,KAAK,UAAU,eAAe,MAAM,CAAC;SACtC;EACN,OAAO,OAAO,MAAM;;;;;;;;;;;;;AAcxB,SAAS,eAAe,OAAgB,uBAAwB,IAAI,SAAS,EAAW;CACtF,IAAI,MAAM,MAAM,IAAI,YAAY,MAAM,EACpC,OAAO;CAGT,MAAM,MAAM;CACZ,IAAI,KAAK,IAAI,IAAI,EACf,OAAO;CAET,KAAK,IAAI,IAAI;CAEb,IAAI,QAAQ,MAAM,EAAE;EAClB,MAAM,WAAoC;GACxC,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,OAAO,MAAM;GACd;EACD,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,EAElC,SAAS,OAAO,eAAgB,MAA6C,MAAM,KAAK;EAE1F,OAAO;;CAGT,IAAI,MAAM,MAAM,EACd,OAAO,MAAM,KAAK,MAAM,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CACjD,eAAe,GAAG,KAAK,EACvB,eAAe,GAAG,KAAK,CACxB,CAAC;CAGJ,IAAI,MAAM,MAAM,EACd,OAAO,MAAM,KAAK,MAAM,CAAC,KAAK,MAAM,eAAe,GAAG,KAAK,CAAC;CAG9D,IAAI,MAAM,QAAQ,MAAM,EACtB,OAAO,MAAM,KAAK,MAAM,eAAe,GAAG,KAAK,CAAC;CAGlD,MAAM,SAAkC,EAAE;CAC1C,KAAK,MAAM,OAAO,OAAO,KAAK,MAAiC,EAE7D,OAAO,OAAO,eAAgB,MAAkC,MAAM,KAAK;CAE7E,OAAO;;;;;;;;;;;;;;;AAgBT,SAAgB,SAAS,OAAwB;CAC/C,OAAO,OAAO,MAAM;;;;;;;;;;;;;;AAetB,SAAgB,SAAS,OAAwB;CAC/C,OAAO,OAAO,MAAM;;;;;;;;;;;AAYtB,SAAgB,UAAU,OAAwB;CAChD,OAAO,KAAK,MAAM,SAAS,MAAM,CAAC;;;;;;;;;;;;;AAcpC,SAAgB,SAAS,OAAwB;CAC/C,MAAM,IAAI,OAAO,MAAM;CACvB,IAAI,OAAO,SAAS,EAAE,EACpB,OAAO;CAET,OAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,QAAW,OAAgD;CACzE,IAAI,SAAS,MACX,OAAO,EAAE;CAEX,IAAI,MAAM,QAAQ,MAAM,EACtB,OAAO;CAET,IAAI,OAAQ,MAA6C,OAAO,cAAc,YAC5E,OAAO,MAAM,KAAK,MAAqB;CAEzC,OAAO,CAAC,MAAW;;;;;;;;;;;;;;;AAgBrB,SAAgB,UAAU,OAAyB;CACjD,OAAO,QAAQ,MAAM"}
@@ -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-DqsBQ7Pp.mjs";
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-D5l6I7QH.mjs";
2
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,45 +1,6 @@
1
+ import { n as Ok, r as Result, t as Err } from "./types-X6LqLWno.mjs";
1
2
  import { assert, invariant } from "es-toolkit/util";
2
3
 
3
- //#region src/control/types.d.ts
4
- /**
5
- * Success result containing a value.
6
- *
7
- * @example
8
- * ```ts
9
- * const result: Ok<number> = { ok: true, value: 42 }
10
- * ```
11
- */
12
- interface Ok<T> {
13
- readonly ok: true;
14
- readonly value: T;
15
- readonly error: null;
16
- }
17
- /**
18
- * Failure result containing an error.
19
- *
20
- * @example
21
- * ```ts
22
- * const result: Err = { ok: false, error: new Error('fail') }
23
- * ```
24
- */
25
- interface Err {
26
- readonly ok: false;
27
- readonly value: null;
28
- readonly error: Error;
29
- }
30
- /**
31
- * Discriminated union representing either success (`Ok`) or failure (`Err`).
32
- * Inspired by Rust's `Result<T, E>`, but errors are always `Error`.
33
- *
34
- * @example
35
- * ```ts
36
- * function divide(a: number, b: number): Result<number> {
37
- * return b === 0 ? err('division by zero') : ok(a / b)
38
- * }
39
- * ```
40
- */
41
- type Result<T> = Ok<T> | Err;
42
- //#endregion
43
4
  //#region src/control/attempt.d.ts
44
5
  /**
45
6
  * Executes a synchronous function and wraps the outcome in a `Result`.
@@ -151,5 +112,5 @@ declare function isErr<T>(result: Result<T>): result is Err;
151
112
  */
152
113
  declare function unwrap<T>(result: Result<T>, message?: string): T;
153
114
  //#endregion
154
- export { isOk as a, attempt as c, Ok as d, Result as f, isErr as i, attemptAsync as l, invariant as n, ok as o, err as r, unwrap as s, assert as t, Err as u };
155
- //# sourceMappingURL=index-Br9PO6mU.d.mts.map
115
+ export { isOk as a, attempt as c, isErr as i, attemptAsync as l, invariant as n, ok as o, err as r, unwrap as s, assert as t };
116
+ //# sourceMappingURL=index-BHb3Vge_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BHb3Vge_.d.mts","names":[],"sources":["../src/control/attempt.ts","../src/control/result.ts"],"mappings":";;;;;;;AAkBA;;;;;;;;;;;;iBAAgB,OAAA,GAAA,CAAW,EAAA,QAAU,CAAA,GAAI,MAAA,CAAO,CAAA;;;AAuBhD;;;;;;;;;;;;;iBAAsB,YAAA,GAAA,CAAgB,EAAA,QAAU,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,MAAA,CAAO,CAAA;;;;;;AAvB5E;;;;;;;;;iBCmBgB,EAAA,GAAA,CAAM,KAAA,EAAO,CAAA,GAAI,EAAA,CAAG,CAAA;;;;;;ADIpC;;;;;;;iBCYgB,GAAA,CAAI,KAAA,YAAiB,GAAA;;;;;;;;;;;;;;;iBAkBrB,IAAA,GAAA,CAAQ,MAAA,EAAQ,MAAA,CAAO,CAAA,IAAK,MAAA,IAAU,EAAA,CAAG,CAAA;;;;;;;;;;;;;;;iBAkBzC,KAAA,GAAA,CAAS,MAAA,EAAQ,MAAA,CAAO,CAAA,IAAK,MAAA,IAAU,GAAA;;;;;AAlBvD;;;;;;;;;;;;;;iBAwCgB,MAAA,GAAA,CAAU,MAAA,EAAQ,MAAA,CAAO,CAAA,GAAI,OAAA,YAAmB,CAAA"}
@@ -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-COFf0Pih.d.mts.map
128
+ //# sourceMappingURL=index-BjmDP8W9.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-COFf0Pih.d.mts","names":[],"sources":["../src/conversion/convert.ts"],"mappings":";;AAwBA;;;;;AA8BA;;;;;AAqFA;;;;;AAgBA;;;;;AAaA;iBAhJgB,OAAA,CAAQ,MAAA,YAAkB,KAAA;;;;AA+J1C;;;;;AAwBA;;;;;;;;;;;;iBAzJgB,SAAA,CAAU,KAAA;;;;;AAmL1B;;;;;;;;;iBA9FgB,QAAA,CAAS,KAAA;;;;;;;;;;;;;iBAgBT,QAAA,CAAS,KAAA;;;;;;;;;;iBAaT,SAAA,CAAU,KAAA;;;;;;;;;;;;iBAeV,QAAA,CAAS,KAAA;;;;;;;;;;;;;;;;;iBAwBT,OAAA,GAAA,CAAW,KAAA,EAAO,QAAA,CAAS,CAAA,IAAK,CAAA,sBAAuB,CAAA;;;;;;;;;;;;;;iBA0BvD,SAAA,CAAU,KAAA"}
1
+ {"version":3,"file":"index-BjmDP8W9.d.mts","names":[],"sources":["../src/conversion/convert.ts"],"mappings":";;AAwBA;;;;;AA8BA;;;;;AAiFA;;;;;AAgBA;;;;;AAaA;iBA5IgB,OAAA,CAAQ,MAAA,YAAkB,KAAA;;;;AA2J1C;;;;;AAwBA;;;;;;;;;;;;iBArJgB,SAAA,CAAU,KAAA;;;;;AA+K1B;;;;;;;;;iBA9FgB,QAAA,CAAS,KAAA;;;;;;;;;;;;;iBAgBT,QAAA,CAAS,KAAA;;;;;;;;;;iBAaT,SAAA,CAAU,KAAA;;;;;;;;;;;;iBAeV,QAAA,CAAS,KAAA;;;;;;;;;;;;;;;;;iBAwBT,OAAA,GAAA,CAAW,KAAA,EAAO,QAAA,CAAS,CAAA,IAAK,CAAA,sBAAuB,CAAA;;;;;;;;;;;;;;iBA0BvD,SAAA,CAAU,KAAA"}
@@ -117,4 +117,4 @@ declare function flowAsync<A extends readonly unknown[], R1, R2, R3, R4, R5, R6>
117
117
  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
118
  //#endregion
119
119
  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-DqsBQ7Pp.d.mts.map
120
+ //# sourceMappingURL=index-D5l6I7QH.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DqsBQ7Pp.d.mts","names":[],"sources":["../src/function/call.ts","../src/function/branching.ts","../src/function/tap.ts","../src/function/flowAsync.ts"],"mappings":";;;;;;AAcA;;;;;;;;;;;iBAAgB,IAAA,iCAAA,CAAsC,EAAA,MAAQ,IAAA,EAAM,CAAA,KAAM,CAAA,KAAM,IAAA,EAAM,CAAA,GAAI,CAAA;;;;;;;;;AAgB1F;;;;iBAAsB,SAAA,iCAAA,CACpB,EAAA,MAAQ,IAAA,EAAM,CAAA,KAAM,OAAA,CAAQ,CAAA,MACzB,IAA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AAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,QAChC,IAAA,EAAM,CAAA,KAAM,OAAA,CAAQ,OAAA,CAAQ,EAAA;AAAA,iBACnB,SAAA,0DAAA,CACd,EAAA,MAAQ,IAAA,EAAM,CAAA,KAAM,YAAA,CAAa,EAAA,GACjC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,GACrC,EAAA,GAAK,CAAA,EAAG,OAAA,CAAQ,EAAA,MAAQ,YAAA,CAAa,EAAA,QAChC,IAAA,EAAM,CAAA,KAAM,OAAA,CAAQ,OAAA,CAAQ,EAAA"}
@@ -0,0 +1,39 @@
1
+ import { n as Ok$1, t as Err$1 } from "./types-X6LqLWno.mjs";
2
+ import { NonExhaustiveError, P, Pattern, isMatching, match } from "ts-pattern";
3
+
4
+ //#region src/match/match.d.ts
5
+ /**
6
+ * Extended ts-pattern `P` namespace. Carries everything ts-pattern exports
7
+ * (`P.string`, `P.number`, `P.array`, `P.when`, …) plus `P.ok` / `P.err`
8
+ * for matching `Result` values.
9
+ *
10
+ * Explicit literal-type annotations on the additions (rather than `as const`)
11
+ * keep the values non-`readonly`, which ts-pattern's narrowing requires —
12
+ * a `readonly` pattern collapses the remaining input to `never` after the
13
+ * first arm, breaking exhaustiveness.
14
+ *
15
+ * For the `P.Pattern<T>` type shorthand, import `Pattern` standalone from
16
+ * `massaman/match` — it's the form ts-pattern's own docs recommend.
17
+ */
18
+ declare const P$1: typeof P & {
19
+ ok: {
20
+ ok: true;
21
+ };
22
+ err: {
23
+ ok: false;
24
+ };
25
+ };
26
+ /**
27
+ * The `Ok` variant of a `Result<T>`. Re-exported here so the value-side
28
+ * patterns and the type-side `Ok<T>` live in one module — any consumer
29
+ * import gets both type and value namespaces without cross-module merge
30
+ * issues (TS2300).
31
+ */
32
+ type Ok<T> = Ok$1<T>;
33
+ /**
34
+ * The `Err` variant of a `Result<T>`. See {@link Ok} for the co-location note.
35
+ */
36
+ type Err = Err$1;
37
+ //#endregion
38
+ export { Err as a, match as i, Pattern as n, Ok as o, isMatching as r, P$1 as s, NonExhaustiveError as t };
39
+ //# sourceMappingURL=index-DtnKhaAD.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DtnKhaAD.d.mts","names":[],"sources":["../src/match/match.ts"],"mappings":";;;;;;;;AAwDA;;;;;;;;;cAjBa,GAAA,SAAU,CAAA;EAAQ,EAAA;IAAM,EAAA;EAAA;EAAY,GAAA;IAAO,EAAA;EAAA;AAAA;;;;;;;KAY5C,EAAA,MAAQ,IAAA,CAAO,CAAA;;;;KAKf,GAAA,GAAM,KAAA"}
@@ -21,28 +21,6 @@ import { isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyO
21
21
  type DangerouslyAllowAny = any;
22
22
  //#endregion
23
23
  //#region src/predicate/combinators.d.ts
24
- /**
25
- * Extracts the narrowed target type from a type-guard predicate.
26
- * Returns `never` for plain `boolean` predicates so they don't pollute
27
- * the union/intersection downstream.
28
- *
29
- * `DangerouslyAllowAny` is required here: this conditional needs to match
30
- * predicate signatures with arbitrary input types (`(n: number) => …`,
31
- * `(s: string) => …`, etc.). `unknown` would reject those by contravariance.
32
- */
33
- type Guarded<P> = P extends ((value: DangerouslyAllowAny) => value is infer X) ? X : never;
34
- /**
35
- * Extracts the input type from a tuple of predicates. Uses `infer V` in
36
- * contravariant position so multiple predicates with the same input type
37
- * collapse to that type. Return-position is `unknown` (covariant, accepts
38
- * any return value).
39
- */
40
- type InferInput<Ps> = Ps extends ReadonlyArray<(value: infer V) => unknown> ? V : never;
41
- /**
42
- * Converts a union `A | B | C` to an intersection `A & B & C`.
43
- * Standard contravariant-position trick.
44
- */
45
- type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
46
24
  /**
47
25
  * Returns a predicate that checks if a value satisfies ALL predicates.
48
26
  *
@@ -110,6 +88,17 @@ declare function both<T>(f: (value: T) => boolean, g: (value: T) => boolean): (v
110
88
  */
111
89
  declare function either<T, A extends T, B extends T>(f: (value: T) => value is A, g: (value: T) => value is B): (value: T) => value is A | B;
112
90
  declare function either<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean;
91
+ /**
92
+ * `DangerouslyAllowAny` is required: this conditional needs to match predicate
93
+ * signatures with arbitrary input types. `unknown` would reject them by contravariance.
94
+ */
95
+ type Guarded<P> = P extends ((value: DangerouslyAllowAny) => value is infer X) ? X : never;
96
+ /**
97
+ * `infer V` is contravariant here, so multiple predicates with the same input
98
+ * type collapse to that single type.
99
+ */
100
+ type InferInput<Ps> = Ps extends ReadonlyArray<(value: infer V) => unknown> ? V : never;
101
+ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
113
102
  //#endregion
114
103
  //#region src/predicate/guards.d.ts
115
104
  /**
@@ -121,7 +110,7 @@ declare function either<T>(f: (value: T) => boolean, g: (value: T) => boolean):
121
110
  * isArray('hello') // false
122
111
  * ```
123
112
  */
124
- declare const isArray: (arg: any) => arg is any[];
113
+ declare function isArray(value: unknown): value is unknown[];
125
114
  /**
126
115
  * Checks if a value is a non-null object.
127
116
  *
@@ -171,7 +160,7 @@ declare function isNotEmpty(value: string | object): boolean;
171
160
  * isFiniteNumber(Infinity) // false
172
161
  * ```
173
162
  */
174
- declare const isFiniteNumber: (value: unknown) => boolean;
163
+ declare function isFiniteNumber(value: unknown): value is number;
175
164
  /**
176
165
  * Checks if a value is an integer.
177
166
  *
@@ -181,7 +170,7 @@ declare const isFiniteNumber: (value: unknown) => boolean;
181
170
  * isInteger(4.2) // false
182
171
  * ```
183
172
  */
184
- declare const isInteger: (value: unknown) => boolean;
173
+ declare function isInteger(value: unknown): value is number;
185
174
  /**
186
175
  * Checks if a value is NaN.
187
176
  *
@@ -191,7 +180,7 @@ declare const isInteger: (value: unknown) => boolean;
191
180
  * isNaN(42) // false
192
181
  * ```
193
182
  */
194
- declare const isNaN: (value: unknown) => boolean;
183
+ declare function isNaN(value: unknown): value is number;
195
184
  //#endregion
196
185
  export { isSymbol as A, isNotEmpty as B, isNumber as C, isRegExp as D, isPromise as E, isArray as F, either as G, allPass as H, isEmpty as I, isFiniteNumber as L, isUndefined as M, isWeakMap as N, isSet$1 as O, isWeakSet as P, isInteger as R, isNull as S, isPrimitive$1 as T, anyPass as U, isObject as V, both as W, isLength as _, isBuffer as a, isNode as b, isEqual as c, isFile as d, isFunction as f, isJSONValue as g, isJSONObject as h, isBrowser as i, isTypedArray as j, isString$1 as k, isEqualWith as l, isJSONArray as m, isBlob as n, isDate as o, isJSON as p, isBoolean as r, isEmptyObject as s, isArrayBuffer as t, isError$1 as u, isMap$1 as v, isPlainObject as w, isNotNil as x, isNil$1 as y, isNaN as z };
197
- //# sourceMappingURL=index-BuBpCB73.d.mts.map
186
+ //# sourceMappingURL=index-g2aw5tc_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-g2aw5tc_.d.mts","names":[],"sources":["../src/types/internal.ts","../src/predicate/combinators.ts","../src/predicate/guards.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S,CAAA,GAAI,CAAA;AAAA,iBACd,MAAA,GAAA,CAAU,CAAA,GAAI,KAAA,EAAO,CAAA,cAAe,CAAA,GAAI,KAAA,EAAO,CAAA,gBAAiB,KAAA,EAAO,CAAA;;;;;KAYlF,OAAA,MAAa,CAAA,WAAY,KAAA,EAAO,mBAAA,KAAwB,KAAA,eAAoB,CAAA;;;;;KAM5E,UAAA,OAAiB,EAAA,SAAW,aAAA,EAAe,KAAA,yBAA8B,CAAA;AAAA,KAEzE,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAA,6BACrD,CAAA,sBAEE,CAAA;;;;;;ADnGJ;;;;;;iBETgB,OAAA,CAAQ,KAAA,YAAiB,KAAA;;ADWzC;;;;;;;;;;AACA;iBCIgB,QAAA,CAAS,KAAA,YAAiB,KAAA;;;;;;;;;;;;;;;;;iBAoB1B,OAAA,CAAQ,KAAA;;;;;;;;;;iBAmBR,UAAA,CAAW,KAAA;;;;ADjB3B;;;;;;iBC8BgB,cAAA,CAAe,KAAA,YAAiB,KAAA;;;;AD7BhD;;;;;;iBC0CgB,SAAA,CAAU,KAAA,YAAiB,KAAA;;;;;;;;;;iBAa3B,KAAA,CAAM,KAAA,YAAiB,KAAA"}
@@ -17,4 +17,4 @@ import { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKey
17
17
  declare function evolve<T extends Record<string, unknown>>(obj: T, spec: { [K in keyof T]?: (value: T[K]) => T[K] }): T;
18
18
  //#endregion
19
19
  export { toSnakeCaseKeys as _, flattenObject as a, mapValues as c, omit as d, omitBy as f, toMerged as g, toCamelCaseKeys as h, findKey as i, merge as l, pickBy as m, cloneDeep as n, invert as o, pick as p, cloneDeepWith as r, mapKeys as s, clone as t, mergeWith as u, evolve as v };
20
- //# sourceMappingURL=index-BkyNt8th.d.mts.map
20
+ //# sourceMappingURL=index-keGHab-v.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-keGHab-v.d.mts","names":[],"sources":["../src/object/evolve.ts"],"mappings":";;;;;;AAaA;;;;;;;;;;iBAAgB,MAAA,WAAiB,MAAA,kBAAA,CAC/B,GAAA,EAAK,CAAA,EACL,IAAA,gBAAoB,CAAA,KAAM,KAAA,EAAO,CAAA,CAAE,CAAA,MAAO,CAAA,CAAE,CAAA,MAC3C,CAAA"}
@@ -131,4 +131,4 @@ declare function sortWith<T>(array: readonly T[], comparators: ReadonlyArray<(a:
131
131
  declare function unfold<T, R>(fn: (seed: T) => [R, T] | false, seed: T): R[];
132
132
  //#endregion
133
133
  export { unionWith as $, last as A, remove as B, initial as C, isSubset as D, intersectionWith as E, orderBy as F, tail as G, sampleSize as H, partition as I, takeRightWhile as J, take as K, pull as L, mapAsync as M, maxBy as N, isSubsetWith as O, minBy as P, unionBy as Q, pullAt as R, head as S, intersectionBy as T, shuffle as U, sample as V, sortBy as W, toFilled as X, takeWhile as Y, union as Z, flatten as _, scan as _t, difference as a, windowed as at, forEachRight as b, adjust as bt, drop as c, xorBy as ct, dropWhile as d, zipObject as dt, uniq as et, fill as f, zipWith as ft, flatMapDeep as g, sortWith as gt, flatMapAsync as h, descend as ht, countBy as i, unzipWith as it, limitAsync as j, keyBy as k, dropRight as l, xorWith as lt, flatMap as m, ascend as mt, chunk as n, uniqWith as nt, differenceBy as o, without as ot, filterAsync as p, unfold as pt, takeRight as q, compact as r, unzip as rt, differenceWith as s, xor as st, at as t, uniqBy as tt, dropRightWhile as u, zip as ut, flattenDeep as v, reduceWhile as vt, intersection as w, groupBy as x, forEachAsync as y, dropRepeats as yt, reduceAsync as z };
134
- //# sourceMappingURL=index-Dw_tuZdb.d.mts.map
134
+ //# sourceMappingURL=index-mfIoxwxy.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-Dw_tuZdb.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":";;;;;;AAYA;;;;;;;;;i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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":";;;;;;AAYA;;;;;;;;;iBAAgB,MAAA,GAAA,CAAU,KAAA,WAAgB,CAAA,IAAK,KAAA,UAAe,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,CAAA;;;;;;AAApF;;;;;;;;;;;;;;;iBCMgB,WAAA,GAAA,CAAe,KAAA,WAAgB,CAAA,KAAM,CAAA;;;;;;ADNrD;;;;;;;;;;;;;;;;iBEOgB,WAAA,MAAA,CACd,KAAA,WAAgB,CAAA,IAChB,SAAA,GAAY,WAAA,EAAa,CAAA,EAAG,KAAA,EAAO,CAAA,cACnC,EAAA,GAAK,WAAA,EAAa,CAAA,EAAG,KAAA,EAAO,CAAA,EAAG,KAAA,aAAkB,CAAA,EACjD,OAAA,EAAS,CAAA,GACR,CAAA;;;;;;AFZH;;;;;;;;;iBGAgB,IAAA,MAAA,CACd,KAAA,WAAgB,CAAA,IAChB,EAAA,GAAK,WAAA,EAAa,CAAA,EAAG,KAAA,EAAO,CAAA,EAAG,KAAA,aAAkB,CAAA,EACjD,OAAA,EAAS,CAAA,GACR,CAAA;;;;;;AHJH;;;;;iBIJgB,MAAA,GAAA,CAAU,EAAA,GAAK,KAAA,EAAO,CAAA,wBAAyB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA;;;;;;;;;iBAsBxD,OAAA,GAAA,CAAW,EAAA,GAAK,KAAA,EAAO,CAAA,wBAAyB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA;;;;;;;;;AHZzE;;;;;;iBGwCgB,QAAA,GAAA,CACd,KAAA,WAAgB,CAAA,IAChB,WAAA,EAAa,aAAA,EAAe,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,eACpC,CAAA;;;;;;AJjDH;;;;;;;;;;;;;;;;iBKOgB,MAAA,MAAA,CAAa,EAAA,GAAK,IAAA,EAAM,CAAA,MAAO,CAAA,EAAG,CAAA,WAAY,IAAA,EAAM,CAAA,GAAI,CAAA"}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,13 @@
1
- import { $ as unionWith, A as last, B as remove, C as initial, D as isSubset, E as intersectionWith, F as orderBy, G as tail, H as sampleSize, I as partition, J as takeRightWhile, K as take, L as pull, M as mapAsync, N as maxBy, O as isSubsetWith, P as minBy, Q as unionBy, R as pullAt, S as head, T as intersectionBy, U as shuffle, V as sample, W as sortBy, X as toFilled, Y as takeWhile, Z as union, _ as flatten, _t as scan, a as difference, at as windowed, b as forEachRight, bt as adjust, c as drop, ct as xorBy, d as dropWhile, dt as zipObject, et as uniq, f as fill, ft as zipWith, g as flatMapDeep, gt as sortWith, h as flatMapAsync, ht as descend, i as countBy, it as unzipWith, j as limitAsync, k as keyBy, l as dropRight, lt as xorWith, m as flatMap, mt as ascend, n as chunk, nt as uniqWith, o as differenceBy, ot as without, p as filterAsync, pt as unfold, q as takeRight, r as compact, rt as unzip, s as differenceWith, st as xor, t as at, tt as uniqBy, u as dropRightWhile, ut as zip, v as flattenDeep, vt as reduceWhile, w as intersection, x as groupBy, y as forEachAsync, yt as dropRepeats, z as reduceAsync } from "./index-Dw_tuZdb.mjs";
2
- import { a as isOk, c as attempt, d as Ok, f as Result, i as isErr, l as attemptAsync, n as invariant, o as ok, r as err, s as unwrap, t as assert, u as Err } from "./index-Br9PO6mU.mjs";
3
- 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-COFf0Pih.mjs";
1
+ import { $ as unionWith, A as last, B as remove, C as initial, D as isSubset, E as intersectionWith, F as orderBy, G as tail, H as sampleSize, I as partition, J as takeRightWhile, K as take, L as pull, M as mapAsync, N as maxBy, O as isSubsetWith, P as minBy, Q as unionBy, R as pullAt, S as head, T as intersectionBy, U as shuffle, V as sample, W as sortBy, X as toFilled, Y as takeWhile, Z as union, _ as flatten, _t as scan, a as difference, at as windowed, b as forEachRight, bt as adjust, c as drop, ct as xorBy, d as dropWhile, dt as zipObject, et as uniq, f as fill, ft as zipWith, g as flatMapDeep, gt as sortWith, h as flatMapAsync, ht as descend, i as countBy, it as unzipWith, j as limitAsync, k as keyBy, l as dropRight, lt as xorWith, m as flatMap, mt as ascend, n as chunk, nt as uniqWith, o as differenceBy, ot as without, p as filterAsync, pt as unfold, q as takeRight, r as compact, rt as unzip, s as differenceWith, st as xor, t as at, tt as uniqBy, u as dropRightWhile, ut as zip, v as flattenDeep, vt as reduceWhile, w as intersection, x as groupBy, y as forEachAsync, yt as dropRepeats, z as reduceAsync } from "./index-mfIoxwxy.mjs";
2
+ import { r as Result } from "./types-X6LqLWno.mjs";
3
+ import { a as isOk, c as attempt, i as isErr, l as attemptAsync, n as invariant, o as ok, r as err, s as unwrap, t as assert } from "./index-BHb3Vge_.mjs";
4
+ 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-BjmDP8W9.mjs";
4
5
  import { AbortError, TimeoutError } from "./error/index.mjs";
5
- 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-DqsBQ7Pp.mjs";
6
+ 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-D5l6I7QH.mjs";
6
7
  import { clamp, inRange, mean, meanBy, median, medianBy, random, randomInt, range, rangeRight, round, sum, sumBy } from "./math/index.mjs";
7
- import { _ as toSnakeCaseKeys, a as flattenObject, c as mapValues, d as omit, f as omitBy, g as toMerged, h as toCamelCaseKeys, i as findKey, l as merge, m as pickBy, n as cloneDeep, o as invert, p as pick, r as cloneDeepWith, s as mapKeys, t as clone, u as mergeWith, v as evolve } from "./index-BkyNt8th.mjs";
8
- import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "./index-BuBpCB73.mjs";
8
+ import { _ as toSnakeCaseKeys, a as flattenObject, c as mapValues, d as omit, f as omitBy, g as toMerged, h as toCamelCaseKeys, i as findKey, l as merge, m as pickBy, n as cloneDeep, o as invert, p as pick, r as cloneDeepWith, s as mapKeys, t as clone, u as mergeWith, v as evolve } from "./index-keGHab-v.mjs";
9
+ import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "./index-g2aw5tc_.mjs";
9
10
  import { Mutex, Semaphore, delay, timeout, withTimeout } from "./promise/index.mjs";
10
11
  import { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words } from "./string/index.mjs";
11
- import { NonExhaustiveError, P, Pattern, isMatching, match } from "./pattern/index.mjs";
12
+ import { a as Err, i as match, n as Pattern, o as Ok, r as isMatching, s as P, t as NonExhaustiveError } from "./index-DtnKhaAD.mjs";
12
13
  export { AbortError, type DebounceOptions, type DebouncedFunction, type Err, type MemoizeCache, Mutex, NonExhaustiveError, type Ok, P, Pattern, type Result, Semaphore, type ThrottleOptions, type ThrottledFunction, TimeoutError, adjust, after, allPass, anyPass, ary, ascend, assert, asyncNoop, at, attempt, attemptAsync, before, both, call, callAsync, camelCase, capitalize, chunk, clamp, clone, cloneDeep, cloneDeepWith, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, descend, difference, differenceBy, differenceWith, drop, dropRepeats, dropRight, dropRightWhile, dropWhile, either, err, escape, escapeRegExp, evolve, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowAsync, flowRight, forEachAsync, forEachRight, groupBy, head, identity, ifElse, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArray, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmpty, isEmptyObject, isEqual, isEqualWith, isErr, isError, isFile, isFiniteNumber, isFunction, isInteger, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isMatching, isNaN, isNil, isNode, isNotEmpty, isNotNil, isNull, isNumber, isObject, isOk, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, match, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, ok, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, reduceWhile, remove, rest, retry, reverseString, round, sample, sampleSize, scan, shuffle, snakeCase, sortBy, sortWith, spread, startCase, stringify, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, tap, throttle, timeout, toArray, toBoolean, toCamelCaseKeys, toError, toFilled, toFinite, toInteger, toMerged, toNumber, toSnakeCaseKeys, toString, trim, trimEnd, trimStart, unary, unescape, unfold, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unless, unwrap, unzip, unzipWith, upperCase, upperFirst, when, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith };
package/dist/index.mjs CHANGED
@@ -3,10 +3,10 @@ import { AbortError, TimeoutError } from "./error/index.mjs";
3
3
  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-2-6QB4m7.mjs";
4
4
  import { clamp, inRange, mean, meanBy, median, medianBy, random, randomInt, range, rangeRight, round, sum, sumBy } from "./math/index.mjs";
5
5
  import { _ as toSnakeCaseKeys, a as flattenObject, c as mapValues, d as omit, f as omitBy, g as toMerged, h as toCamelCaseKeys, i as findKey, l as merge, m as pickBy, n as cloneDeep, o as invert, p as pick, r as cloneDeepWith, s as mapKeys, t as clone, u as mergeWith, v as evolve } from "./object-BHnp9Sr9.mjs";
6
- import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "./predicate-CYzSOMLW.mjs";
6
+ import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "./predicate-DtTBffBT.mjs";
7
7
  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-ByBXBR5i.mjs";
8
8
  import { Mutex, Semaphore, delay, timeout, withTimeout } from "./promise/index.mjs";
9
9
  import { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words } from "./string/index.mjs";
10
10
  import { a as err, c as ok, i as attemptAsync, l as unwrap, n as invariant, o as isErr, r as attempt, s as isOk, t as assert } from "./control-B8mDJqXw.mjs";
11
- import { NonExhaustiveError, P, Pattern, isMatching, match } from "./pattern/index.mjs";
11
+ import { a as P, i as match, n as Pattern, r as isMatching, t as NonExhaustiveError } from "./match-CG_v2C4Q.mjs";
12
12
  export { AbortError, Mutex, NonExhaustiveError, P, Pattern, Semaphore, TimeoutError, adjust, after, allPass, anyPass, ary, ascend, assert, asyncNoop, at, attempt, attemptAsync, before, both, call, callAsync, camelCase, capitalize, chunk, clamp, clone, cloneDeep, cloneDeepWith, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, descend, difference, differenceBy, differenceWith, drop, dropRepeats, dropRight, dropRightWhile, dropWhile, either, err, escape, escapeRegExp, evolve, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowAsync, flowRight, forEachAsync, forEachRight, groupBy, head, identity, ifElse, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArray, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmpty, isEmptyObject, isEqual, isEqualWith, isErr, isError, isFile, isFiniteNumber, isFunction, isInteger, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isMatching, isNaN, isNil, isNode, isNotEmpty, isNotNil, isNull, isNumber, isObject, isOk, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, match, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, ok, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, reduceWhile, remove, rest, retry, reverseString, round, sample, sampleSize, scan, shuffle, snakeCase, sortBy, sortWith, spread, startCase, stringify, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, tap, throttle, timeout, toArray, toBoolean, toCamelCaseKeys, toError, toFilled, toFinite, toInteger, toMerged, toNumber, toSnakeCaseKeys, toString, trim, trimEnd, trimStart, unary, unescape, unfold, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unless, unwrap, unzip, unzipWith, upperCase, upperFirst, when, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith };
@@ -0,0 +1,2 @@
1
+ import { a as Err, i as match, n as Pattern, o as Ok, r as isMatching, s as P, t as NonExhaustiveError } from "../index-DtnKhaAD.mjs";
2
+ export { Err, NonExhaustiveError, Ok, P, Pattern, isMatching, match };
@@ -0,0 +1,2 @@
1
+ import { a as P, i as match, n as Pattern, r as isMatching, t as NonExhaustiveError } from "../match-CG_v2C4Q.mjs";
2
+ export { NonExhaustiveError, P, Pattern, isMatching, match };
@@ -0,0 +1,44 @@
1
+ import { NonExhaustiveError, P, Pattern, isMatching, match } from "ts-pattern";
2
+ //#region src/match/match.ts
3
+ /**
4
+ * Extends ts-pattern's `P` namespace with `P.ok` and `P.err` — structural
5
+ * patterns for matching a `Result` inside `match()`.
6
+ *
7
+ * Mirrors Rust's `Ok(value)` / `Err(error)` match arms, but uses the
8
+ * namespace-property form (`P.ok` / `P.err`) so it doesn't collide with
9
+ * the lowercase `ok()` / `err()` constructors from `massaman/control`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { match, P, attempt } from 'massaman'
14
+ *
15
+ * match(attempt(() => JSON.parse(raw)))
16
+ * .with(P.ok, ({ value }) => use(value))
17
+ * .with(P.err, ({ error }) => log(error))
18
+ * .exhaustive()
19
+ * ```
20
+ */
21
+ const okPattern = { ok: true };
22
+ const errPattern = { ok: false };
23
+ /**
24
+ * Extended ts-pattern `P` namespace. Carries everything ts-pattern exports
25
+ * (`P.string`, `P.number`, `P.array`, `P.when`, …) plus `P.ok` / `P.err`
26
+ * for matching `Result` values.
27
+ *
28
+ * Explicit literal-type annotations on the additions (rather than `as const`)
29
+ * keep the values non-`readonly`, which ts-pattern's narrowing requires —
30
+ * a `readonly` pattern collapses the remaining input to `never` after the
31
+ * first arm, breaking exhaustiveness.
32
+ *
33
+ * For the `P.Pattern<T>` type shorthand, import `Pattern` standalone from
34
+ * `massaman/match` — it's the form ts-pattern's own docs recommend.
35
+ */
36
+ const P$1 = {
37
+ ...P,
38
+ ok: okPattern,
39
+ err: errPattern
40
+ };
41
+ //#endregion
42
+ export { P$1 as a, match as i, Pattern as n, isMatching as r, NonExhaustiveError as t };
43
+
44
+ //# sourceMappingURL=match-CG_v2C4Q.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-CG_v2C4Q.mjs","names":["P","TsP"],"sources":["../src/match/match.ts"],"sourcesContent":["/**\n * Extends ts-pattern's `P` namespace with `P.ok` and `P.err` — structural\n * patterns for matching a `Result` inside `match()`.\n *\n * Mirrors Rust's `Ok(value)` / `Err(error)` match arms, but uses the\n * namespace-property form (`P.ok` / `P.err`) so it doesn't collide with\n * the lowercase `ok()` / `err()` constructors from `massaman/control`.\n *\n * @example\n * ```ts\n * import { match, P, attempt } from 'massaman'\n *\n * match(attempt(() => JSON.parse(raw)))\n * .with(P.ok, ({ value }) => use(value))\n * .with(P.err, ({ error }) => log(error))\n * .exhaustive()\n * ```\n */\n\nimport { P as TsP } from 'ts-pattern'\n\nimport type { Err as ErrType, Ok as OkType } from '../control/types.js'\n\nconst okPattern: { ok: true } = { ok: true }\nconst errPattern: { ok: false } = { ok: false }\n\n/**\n * Extended ts-pattern `P` namespace. Carries everything ts-pattern exports\n * (`P.string`, `P.number`, `P.array`, `P.when`, …) plus `P.ok` / `P.err`\n * for matching `Result` values.\n *\n * Explicit literal-type annotations on the additions (rather than `as const`)\n * keep the values non-`readonly`, which ts-pattern's narrowing requires —\n * a `readonly` pattern collapses the remaining input to `never` after the\n * first arm, breaking exhaustiveness.\n *\n * For the `P.Pattern<T>` type shorthand, import `Pattern` standalone from\n * `massaman/match` — it's the form ts-pattern's own docs recommend.\n */\nexport const P: typeof TsP & { ok: { ok: true }; err: { ok: false } } = {\n ...TsP,\n ok: okPattern,\n err: errPattern,\n}\n\n/**\n * The `Ok` variant of a `Result<T>`. Re-exported here so the value-side\n * patterns and the type-side `Ok<T>` live in one module — any consumer\n * import gets both type and value namespaces without cross-module merge\n * issues (TS2300).\n */\nexport type Ok<T> = OkType<T>\n\n/**\n * The `Err` variant of a `Result<T>`. See {@link Ok} for the co-location note.\n */\nexport type Err = ErrType\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,YAA0B,EAAE,IAAI,MAAM;AAC5C,MAAM,aAA4B,EAAE,IAAI,OAAO;;;;;;;;;;;;;;AAe/C,MAAaA,MAA2D;CACtE,GAAGC;CACH,IAAI;CACJ,KAAK;CACN"}
@@ -1,2 +1,2 @@
1
- import { _ as toSnakeCaseKeys, a as flattenObject, c as mapValues, d as omit, f as omitBy, g as toMerged, h as toCamelCaseKeys, i as findKey, l as merge, m as pickBy, n as cloneDeep, o as invert, p as pick, r as cloneDeepWith, s as mapKeys, t as clone, u as mergeWith, v as evolve } from "../index-BkyNt8th.mjs";
1
+ import { _ as toSnakeCaseKeys, a as flattenObject, c as mapValues, d as omit, f as omitBy, g as toMerged, h as toCamelCaseKeys, i as findKey, l as merge, m as pickBy, n as cloneDeep, o as invert, p as pick, r as cloneDeepWith, s as mapKeys, t as clone, u as mergeWith, v as evolve } from "../index-keGHab-v.mjs";
2
2
  export { clone, cloneDeep, cloneDeepWith, evolve, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
@@ -1 +1 @@
1
- {"version":3,"file":"object-BHnp9Sr9.mjs","names":[],"sources":["../src/object/evolve.ts"],"sourcesContent":["/* oxlint-disable security/detect-object-injection -- keys sourced from Object.keys(spec), not user input */\n\n/**\n * Applies a spec of transformation functions to matching keys of an object,\n * returning a new object. Keys not in the spec are copied as-is.\n *\n * @example\n * ```ts\n * evolve({ name: ' Alice ', age: 29, role: 'admin' }, {\n * name: (s) => s.trim(),\n * age: (n) => n + 1,\n * })\n * // { name: 'Alice', age: 30, role: 'admin' }\n * ```\n */\nexport function evolve<T extends Record<string, unknown>>(\n obj: T,\n spec: { [K in keyof T]?: (value: T[K]) => T[K] }\n): T {\n const result = { ...obj }\n for (const key of Object.keys(spec) as Array<keyof T>) {\n const transform = spec[key]\n if (transform != null && key in result) {\n result[key] = transform(result[key])\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,OACd,KACA,MACG;CACH,MAAM,SAAS,EAAE,GAAG,KAAK;CACzB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,EAAoB;EACrD,MAAM,YAAY,KAAK;EACvB,IAAI,aAAa,QAAQ,OAAO,QAC9B,OAAO,OAAO,UAAU,OAAO,KAAK;;CAGxC,OAAO"}
1
+ {"version":3,"file":"object-BHnp9Sr9.mjs","names":[],"sources":["../src/object/evolve.ts"],"sourcesContent":["/**\n * Applies a spec of transformation functions to matching keys of an object,\n * returning a new object. Keys not in the spec are copied as-is.\n *\n * @example\n * ```ts\n * evolve({ name: ' Alice ', age: 29, role: 'admin' }, {\n * name: (s) => s.trim(),\n * age: (n) => n + 1,\n * })\n * // { name: 'Alice', age: 30, role: 'admin' }\n * ```\n */\nexport function evolve<T extends Record<string, unknown>>(\n obj: T,\n spec: { [K in keyof T]?: (value: T[K]) => T[K] }\n): T {\n const result = { ...obj }\n for (const key of Object.keys(spec) as Array<keyof T>) {\n // oxlint-disable-next-line security/detect-object-injection -- key sourced from Object.keys(spec), not user input\n const transform = spec[key]\n if (transform != null && key in result) {\n // oxlint-disable-next-line security/detect-object-injection -- key sourced from Object.keys(spec), not user input\n result[key] = transform(result[key])\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,OACd,KACA,MACG;CACH,MAAM,SAAS,EAAE,GAAG,KAAK;CACzB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,EAAoB;EAErD,MAAM,YAAY,KAAK;EACvB,IAAI,aAAa,QAAQ,OAAO,QAE9B,OAAO,OAAO,UAAU,OAAO,KAAK;;CAGxC,OAAO"}
@@ -1,2 +1,2 @@
1
- import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "../index-BuBpCB73.mjs";
1
+ import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "../index-g2aw5tc_.mjs";
2
2
  export { allPass, anyPass, both, either, isArray, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmpty, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFiniteNumber, isFunction, isInteger, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNaN, isNil, isNode, isNotEmpty, isNotNil, isNull, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet };
@@ -1,2 +1,2 @@
1
- import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "../predicate-CYzSOMLW.mjs";
1
+ import { A as isSymbol, B as isNotEmpty, C as isNumber, D as isRegExp, E as isPromise, F as isArray, G as either, H as allPass, I as isEmpty, L as isFiniteNumber, M as isUndefined, N as isWeakMap, O as isSet, P as isWeakSet, R as isInteger, S as isNull, T as isPrimitive, U as anyPass, V as isObject, W as both, _ as isLength, a as isBuffer, b as isNode, c as isEqual, d as isFile, f as isFunction, g as isJSONValue, h as isJSONObject, i as isBrowser, j as isTypedArray, k as isString, l as isEqualWith, m as isJSONArray, n as isBlob, o as isDate, p as isJSON, r as isBoolean, s as isEmptyObject, t as isArrayBuffer, u as isError, v as isMap, w as isPlainObject, x as isNotNil, y as isNil, z as isNaN } from "../predicate-DtTBffBT.mjs";
2
2
  export { allPass, anyPass, both, either, isArray, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmpty, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFiniteNumber, isFunction, isInteger, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNaN, isNil, isNode, isNotEmpty, isNotNil, isNull, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet };
@@ -23,7 +23,9 @@ function either(f, g) {
23
23
  * isArray('hello') // false
24
24
  * ```
25
25
  */
26
- const isArray = Array.isArray;
26
+ function isArray(value) {
27
+ return Array.isArray(value);
28
+ }
27
29
  /**
28
30
  * Checks if a value is a non-null object.
29
31
  *
@@ -81,7 +83,9 @@ function isNotEmpty(value) {
81
83
  * isFiniteNumber(Infinity) // false
82
84
  * ```
83
85
  */
84
- const isFiniteNumber = Number.isFinite;
86
+ function isFiniteNumber(value) {
87
+ return Number.isFinite(value);
88
+ }
85
89
  /**
86
90
  * Checks if a value is an integer.
87
91
  *
@@ -91,7 +95,9 @@ const isFiniteNumber = Number.isFinite;
91
95
  * isInteger(4.2) // false
92
96
  * ```
93
97
  */
94
- const isInteger = Number.isInteger;
98
+ function isInteger(value) {
99
+ return Number.isInteger(value);
100
+ }
95
101
  /**
96
102
  * Checks if a value is NaN.
97
103
  *
@@ -101,8 +107,10 @@ const isInteger = Number.isInteger;
101
107
  * isNaN(42) // false
102
108
  * ```
103
109
  */
104
- const isNaN = Number.isNaN;
110
+ function isNaN(value) {
111
+ return Number.isNaN(value);
112
+ }
105
113
  //#endregion
106
114
  export { isSymbol as A, isNotEmpty as B, isNumber as C, isRegExp as D, isPromise as E, isArray as F, either as G, allPass as H, isEmpty as I, isFiniteNumber as L, isUndefined as M, isWeakMap as N, isSet$1 as O, isWeakSet as P, isInteger as R, isNull as S, isPrimitive$1 as T, anyPass as U, isObject as V, both as W, isLength as _, isBuffer as a, isNode as b, isEqual as c, isFile as d, isFunction as f, isJSONValue as g, isJSONObject as h, isBrowser as i, isTypedArray as j, isString$1 as k, isEqualWith as l, isJSONArray as m, isBlob as n, isDate as o, isJSON as p, isBoolean as r, isEmptyObject as s, isArrayBuffer as t, isError$1 as u, isMap$1 as v, isPlainObject as w, isNotNil as x, isNil$1 as y, isNaN as z };
107
115
 
108
- //# sourceMappingURL=predicate-CYzSOMLW.mjs.map
116
+ //# sourceMappingURL=predicate-DtTBffBT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predicate-DtTBffBT.mjs","names":[],"sources":["../src/predicate/combinators.ts","../src/predicate/guards.ts"],"sourcesContent":["import type { DangerouslyAllowAny } from '../types/internal.js'\n\n/**\n * Returns a predicate that checks if a value satisfies ALL predicates.\n *\n * When every input is a type guard, the result narrows to the intersection\n * of every guard's target type. Plain `boolean` predicates contribute nothing\n * to the narrowing (they fall back to no-op).\n *\n * @example\n * ```ts\n * const isPositiveEven = allPass([(n: number) => n > 0, (n: number) => n % 2 === 0])\n * isPositiveEven(4) // true\n *\n * const isNonEmptyString = allPass([isString, isNotEmpty])\n * if (isNonEmptyString(x)) {\n * // x is narrowed to string here\n * }\n * ```\n */\nexport function allPass<T>(predicates: readonly []): (value: T) => true\nexport function allPass<Ps extends ReadonlyArray<(value: DangerouslyAllowAny) => boolean>>(\n predicates: Ps\n): (value: InferInput<Ps>) => value is InferInput<Ps> & UnionToIntersection<Guarded<Ps[number]>>\nexport function allPass(\n predicates: ReadonlyArray<(value: unknown) => boolean>\n): (value: unknown) => boolean {\n return (value: unknown) => predicates.every((pred) => pred(value))\n}\n\n/**\n * Returns a predicate that checks if a value satisfies ANY predicate.\n *\n * When every input is a type guard, the result narrows to the union of every\n * guard's target type (since only one needs to match).\n *\n * @example\n * ```ts\n * const isAdminOrOwner = anyPass([isAdmin, isOwner])\n * isAdminOrOwner(user)\n *\n * const isStringOrNumber = anyPass([isString, isNumber])\n * if (isStringOrNumber(x)) {\n * // x is narrowed to string | number here\n * }\n * ```\n */\nexport function anyPass<T>(predicates: readonly []): (value: T) => false\nexport function anyPass<Ps extends ReadonlyArray<(value: DangerouslyAllowAny) => boolean>>(\n predicates: Ps\n): (value: InferInput<Ps>) => value is InferInput<Ps> & Guarded<Ps[number]>\nexport function anyPass(\n predicates: ReadonlyArray<(value: unknown) => boolean>\n): (value: unknown) => boolean {\n return (value: unknown) => predicates.some((pred) => pred(value))\n}\n\n/**\n * Returns a predicate that checks if a value satisfies both predicates.\n *\n * Binary AND combinator — shorthand for `allPass([f, g])`. When both inputs\n * are type guards, the result narrows to the intersection of their target types.\n *\n * @example\n * ```ts\n * const isPositiveEven = both((n: number) => n > 0, (n: number) => n % 2 === 0)\n * isPositiveEven(4)\n * ```\n */\nexport function both<T, A extends T, B extends T>(\n f: (value: T) => value is A,\n g: (value: T) => value is B\n): (value: T) => value is A & B\nexport function both<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean\nexport function both<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean {\n return (value: T) => f(value) && g(value)\n}\n\n/**\n * Returns a predicate that checks if a value satisfies either predicate.\n *\n * Binary OR combinator — shorthand for `anyPass([f, g])`. When both inputs\n * are type guards, the result narrows to the union of their target types.\n *\n * @example\n * ```ts\n * const isNilOrEmpty = either(isNil, (s: string) => s === '')\n * isNilOrEmpty(null)\n * ```\n */\nexport function either<T, A extends T, B extends T>(\n f: (value: T) => value is A,\n g: (value: T) => value is B\n): (value: T) => value is A | B\nexport function either<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean\nexport function either<T>(\n f: (value: T) => boolean,\n g: (value: T) => boolean\n): (value: T) => boolean {\n return (value: T) => f(value) || g(value)\n}\n\n/**\n * `DangerouslyAllowAny` is required: this conditional needs to match predicate\n * signatures with arbitrary input types. `unknown` would reject them by contravariance.\n */\ntype Guarded<P> = P extends ((value: DangerouslyAllowAny) => value is infer X) ? X : never\n\n/**\n * `infer V` is contravariant here, so multiple predicates with the same input\n * type collapse to that single type.\n */\ntype InferInput<Ps> = Ps extends ReadonlyArray<(value: infer V) => unknown> ? V : never\n\ntype UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\n","/**\n * Checks if a value is an array.\n *\n * @example\n * ```ts\n * isArray([1, 2]) // true\n * isArray('hello') // false\n * ```\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value)\n}\n\n/**\n * Checks if a value is a non-null object.\n *\n * Returns `true` for plain objects, arrays, class instances, etc.\n * Returns `false` for `null`, primitives, and functions.\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is object {\n return value !== null && typeof value === 'object'\n}\n\n/**\n * Checks if a value is empty.\n *\n * - Strings: `''`\n * - Arrays: `length === 0`\n * - Maps/Sets: `size === 0`\n * - Objects: no own enumerable keys\n *\n * @example\n * ```ts\n * isEmpty('') // true\n * isEmpty([]) // true\n * isEmpty({}) // true\n * isEmpty(new Map()) // true\n * ```\n */\nexport function isEmpty(value: string | object): boolean {\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0\n }\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0\n }\n return Object.keys(value).length === 0\n}\n\n/**\n * Checks if a value is not empty. Complement of {@link isEmpty}.\n *\n * @example\n * ```ts\n * isNotEmpty('hello') // true\n * isNotEmpty([]) // false\n * ```\n */\nexport function isNotEmpty(value: string | object): boolean {\n return !isEmpty(value)\n}\n\n/**\n * Checks if a value is a finite number.\n *\n * @example\n * ```ts\n * isFiniteNumber(42) // true\n * isFiniteNumber(Infinity) // false\n * ```\n */\nexport function isFiniteNumber(value: unknown): value is number {\n return Number.isFinite(value)\n}\n\n/**\n * Checks if a value is an integer.\n *\n * @example\n * ```ts\n * isInteger(42) // true\n * isInteger(4.2) // false\n * ```\n */\nexport function isInteger(value: unknown): value is number {\n return Number.isInteger(value)\n}\n\n/**\n * Checks if a value is NaN.\n *\n * @example\n * ```ts\n * isNaN(NaN) // true\n * isNaN(42) // false\n * ```\n */\nexport function isNaN(value: unknown): value is number {\n return Number.isNaN(value)\n}\n"],"mappings":";;AAwBA,SAAgB,QACd,YAC6B;CAC7B,QAAQ,UAAmB,WAAW,OAAO,SAAS,KAAK,MAAM,CAAC;;AAwBpE,SAAgB,QACd,YAC6B;CAC7B,QAAQ,UAAmB,WAAW,MAAM,SAAS,KAAK,MAAM,CAAC;;AAoBnE,SAAgB,KAAQ,GAA0B,GAAiD;CACjG,QAAQ,UAAa,EAAE,MAAM,IAAI,EAAE,MAAM;;AAoB3C,SAAgB,OACd,GACA,GACuB;CACvB,QAAQ,UAAa,EAAE,MAAM,IAAI,EAAE,MAAM;;;;;;;;;;;;;AC1F3C,SAAgB,QAAQ,OAAoC;CAC1D,OAAO,MAAM,QAAQ,MAAM;;;;;;;;;;;;;;AAe7B,SAAgB,SAAS,OAAiC;CACxD,OAAO,UAAU,QAAQ,OAAO,UAAU;;;;;;;;;;;;;;;;;;AAmB5C,SAAgB,QAAQ,OAAiC;CACvD,IAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,EACnD,OAAO,MAAM,WAAW;CAE1B,IAAI,iBAAiB,OAAO,iBAAiB,KAC3C,OAAO,MAAM,SAAS;CAExB,OAAO,OAAO,KAAK,MAAM,CAAC,WAAW;;;;;;;;;;;AAYvC,SAAgB,WAAW,OAAiC;CAC1D,OAAO,CAAC,QAAQ,MAAM;;;;;;;;;;;AAYxB,SAAgB,eAAe,OAAiC;CAC9D,OAAO,OAAO,SAAS,MAAM;;;;;;;;;;;AAY/B,SAAgB,UAAU,OAAiC;CACzD,OAAO,OAAO,UAAU,MAAM;;;;;;;;;;;AAYhC,SAAgB,MAAM,OAAiC;CACrD,OAAO,OAAO,MAAM,MAAM"}
@@ -0,0 +1,42 @@
1
+ //#region src/control/types.d.ts
2
+ /**
3
+ * Success result containing a value.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const result: Ok<number> = { ok: true, value: 42 }
8
+ * ```
9
+ */
10
+ interface Ok<T> {
11
+ readonly ok: true;
12
+ readonly value: T;
13
+ readonly error: null;
14
+ }
15
+ /**
16
+ * Failure result containing an error.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const result: Err = { ok: false, error: new Error('fail') }
21
+ * ```
22
+ */
23
+ interface Err {
24
+ readonly ok: false;
25
+ readonly value: null;
26
+ readonly error: Error;
27
+ }
28
+ /**
29
+ * Discriminated union representing either success (`Ok`) or failure (`Err`).
30
+ * Inspired by Rust's `Result<T, E>`, but errors are always `Error`.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * function divide(a: number, b: number): Result<number> {
35
+ * return b === 0 ? err('division by zero') : ok(a / b)
36
+ * }
37
+ * ```
38
+ */
39
+ type Result<T> = Ok<T> | Err;
40
+ //#endregion
41
+ export { Ok as n, Result as r, Err as t };
42
+ //# sourceMappingURL=types-X6LqLWno.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-X6LqLWno.d.mts","names":[],"sources":["../src/control/types.ts"],"mappings":";;AAQA;;;;;;;UAAiB,EAAA;EAAA,SACN,EAAA;EAAA,SACA,KAAA,EAAO,CAAA;EAAA,SACP,KAAA;AAAA;;;;;;;;;UAWM,GAAA;EAAA,SACN,EAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;KAcN,MAAA,MAAY,EAAA,CAAG,CAAA,IAAK,GAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "massaman",
3
- "version": "0.0.1-rc.2",
3
+ "version": "0.2.0",
4
4
  "description": "A comprehensive functional programming library and utilities for TypeScript",
5
5
  "keywords": [
6
6
  "es-toolkit",
@@ -59,9 +59,9 @@
59
59
  "types": "./dist/control/index.d.mts",
60
60
  "import": "./dist/control/index.mjs"
61
61
  },
62
- "./pattern": {
63
- "types": "./dist/pattern/index.d.mts",
64
- "import": "./dist/pattern/index.mjs"
62
+ "./match": {
63
+ "types": "./dist/match/index.d.mts",
64
+ "import": "./dist/match/index.mjs"
65
65
  },
66
66
  "./math": {
67
67
  "types": "./dist/math/index.d.mts",
@@ -81,7 +81,8 @@
81
81
  }
82
82
  },
83
83
  "publishConfig": {
84
- "access": "public"
84
+ "access": "public",
85
+ "provenance": true
85
86
  },
86
87
  "dependencies": {
87
88
  "es-toolkit": "1.46.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BkyNt8th.d.mts","names":[],"sources":["../src/object/evolve.ts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B,KAAA,EAAO,CAAA,KAAM,KAAA,IAAS,CAAA,GAAI,CAAA;AAAA,iBACd,IAAA,GAAA,CAAQ,CAAA,GAAI,KAAA,EAAO,CAAA,cAAe,CAAA,GAAI,KAAA,EAAO,CAAA,gBAAiB,KAAA,EAAO,CAAA;;;;;;;;;;;;;iBAiBrE,MAAA,cAAoB,CAAA,YAAa,CAAA,CAAA,CAC/C,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,KAAA,IAAS,CAAA,EAC1B,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,KAAA,IAAS,CAAA,IACxB,KAAA,EAAO,CAAA,KAAM,KAAA,IAAS,CAAA,GAAI,CAAA;AAAA,iBACd,MAAA,GAAA,CAAU,CAAA,GAAI,KAAA,EAAO,CAAA,cAAe,CAAA,GAAI,KAAA,EAAO,CAAA,gBAAiB,KAAA,EAAO,CAAA;;;;;;ADxGvF;;;;;;cEVa,OAAA,GAAO,GAAA,UAAA,GAAA;;ADT2C;;;;;;;;;;;iBCuB/C,QAAA,CAAS,KAAA,YAAiB,KAAA;;ADZwC;;;;;;;;;;;;AAQH;;;iBCwB/D,OAAA,CAAQ,KAAA;;;;;;;;;;iBAmBR,UAAA,CAAW,KAAA;;;;;;;;;;cAad,cAAA,GAAiB,KAAA;;;;;;;;;;cAWjB,SAAA,GAAY,KAAA;;;;;;;;;;cAWZ,KAAA,GAAQ,KAAA"}
@@ -1,2 +0,0 @@
1
- import { NonExhaustiveError, P, Pattern, isMatching, match } from "ts-pattern";
2
- export { NonExhaustiveError, P, Pattern, isMatching, match };
@@ -1,2 +0,0 @@
1
- import { NonExhaustiveError, P, Pattern, isMatching, match } from "ts-pattern";
2
- export { NonExhaustiveError, P, Pattern, isMatching, match };
@@ -1 +0,0 @@
1
- {"version":3,"file":"predicate-CYzSOMLW.mjs","names":[],"sources":["../src/predicate/combinators.ts","../src/predicate/guards.ts"],"sourcesContent":["import type { DangerouslyAllowAny } from '../types/internal.js'\n\n/**\n * Extracts the narrowed target type from a type-guard predicate.\n * Returns `never` for plain `boolean` predicates so they don't pollute\n * the union/intersection downstream.\n *\n * `DangerouslyAllowAny` is required here: this conditional needs to match\n * predicate signatures with arbitrary input types (`(n: number) => …`,\n * `(s: string) => …`, etc.). `unknown` would reject those by contravariance.\n */\ntype Guarded<P> = P extends ((value: DangerouslyAllowAny) => value is infer X) ? X : never\n\n/**\n * Extracts the input type from a tuple of predicates. Uses `infer V` in\n * contravariant position so multiple predicates with the same input type\n * collapse to that type. Return-position is `unknown` (covariant, accepts\n * any return value).\n */\ntype InferInput<Ps> = Ps extends ReadonlyArray<(value: infer V) => unknown> ? V : never\n\n/**\n * Converts a union `A | B | C` to an intersection `A & B & C`.\n * Standard contravariant-position trick.\n */\ntype UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\n\n/**\n * Returns a predicate that checks if a value satisfies ALL predicates.\n *\n * When every input is a type guard, the result narrows to the intersection\n * of every guard's target type. Plain `boolean` predicates contribute nothing\n * to the narrowing (they fall back to no-op).\n *\n * @example\n * ```ts\n * const isPositiveEven = allPass([(n: number) => n > 0, (n: number) => n % 2 === 0])\n * isPositiveEven(4) // true\n *\n * const isNonEmptyString = allPass([isString, isNotEmpty])\n * if (isNonEmptyString(x)) {\n * // x is narrowed to string here\n * }\n * ```\n */\nexport function allPass<T>(predicates: readonly []): (value: T) => true\nexport function allPass<Ps extends ReadonlyArray<(value: DangerouslyAllowAny) => boolean>>(\n predicates: Ps\n): (value: InferInput<Ps>) => value is InferInput<Ps> & UnionToIntersection<Guarded<Ps[number]>>\nexport function allPass(\n predicates: ReadonlyArray<(value: unknown) => boolean>\n): (value: unknown) => boolean {\n return (value: unknown) => predicates.every((pred) => pred(value))\n}\n\n/**\n * Returns a predicate that checks if a value satisfies ANY predicate.\n *\n * When every input is a type guard, the result narrows to the union of every\n * guard's target type (since only one needs to match).\n *\n * @example\n * ```ts\n * const isAdminOrOwner = anyPass([isAdmin, isOwner])\n * isAdminOrOwner(user)\n *\n * const isStringOrNumber = anyPass([isString, isNumber])\n * if (isStringOrNumber(x)) {\n * // x is narrowed to string | number here\n * }\n * ```\n */\nexport function anyPass<T>(predicates: readonly []): (value: T) => false\nexport function anyPass<Ps extends ReadonlyArray<(value: DangerouslyAllowAny) => boolean>>(\n predicates: Ps\n): (value: InferInput<Ps>) => value is InferInput<Ps> & Guarded<Ps[number]>\nexport function anyPass(\n predicates: ReadonlyArray<(value: unknown) => boolean>\n): (value: unknown) => boolean {\n return (value: unknown) => predicates.some((pred) => pred(value))\n}\n\n/**\n * Returns a predicate that checks if a value satisfies both predicates.\n *\n * Binary AND combinator — shorthand for `allPass([f, g])`. When both inputs\n * are type guards, the result narrows to the intersection of their target types.\n *\n * @example\n * ```ts\n * const isPositiveEven = both((n: number) => n > 0, (n: number) => n % 2 === 0)\n * isPositiveEven(4)\n * ```\n */\nexport function both<T, A extends T, B extends T>(\n f: (value: T) => value is A,\n g: (value: T) => value is B\n): (value: T) => value is A & B\nexport function both<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean\nexport function both<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean {\n return (value: T) => f(value) && g(value)\n}\n\n/**\n * Returns a predicate that checks if a value satisfies either predicate.\n *\n * Binary OR combinator — shorthand for `anyPass([f, g])`. When both inputs\n * are type guards, the result narrows to the union of their target types.\n *\n * @example\n * ```ts\n * const isNilOrEmpty = either(isNil, (s: string) => s === '')\n * isNilOrEmpty(null)\n * ```\n */\nexport function either<T, A extends T, B extends T>(\n f: (value: T) => value is A,\n g: (value: T) => value is B\n): (value: T) => value is A | B\nexport function either<T>(f: (value: T) => boolean, g: (value: T) => boolean): (value: T) => boolean\nexport function either<T>(\n f: (value: T) => boolean,\n g: (value: T) => boolean\n): (value: T) => boolean {\n return (value: T) => f(value) || g(value)\n}\n","/**\n * Checks if a value is an array.\n *\n * @example\n * ```ts\n * isArray([1, 2]) // true\n * isArray('hello') // false\n * ```\n */\nexport const isArray = Array.isArray\n\n/**\n * Checks if a value is a non-null object.\n *\n * Returns `true` for plain objects, arrays, class instances, etc.\n * Returns `false` for `null`, primitives, and functions.\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is object {\n return value !== null && typeof value === 'object'\n}\n\n/**\n * Checks if a value is empty.\n *\n * - Strings: `''`\n * - Arrays: `length === 0`\n * - Maps/Sets: `size === 0`\n * - Objects: no own enumerable keys\n *\n * @example\n * ```ts\n * isEmpty('') // true\n * isEmpty([]) // true\n * isEmpty({}) // true\n * isEmpty(new Map()) // true\n * ```\n */\nexport function isEmpty(value: string | object): boolean {\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0\n }\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0\n }\n return Object.keys(value).length === 0\n}\n\n/**\n * Checks if a value is not empty. Complement of {@link isEmpty}.\n *\n * @example\n * ```ts\n * isNotEmpty('hello') // true\n * isNotEmpty([]) // false\n * ```\n */\nexport function isNotEmpty(value: string | object): boolean {\n return !isEmpty(value)\n}\n\n/**\n * Checks if a value is a finite number.\n *\n * @example\n * ```ts\n * isFiniteNumber(42) // true\n * isFiniteNumber(Infinity) // false\n * ```\n */\nexport const isFiniteNumber: (value: unknown) => boolean = Number.isFinite\n\n/**\n * Checks if a value is an integer.\n *\n * @example\n * ```ts\n * isInteger(42) // true\n * isInteger(4.2) // false\n * ```\n */\nexport const isInteger: (value: unknown) => boolean = Number.isInteger\n\n/**\n * Checks if a value is NaN.\n *\n * @example\n * ```ts\n * isNaN(NaN) // true\n * isNaN(42) // false\n * ```\n */\nexport const isNaN: (value: unknown) => boolean = Number.isNaN\n"],"mappings":";;AAqDA,SAAgB,QACd,YAC6B;CAC7B,QAAQ,UAAmB,WAAW,OAAO,SAAS,KAAK,MAAM,CAAC;;AAwBpE,SAAgB,QACd,YAC6B;CAC7B,QAAQ,UAAmB,WAAW,MAAM,SAAS,KAAK,MAAM,CAAC;;AAoBnE,SAAgB,KAAQ,GAA0B,GAAiD;CACjG,QAAQ,UAAa,EAAE,MAAM,IAAI,EAAE,MAAM;;AAoB3C,SAAgB,OACd,GACA,GACuB;CACvB,QAAQ,UAAa,EAAE,MAAM,IAAI,EAAE,MAAM;;;;;;;;;;;;;ACvH3C,MAAa,UAAU,MAAM;;;;;;;;;;;;;AAc7B,SAAgB,SAAS,OAAiC;CACxD,OAAO,UAAU,QAAQ,OAAO,UAAU;;;;;;;;;;;;;;;;;;AAmB5C,SAAgB,QAAQ,OAAiC;CACvD,IAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,EACnD,OAAO,MAAM,WAAW;CAE1B,IAAI,iBAAiB,OAAO,iBAAiB,KAC3C,OAAO,MAAM,SAAS;CAExB,OAAO,OAAO,KAAK,MAAM,CAAC,WAAW;;;;;;;;;;;AAYvC,SAAgB,WAAW,OAAiC;CAC1D,OAAO,CAAC,QAAQ,MAAM;;;;;;;;;;;AAYxB,MAAa,iBAA8C,OAAO;;;;;;;;;;AAWlE,MAAa,YAAyC,OAAO;;;;;;;;;;AAW7D,MAAa,QAAqC,OAAO"}