massaman 0.1.0 → 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.
- package/README.md +11 -11
- package/dist/array/index.d.mts +1 -1
- package/dist/control/index.d.mts +2 -1
- package/dist/conversion/index.d.mts +1 -1
- package/dist/function/index.d.mts +1 -1
- package/dist/{index-Br9PO6mU.d.mts → index-BHb3Vge_.d.mts} +3 -42
- package/dist/index-BHb3Vge_.d.mts.map +1 -0
- package/dist/{index-COFf0Pih.d.mts → index-BjmDP8W9.d.mts} +1 -1
- package/dist/{index-COFf0Pih.d.mts.map → index-BjmDP8W9.d.mts.map} +1 -1
- package/dist/{index-DqsBQ7Pp.d.mts → index-D5l6I7QH.d.mts} +1 -1
- package/dist/{index-DqsBQ7Pp.d.mts.map → index-D5l6I7QH.d.mts.map} +1 -1
- package/dist/index-DtnKhaAD.d.mts +39 -0
- package/dist/index-DtnKhaAD.d.mts.map +1 -0
- package/dist/{index-B5x6pJw7.d.mts → index-g2aw5tc_.d.mts} +1 -1
- package/dist/{index-B5x6pJw7.d.mts.map → index-g2aw5tc_.d.mts.map} +1 -1
- package/dist/{index-BkyNt8th.d.mts → index-keGHab-v.d.mts} +1 -1
- package/dist/{index-BkyNt8th.d.mts.map → index-keGHab-v.d.mts.map} +1 -1
- package/dist/{index-Dw_tuZdb.d.mts → index-mfIoxwxy.d.mts} +1 -1
- package/dist/{index-Dw_tuZdb.d.mts.map → index-mfIoxwxy.d.mts.map} +1 -1
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +1 -1
- package/dist/match/index.d.mts +2 -0
- package/dist/match/index.mjs +2 -0
- package/dist/match-CG_v2C4Q.mjs +44 -0
- package/dist/match-CG_v2C4Q.mjs.map +1 -0
- package/dist/object/index.d.mts +1 -1
- package/dist/predicate/index.d.mts +1 -1
- package/dist/types-X6LqLWno.d.mts +42 -0
- package/dist/types-X6LqLWno.d.mts.map +1 -0
- package/package.json +4 -4
- package/dist/index-Br9PO6mU.d.mts.map +0 -1
- package/dist/pattern/index.d.mts +0 -2
- package/dist/pattern/index.mjs +0 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/zrosenbauer/massaman/main/.github/assets/banner.png" alt="massaman" width="
|
|
2
|
+
<img src="https://raw.githubusercontent.com/zrosenbauer/massaman/main/.github/assets/banner.png" alt="massaman" width="100%" />
|
|
3
3
|
<p><strong>Functional programming utilities for TypeScript. Result types, pattern matching, async pipelines. Fully typed.</strong></p>
|
|
4
4
|
|
|
5
5
|
<a href="https://github.com/zrosenbauer/massaman/actions/workflows/ci.yml"><img src="https://github.com/zrosenbauer/massaman/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
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.
|
|
18
18
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
@@ -29,7 +29,7 @@ npm install massaman
|
|
|
29
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
31
|
```ts
|
|
32
|
-
import { match, P } from 'massaman/
|
|
32
|
+
import { match, P } from 'massaman/match'
|
|
33
33
|
|
|
34
34
|
const status = match(action)
|
|
35
35
|
.with({ type: 'load' }, () => 'loading')
|
|
@@ -40,7 +40,7 @@ const status = match(action)
|
|
|
40
40
|
|
|
41
41
|
### From es-toolkit
|
|
42
42
|
|
|
43
|
-
Most of the surface (`array`, `object`, `string`, `function`, `math`) is a transparent re-export of [es-toolkit](https://es-toolkit.
|
|
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.
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
46
|
import { chunk, groupBy } from 'massaman'
|
|
@@ -91,7 +91,7 @@ match parsed {
|
|
|
91
91
|
The equivalent in TypeScript using `massaman`:
|
|
92
92
|
|
|
93
93
|
```ts
|
|
94
|
-
import { match, P } from 'massaman/
|
|
94
|
+
import { match, P } from 'massaman/match'
|
|
95
95
|
import { attempt, isOk } from 'massaman/control'
|
|
96
96
|
|
|
97
97
|
match(action)
|
|
@@ -108,9 +108,9 @@ if (isOk(parsed)) {
|
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
`massaman` brings both patterns to TypeScript, layered over [es-toolkit](https://es-toolkit.
|
|
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
112
|
|
|
113
|
-
More on the philosophy at [zrosenbauer.com/blog](https://zrosenbauer.com/blog).
|
|
113
|
+
More on the philosophy at [zrosenbauer.com/gui/blog](https://zrosenbauer.com/gui/blog).
|
|
114
114
|
|
|
115
115
|
## Contributing
|
|
116
116
|
|
package/dist/array/index.d.mts
CHANGED
|
@@ -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-
|
|
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 };
|
package/dist/control/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
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,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-
|
|
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,
|
|
155
|
-
//# sourceMappingURL=index-
|
|
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-
|
|
128
|
+
//# sourceMappingURL=index-BjmDP8W9.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
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-
|
|
120
|
+
//# sourceMappingURL=index-D5l6I7QH.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-D5l6I7QH.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,IAAA,EAAM,CAAA,G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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"}
|
|
@@ -183,4 +183,4 @@ declare function isInteger(value: unknown): value is number;
|
|
|
183
183
|
declare function isNaN(value: unknown): value is number;
|
|
184
184
|
//#endregion
|
|
185
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 };
|
|
186
|
-
//# sourceMappingURL=index-
|
|
186
|
+
//# sourceMappingURL=index-g2aw5tc_.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-g2aw5tc_.d.mts","names":[],"sources":["../src/types/internal.ts","../src/predicate/combinators.ts","../src/predicate/guards.ts"],"mappings":";;;;;;AAkBA;;;;;;;;ACEA;;;;;;KDFY,mBAAA;;;;;AAAZ;;;;;;;;ACEA;;;;;;;;iBAAgB,OAAA,GAAA,CAAW,UAAA,iBAA2B,KAAA,EAAO,CAAA;AAAA,iBAC7C,OAAA,YAAmB,aAAA,EAAe,KAAA,EAAO,mBAAA,cAAA,CACvD,UAAA,EAAY,EAAA,IACV,KAAA,EAAO,UAAA,CAAW,EAAA,MAAQ,KAAA,IAAS,UAAA,CAAW,EAAA,IAAM,mBAAA,CAAoB,OAAA,CAAQ,EAAA;AAFpF;;;;;;;;;;;;;;;;;AAAA,iBA0BgB,OAAA,GAAA,CAAW,UAAA,iBAA2B,KAAA,EAAO,CAAA;AAAA,iBAC7C,OAAA,YAAmB,aAAA,EAAe,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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-
|
|
20
|
+
//# sourceMappingURL=index-keGHab-v.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
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-
|
|
134
|
+
//# sourceMappingURL=index-mfIoxwxy.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-mfIoxwxy.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;;;;;;;;;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-
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
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-
|
|
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-
|
|
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-
|
|
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 {
|
|
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
|
@@ -8,5 +8,5 @@ import { a as toFinite, c as toString, i as toError, n as toArray, o as toIntege
|
|
|
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 {
|
|
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,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"}
|
package/dist/object/index.d.mts
CHANGED
|
@@ -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-
|
|
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,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-
|
|
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 };
|
|
@@ -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.
|
|
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
|
-
"./
|
|
63
|
-
"types": "./dist/
|
|
64
|
-
"import": "./dist/
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Br9PO6mU.d.mts","names":[],"sources":["../src/control/types.ts","../src/control/attempt.ts","../src/control/result.ts"],"mappings":";;;;;;AAQA;;;;;UAAiB,EAAA;EAAA,SACN,EAAA;EAAA,SACA,KAAA,EAAO,CAAA;EAAA,SACP,KAAA;AAAA;;AAWX;;;;;;;UAAiB,GAAA;EAAA,SACN,EAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;KAcN,MAAA,MAAY,EAAA,CAAG,CAAA,IAAK,GAAA;;;;;AA/BhC;;;;;;;;;;;AAcA;;iBCJgB,OAAA,GAAA,CAAW,EAAA,QAAU,CAAA,GAAI,MAAA,CAAO,CAAA;;;;;;;;ADqBhD;;;;;;;;iBCEsB,YAAA,GAAA,CAAgB,EAAA,QAAU,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,MAAA,CAAO,CAAA;;;;;ADjC5E;;;;;;;;;;iBE6BgB,EAAA,GAAA,CAAM,KAAA,EAAO,CAAA,GAAI,EAAA,CAAG,CAAA;AFfpC;;;;;;;;;;AAiBA;;AAjBA,iBE+BgB,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;;;;;;;;;;;;;;;;;;;iBAsBvC,MAAA,GAAA,CAAU,MAAA,EAAQ,MAAA,CAAO,CAAA,GAAI,OAAA,YAAmB,CAAA"}
|
package/dist/pattern/index.d.mts
DELETED
package/dist/pattern/index.mjs
DELETED