functype 0.9.5 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Either-Dd58ar32.d.ts → Either-S0zzDKYx.d.ts} +147 -114
- package/dist/chunk-KCVLQDVX.mjs +43 -0
- package/dist/chunk-KCVLQDVX.mjs.map +1 -0
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +2 -2
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +1 -1
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +2 -2
- package/dist/try/index.mjs +1 -1
- package/package.json +26 -20
- package/readme/functype-changes-required.md +189 -0
- package/dist/chunk-6KFGLFLL.mjs +0 -43
- package/dist/chunk-6KFGLFLL.mjs.map +0 -1
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { E as Either, c as Left, R as Right, b as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../Either-
|
|
1
|
+
export { E as Either, c as Left, R as Right, b as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import '../Serializable-CK9upOU0.js';
|
package/dist/either/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{q as Either,j as Left,i as Right,o as TypeCheckLeft,n as TypeCheckRight,l as isLeft,k as isRight,m as tryCatch,p as tryCatchAsync}from'../chunk-
|
|
1
|
+
export{q as Either,j as Left,i as Right,o as TypeCheckLeft,n as TypeCheckRight,l as isLeft,k as isRight,m as tryCatch,p as tryCatchAsync}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/fpromise/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as Either } from '../Either-
|
|
1
|
+
import { E as Either } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import { T as Type } from '../Serializable-CK9upOU0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -202,7 +202,7 @@ type FPromise<T extends Type, E extends Type = unknown> = PromiseLike<T> & {
|
|
|
202
202
|
filterError: <E2 extends E>(predicate: (error: E) => boolean, handler: (error: E) => FPromise<T, E2>) => FPromise<T, E>;
|
|
203
203
|
logError: (logger: (error: E, context: ErrorContext) => void) => FPromise<T, E>;
|
|
204
204
|
toPromise: () => Promise<T>;
|
|
205
|
-
toEither: () => Promise<T
|
|
205
|
+
toEither: () => Promise<Either<E, T>>;
|
|
206
206
|
fold: <R extends Type>(onError: (error: E) => R, onSuccess: (value: T) => R) => FPromise<R, never>;
|
|
207
207
|
map: <U extends Type>(f: (value: T) => U) => FPromise<U, E>;
|
|
208
208
|
flatMap: <U extends Type>(f: (value: T) => FPromise<U, E> | PromiseLike<U>) => FPromise<U, E>;
|
package/dist/fpromise/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{K as FPromise,J as FPromiseCompanion}from'../chunk-
|
|
1
|
+
export{K as FPromise,J as FPromiseCompanion}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Brand } from './branded/index.js';
|
|
2
2
|
export { BrandedBoolean, BrandedNumber, BrandedString, ExtractBrand, Unbrand, createBrander, hasBrand, unbrand } from './branded/index.js';
|
|
3
|
-
import { O as Option, E as Either, L as List, F as FunctypeBase, a as Extractable, T as Traversable, M as Matchable } from './Either-
|
|
4
|
-
export { A as Applicative, q as AsyncMonad, C as Collection, o as CollectionOps, p as ContainerOps, r as Functor, j as Functype, k as FunctypeCollection, c as Left, l as MatchableUtils, s as Monad, N as None, m as OptionConstructor, R as Right, n as Set, S as Some, b as TestEither, f as TypeCheckLeft, e as TypeCheckRight, h as isExtractable, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './Either-
|
|
3
|
+
import { O as Option, E as Either, L as List, F as FunctypeBase, a as Extractable, T as Traversable, M as Matchable } from './Either-S0zzDKYx.js';
|
|
4
|
+
export { A as Applicative, q as AsyncMonad, C as Collection, o as CollectionOps, p as ContainerOps, r as Functor, j as Functype, k as FunctypeCollection, c as Left, l as MatchableUtils, s as Monad, N as None, m as OptionConstructor, P as Promisable, R as Right, n as Set, S as Some, b as TestEither, f as TypeCheckLeft, e as TypeCheckRight, h as isExtractable, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './Either-S0zzDKYx.js';
|
|
5
5
|
import { T as Type, a as Typeable, F as Foldable, P as Pipe, S as Serializable } from './Serializable-CK9upOU0.js';
|
|
6
6
|
export { E as ExtractTag, b as SerializationMethods, c as TypeableParams, i as isTypeable } from './Serializable-CK9upOU0.js';
|
|
7
7
|
import { FPromise } from './fpromise/index.js';
|
|
@@ -1544,7 +1544,7 @@ declare const Lazy: (<T extends Type>(thunk: () => T) => Lazy<T>) & {
|
|
|
1544
1544
|
* @param promise - The Promise to convert
|
|
1545
1545
|
* @returns A new Lazy instance that throws an error
|
|
1546
1546
|
*/
|
|
1547
|
-
fromPromise: <T extends Type>(
|
|
1547
|
+
fromPromise: <T extends Type>(_promise: Promise<T>) => Lazy<T>;
|
|
1548
1548
|
/**
|
|
1549
1549
|
* Creates a failed Lazy that will throw when evaluated
|
|
1550
1550
|
* @param error - The error to throw
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{G as Base,B as BoundedNumber,C as BoundedString,E as Cond,
|
|
1
|
+
export{G as Base,B as BoundedNumber,C as BoundedString,E as Cond,da as ESMap,q as Either,x as EmailAddress,K as FPromise,J as FPromiseCompanion,_ as FoldableUtils,$ as HKT,A as ISO8601Date,aa as Identity,u as IntegerNumber,ca as Lazy,X as LazyList,j as Left,h as List,ea as Map,F as Match,fa as MatchableUtils,H as NAME,w as NonEmptyString,t as NonNegativeNumber,b as None,d as Option,c as OptionConstructor,V as ParseError,D as PatternString,v as PositiveInteger,s as PositiveNumber,L as Ref,i as Right,e as Set,a as Some,ga as Stack,Q as Task,N as TaskException,O as TaskResult,I as Throwable,ba as Try,o as TypeCheckLeft,n as TypeCheckRight,f as Typeable,W as TypedError,z as UUID,y as UrlString,r as ValidatedBrand,Y as Validation,ha as Valuable,P as createCancellationTokenSource,U as createErrorSerializer,T as formatError,S as formatStackTrace,Z as isExtractable,l as isLeft,k as isRight,M as isTaggedThrowable,g as isTypeable,R as safeStringify,m as tryCatch,p as tryCatchAsync}from'./chunk-KCVLQDVX.mjs';export{a as Companion,b as Tuple}from'./chunk-BQJB6CCW.mjs';export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unbrand}from'./chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { L as List } from '../Either-
|
|
1
|
+
export { L as List } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import '../Serializable-CK9upOU0.js';
|
package/dist/list/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{h as List}from'../chunk-
|
|
1
|
+
export{h as List}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Traversable, C as Collection, O as Option } from '../Either-
|
|
1
|
+
import { T as Traversable, C as Collection, O as Option } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import { a as Typeable, S as Serializable, P as Pipe, F as Foldable, T as Type } from '../Serializable-CK9upOU0.js';
|
|
3
3
|
import { Tuple } from '../tuple/index.js';
|
|
4
4
|
|
package/dist/map/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{ea as Map}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as None, O as Option, m as OptionConstructor, S as Some } from '../Either-
|
|
1
|
+
export { N as None, O as Option, m as OptionConstructor, S as Some } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import '../Serializable-CK9upOU0.js';
|
package/dist/option/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as None,d as Option,c as OptionConstructor,a as Some}from'../chunk-
|
|
1
|
+
export{b as None,d as Option,c as OptionConstructor,a as Some}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { n as Set } from '../Either-
|
|
1
|
+
export { n as Set } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import '../Serializable-CK9upOU0.js';
|
package/dist/set/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{e as Set}from'../chunk-
|
|
1
|
+
export{e as Set}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { F as FunctypeBase, a as Extractable, E as Either } from '../Either-
|
|
1
|
+
import { F as FunctypeBase, a as Extractable, P as Promisable, E as Either } from '../Either-S0zzDKYx.js';
|
|
2
2
|
import { P as Pipe, T as Type } from '../Serializable-CK9upOU0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Possible types of Try instances
|
|
6
6
|
*/
|
|
7
7
|
type TypeNames = "Success" | "Failure";
|
|
8
|
-
interface Try<T> extends FunctypeBase<T, TypeNames>, Extractable<T>, Pipe<T> {
|
|
8
|
+
interface Try<T> extends FunctypeBase<T, TypeNames>, Extractable<T>, Pipe<T>, Promisable<T> {
|
|
9
9
|
readonly _tag: TypeNames;
|
|
10
10
|
readonly error: Error | undefined;
|
|
11
11
|
isSuccess: () => boolean;
|
package/dist/try/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{ba as Try}from'../chunk-KCVLQDVX.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-YBBRJTHY.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A smallish functional library for TypeScript",
|
|
6
6
|
"author": "jordan.burke@gmail.com",
|
|
@@ -12,29 +12,34 @@
|
|
|
12
12
|
"homepage": "https://github.com/jordanburke/functype#readme",
|
|
13
13
|
"url": "https://github.com/jordanburke/functype",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@eslint/compat": "^1.3.
|
|
15
|
+
"@eslint/compat": "^1.3.2",
|
|
16
16
|
"@eslint/eslintrc": "^3.3.1",
|
|
17
|
-
"@eslint/js": "^9.
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
17
|
+
"@eslint/js": "^9.33.0",
|
|
18
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
19
|
+
"@semantic-release/github": "^11.0.4",
|
|
20
|
+
"@semantic-release/npm": "^12.0.2",
|
|
21
|
+
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
22
|
+
"@types/node": "^22.17.2",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
24
|
+
"@typescript-eslint/parser": "^8.40.0",
|
|
21
25
|
"@vitest/coverage-v8": "^3.2.4",
|
|
22
26
|
"@vitest/ui": "^3.2.4",
|
|
23
27
|
"cross-env": "^10.0.0",
|
|
24
|
-
"eslint": "^9.
|
|
28
|
+
"eslint": "^9.33.0",
|
|
29
|
+
"eslint-config-functype": "1.3.0",
|
|
25
30
|
"eslint-config-prettier": "^10.1.8",
|
|
26
31
|
"eslint-plugin-functional": "^9.0.2",
|
|
27
|
-
"eslint-plugin-functype": "1.1.0",
|
|
28
32
|
"eslint-plugin-prettier": "^5.5.4",
|
|
29
33
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
30
34
|
"fast-check": "^4.2.0",
|
|
31
35
|
"globals": "^16.3.0",
|
|
32
36
|
"prettier": "^3.6.2",
|
|
33
37
|
"rimraf": "^6.0.1",
|
|
38
|
+
"semantic-release": "^24.2.7",
|
|
34
39
|
"ts-node": "^10.9.2",
|
|
35
40
|
"tsup": "^8.5.0",
|
|
36
|
-
"typedoc": "^0.28.
|
|
37
|
-
"typescript": "5.
|
|
41
|
+
"typedoc": "^0.28.10",
|
|
42
|
+
"typescript": "5.9.2",
|
|
38
43
|
"vitest": "^3.2.4"
|
|
39
44
|
},
|
|
40
45
|
"types": "./dist/index.d.ts",
|
|
@@ -139,24 +144,25 @@
|
|
|
139
144
|
},
|
|
140
145
|
"sideEffects": false,
|
|
141
146
|
"scripts": {
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"build:watch": "tsup --watch",
|
|
148
|
-
"lint:fix": "eslint ./src --quiet --fix",
|
|
149
|
-
"lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
|
|
150
|
-
"lint": "pnpm lint:format && pnpm lint:fix ",
|
|
147
|
+
"validate": "pnpm format && pnpm lint && pnpm test && pnpm build",
|
|
148
|
+
"format": "prettier --write .",
|
|
149
|
+
"format:check": "prettier --check .",
|
|
150
|
+
"lint": "eslint ./src --fix",
|
|
151
|
+
"lint:check": "eslint ./src",
|
|
151
152
|
"test": "vitest run",
|
|
152
153
|
"test:watch": "vitest",
|
|
153
154
|
"test:coverage": "vitest run --coverage",
|
|
154
155
|
"test:ui": "vitest --ui",
|
|
156
|
+
"build": "rimraf dist && cross-env NODE_ENV=production tsup",
|
|
157
|
+
"build:watch": "tsup --watch",
|
|
158
|
+
"dev": "tsup --watch",
|
|
159
|
+
"compile": "tsc --noEmit",
|
|
160
|
+
"clean": "rimraf dist",
|
|
155
161
|
"bench": "vitest bench",
|
|
156
162
|
"bench:ui": "vitest bench --ui",
|
|
157
163
|
"docs": "typedoc",
|
|
158
164
|
"docs:watch": "typedoc --watch",
|
|
159
165
|
"postdocs": "node -e \"console.log('Documentation generated in ./typedocs')\"",
|
|
160
|
-
"analyze:size": "pnpm build
|
|
166
|
+
"analyze:size": "pnpm build && node ./scripts/analyze-bundle-size.js"
|
|
161
167
|
}
|
|
162
168
|
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Required Changes to functype Library
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Remove `PromiseLike<R>` from `Either<L, R>` interface and fix `FPromise.toEither()` return type to create a cleaner, more predictable functional programming API.
|
|
6
|
+
|
|
7
|
+
## Changes Required
|
|
8
|
+
|
|
9
|
+
### 1. Remove PromiseLike from Either Interface
|
|
10
|
+
|
|
11
|
+
**File**: `Either-i_F6B_IB.d.ts` (or equivalent source file)
|
|
12
|
+
**Line**: ~582
|
|
13
|
+
|
|
14
|
+
**Current**:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
interface Either<L extends Type, R extends Type> extends FunctypeBase<R, "Left" | "Right">, PromiseLike<R> {
|
|
18
|
+
// ... rest of interface
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Change to**:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
interface Either<L extends Type, R extends Type> extends FunctypeBase<R, "Left" | "Right"> {
|
|
26
|
+
// ... rest of interface (no changes to methods)
|
|
27
|
+
// Remove: , PromiseLike<R>
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Fix FPromise.toEither Return Type
|
|
32
|
+
|
|
33
|
+
**File**: `fpromise/index.d.ts` (or equivalent source file)
|
|
34
|
+
**Line**: ~205
|
|
35
|
+
|
|
36
|
+
**Current**:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
type FPromise<T extends Type, E extends Type = unknown> = PromiseLike<T> & {
|
|
40
|
+
// ...
|
|
41
|
+
toEither: () => Promise<T> // ← This is wrong!
|
|
42
|
+
// ...
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Change to**:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
type FPromise<T extends Type, E extends Type = unknown> = PromiseLike<T> & {
|
|
50
|
+
// ...
|
|
51
|
+
toEither: () => Promise<Either<E, T>> // ← Correct return type
|
|
52
|
+
// ...
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3. Update Implementation (if needed)
|
|
57
|
+
|
|
58
|
+
If there's implementation code (not just type definitions), ensure:
|
|
59
|
+
|
|
60
|
+
1. **Either implementation**: Remove any Promise/thenable behavior
|
|
61
|
+
2. **FPromise.toEither implementation**: Actually return `Either<E, T>` wrapped in Promise
|
|
62
|
+
|
|
63
|
+
Example implementation for FPromise.toEither:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
toEither: async (): Promise<Either<E, T>> => {
|
|
67
|
+
try {
|
|
68
|
+
const value = await this.toPromise()
|
|
69
|
+
return Right<E, T>(value)
|
|
70
|
+
} catch (error) {
|
|
71
|
+
return Left<E, T>(error as E)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Impact Analysis
|
|
77
|
+
|
|
78
|
+
### Breaking Changes
|
|
79
|
+
|
|
80
|
+
- ✅ **Expected**: Code using `await either` will break (this is desired)
|
|
81
|
+
- ✅ **Expected**: Code relying on Either auto-unwrapping will break
|
|
82
|
+
|
|
83
|
+
### Non-Breaking
|
|
84
|
+
|
|
85
|
+
- ✅ **Safe**: All existing Either methods (`isLeft`, `isRight`, `get`, `fold`, etc.) remain unchanged
|
|
86
|
+
- ✅ **Safe**: FPromise behavior remains the same (still implements PromiseLike)
|
|
87
|
+
- ✅ **Safe**: Option and List interfaces unchanged
|
|
88
|
+
|
|
89
|
+
## Validation
|
|
90
|
+
|
|
91
|
+
After making these changes, the following should be true:
|
|
92
|
+
|
|
93
|
+
### TypeScript Compilation
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// This should compile (Either stays Either)
|
|
97
|
+
const either: Either<string, number> = Right(42)
|
|
98
|
+
const stillEither = either.map((x) => x * 2) // Either<string, number>
|
|
99
|
+
|
|
100
|
+
// This should NOT compile (no auto-unwrapping)
|
|
101
|
+
const result = await either // ← TypeScript error (good!)
|
|
102
|
+
|
|
103
|
+
// This should compile (explicit methods still work)
|
|
104
|
+
const value = either.get() // number
|
|
105
|
+
const folded = either.fold(
|
|
106
|
+
(err) => 0,
|
|
107
|
+
(val) => val,
|
|
108
|
+
) // number
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### FPromise Integration
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// This should work (FPromise still awaitable)
|
|
115
|
+
const fpromise: FPromise<string, Error> = FPromise.resolve("hello")
|
|
116
|
+
const result = await fpromise // string
|
|
117
|
+
|
|
118
|
+
// This should work (explicit Either extraction)
|
|
119
|
+
const either = await fpromise.toEither() // Either<Error, string>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Version Impact
|
|
123
|
+
|
|
124
|
+
This is a **major breaking change** and should increment the major version number of functype:
|
|
125
|
+
|
|
126
|
+
- Current: `0.9.4` → Proposed: `1.0.0`
|
|
127
|
+
- Or if already 1.x: `1.x.y` → `2.0.0`
|
|
128
|
+
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
Recommended tests to add/update:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
describe("Either without PromiseLike", () => {
|
|
135
|
+
it("should not be awaitable", async () => {
|
|
136
|
+
const either = Right<string, number>(42)
|
|
137
|
+
|
|
138
|
+
// This should be a TypeScript error
|
|
139
|
+
// const result = await either
|
|
140
|
+
|
|
141
|
+
// This should work
|
|
142
|
+
const result = either.get()
|
|
143
|
+
expect(result).toBe(42)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it("should still support all Either methods", () => {
|
|
147
|
+
const either = Right<string, number>(42)
|
|
148
|
+
|
|
149
|
+
expect(either.isRight()).toBe(true)
|
|
150
|
+
expect(either.isLeft()).toBe(false)
|
|
151
|
+
expect(either.get()).toBe(42)
|
|
152
|
+
|
|
153
|
+
const mapped = either.map((x) => x * 2)
|
|
154
|
+
expect(mapped.get()).toBe(84)
|
|
155
|
+
|
|
156
|
+
const folded = either.fold(
|
|
157
|
+
(err) => 0,
|
|
158
|
+
(val) => val,
|
|
159
|
+
)
|
|
160
|
+
expect(folded).toBe(42)
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
describe("FPromise.toEither", () => {
|
|
165
|
+
it("should return Promise<Either<E, T>>", async () => {
|
|
166
|
+
const fpromise = FPromise.resolve(42)
|
|
167
|
+
const either = await fpromise.toEither()
|
|
168
|
+
|
|
169
|
+
expect(either.isRight()).toBe(true)
|
|
170
|
+
expect(either.get()).toBe(42)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it("should handle errors properly", async () => {
|
|
174
|
+
const fpromise = FPromise.reject<number, string>("error")
|
|
175
|
+
const either = await fpromise.toEither()
|
|
176
|
+
|
|
177
|
+
expect(either.isLeft()).toBe(true)
|
|
178
|
+
expect(either.get()).toBe("error")
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Implementation Priority
|
|
184
|
+
|
|
185
|
+
1. **High Priority**: Remove PromiseLike from Either (core change)
|
|
186
|
+
2. **Medium Priority**: Fix FPromise.toEither return type (nice to have)
|
|
187
|
+
3. **Low Priority**: Add additional convenience methods if desired
|
|
188
|
+
|
|
189
|
+
The first change is the most critical for resolving the API confusion issues.
|
package/dist/chunk-6KFGLFLL.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {a,b as b$1}from'./chunk-BQJB6CCW.mjs';import {a as a$1}from'./chunk-YBBRJTHY.mjs';import se from'safe-stable-stringify';var J=Set;var P=e=>{let t=new J(e),r={_tag:"Set",[Symbol.iterator]:()=>t[Symbol.iterator](),add:n=>P([...t,n]),remove:n=>{let o=new J(t);return o.delete(n),P(o)},contains:n=>t.has(n),has:n=>t.has(n),map:n=>P(Array.from(t).map(n)),ap:n=>{let o=new J;for(let a of t)for(let s of n)o.add(s(a));return P(o)},flatMap:n=>{let o=new J;for(let a of t)for(let s of n(a))o.add(s);return P(o)},flatMapAsync:async n=>{let o=new J;for(let a of t){let s=await n(a);for(let i of s)o.add(i);}return P(o)},fold:(n,o)=>{if(t.size===0)return n();let a=Array.from(t);if(a.length===0)return n();let s=a[0];return s===void 0?n():o(s)},foldLeft:n=>o=>{let a=n;for(let s of t)a=o(a,s);return a},foldRight:n=>o=>Array.from(t).reduceRight((s,i)=>o(i,s),n),get size(){return t.size},get isEmpty(){return t.size===0},reduce:n=>{let o=Array.from(t);if(o.length===0)throw new Error("Cannot reduce empty Set");return o.reduce(n)},reduceRight:n=>{let o=Array.from(t);if(o.length===0)throw new Error("Cannot reduceRight empty Set");return o.reduceRight(n)},count:n=>{let o=0;for(let a of t)n(a)&&o++;return o},find:n=>{for(let o of t)if(n(o))return f(o);return f(null)},exists:n=>{for(let o of t)if(n(o))return true;return false},forEach:n=>{t.forEach(n);},filter:n=>{let o=new J;for(let a of t)n(a)&&o.add(a);return P(o)},filterNot:n=>{let o=new J;for(let a of t)n(a)||o.add(a);return P(o)},drop:n=>P(Array.from(t).slice(n)),dropRight:n=>P(Array.from(t).slice(0,-n)),dropWhile:n=>{let o=Array.from(t),a=o.findIndex(s=>!n(s));return P(a===-1?[]:o.slice(a))},flatten:()=>{let n=new J;for(let o of t)if(Array.isArray(o))for(let a of o)n.add(a);else if(o&&typeof o=="object"&&Symbol.iterator in o)for(let a of o)n.add(a);else n.add(o);return P(n)},get head(){return Array.from(t)[0]},get headOption(){let n=Array.from(t)[0];return f(n)},toList:()=>y(Array.from(t)),toSet:()=>r,toArray:()=>Array.from(t),toString:()=>`Set(${Array.from(t).toString()})`,toValue:()=>({_tag:"Set",value:Array.from(t)}),pipe:n=>n(Array.from(t)),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Set",value:Array.from(t)}),toYAML:()=>`_tag: Set
|
|
2
|
-
value: ${JSON.stringify(Array.from(t))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Set",value:Array.from(t)})).toString("base64")})};return r},qe=e=>P(e),we={fromJSON:e=>{let t=JSON.parse(e);return Q(t.value)},fromYAML:e=>{let r=e.split(`
|
|
3
|
-
`)[1]?.split(": ")[1];if(!r)return Q([]);let n=JSON.parse(r);return Q(n)},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return we.fromJSON(t)}},Q=a(qe,we);function ce({_tag:e,impl:t}){return {...t,_tag:e}}function me(e,t){return !e||typeof e!="object"||!("_tag"in e)?false:t?e._tag===t:true}var U=e=>{let t=Array.from(e||[]),r={_tag:"List",[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:n=>U(t.map(n)),ap:n=>U(t.flatMap(o=>Array.from(n).map(a=>a(o)))),flatMap:n=>U(t.flatMap(o=>Array.from(n(o)))),flatMapAsync:async n=>{let o=await Promise.all(t.map(async a=>await n(a)));return U(o.flatMap(a=>Array.from(a)))},forEach:n=>t.forEach(n),contains:n=>t.includes(n),count:n=>t.filter(n).length,exists:n=>t.some(n),filter:n=>U(t.filter(n)),filterNot:n=>U(t.filter(o=>!n(o))),filterType:n=>U(t.filter(o=>me(o,n))),find:(n,o)=>{let a=t.find(s=>n(s)&&(o?me(s,o):true));return f(a)},get head(){return t[0]},get headOption(){return t.length>0?f(t[0]):b()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:n=>t.reduce(n),reduceRight:n=>t.reduceRight(n),fold:(n,o)=>{if(t.length===0)return n();let a=t[0];return o(a)},foldLeft:n=>o=>t.reduce(o,n),foldRight:n=>o=>t.reduceRight((a,s)=>o(s,a),n),match:n=>t.length===0?n.Empty():n.NonEmpty([...t]),remove:n=>U(t.filter(o=>o!==n)),removeAt:n=>n<0||n>=t.length?r:U([...t.slice(0,n),...t.slice(n+1)]),add:n=>U([...t,n]),get:n=>f(t[n]),concat:n=>U([...t,...n.toArray()]),drop:n=>U(t.slice(n)),dropRight:n=>U(t.slice(0,-n)),dropWhile:n=>U(t.slice(t.findIndex(o=>!n(o)))),flatten:()=>U(t.flatMap(n=>Array.isArray(n)?n:[n])),toList:()=>r,toSet:()=>Q(t),toString:()=>`List(${se(t)})`,toValue:()=>({_tag:"List",value:t}),pipe:n=>n([...t]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"List",value:t}),toYAML:()=>`_tag: List
|
|
4
|
-
value: ${se(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"List",value:t})).toString("base64")})};return r},Ye=e=>U(e),Se={fromJSON:e=>{let t=JSON.parse(e);return y(t.value)},fromYAML:e=>{let r=e.split(`
|
|
5
|
-
`)[1]?.split(": ")[1];if(!r)return y([]);let n=JSON.parse(r);return y(n)},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return Se.fromJSON(t)}},y=a(Ye,Se);var Be=e=>({_tag:"Right",value:e,isLeft:()=>false,isRight:()=>true,get:()=>e,getOrElse:t=>e,getOrThrow:()=>e,orElse:t=>c(e),orNull:()=>e,orUndefined:()=>e,map:t=>c(t(e)),ap:t=>t._tag==="Right"?c(t.value(e)):p(t.value),mapAsync:t=>t(e).then(r=>c(r)).catch(r=>Promise.resolve(p(r))),merge:t=>t.isLeft()?p(t.value):c([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>p(r)),toOption:()=>w(e),toList:()=>y([e]),toJSON:function(){return {_tag:"Right",value:e}},toString:()=>`Right(${se(e)})`,[Symbol.iterator]:function*(){yield e;},yield:function*(){yield e;},traverse:t=>{let r=t(e);return r.isLeft()?p(r.value):c([r.value])},lazyMap:function*(t){yield c(t(e));},tap:t=>(t(e),c(e)),tapLeft:t=>c(e),mapLeft:t=>c(e),bimap:(t,r)=>c(r(e)),fold:(t,r)=>r(e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),match:t=>t.Right(e),swap:()=>p(e),then:(t,r)=>Promise.resolve(e).then(t,r),toValue:()=>({_tag:"Right",value:e}),pipeEither:(t,r)=>r(e),pipe:t=>t(e),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Right",value:e}),toYAML:()=>`_tag: Right
|
|
6
|
-
value: ${se(e)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Right",value:e})).toString("base64")}),get size(){return 1},get isEmpty(){return false},contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>t(e)?1:0,find:t=>t(e)?w(e):b(),exists:t=>t(e),forEach:t=>t(e)}),Oe=e=>({_tag:"Left",value:e,isLeft:()=>true,isRight:()=>false,get:()=>{throw new Error(`Cannot call get() on Left(${se(e)})`)},getOrElse:t=>t,getOrThrow:t=>{throw t||e},orElse:t=>t,orNull:()=>null,orUndefined:()=>{},map:t=>p(e),ap:t=>p(e),mapAsync:t=>Promise.resolve(p(e)),merge:t=>p(e),flatMap:t=>p(e),flatMapAsync:t=>Promise.resolve(p(e)),toOption:()=>b(),toList:()=>y(),toJSON:function(){return {_tag:"Left",value:e}},toString:()=>`Left(${se(e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>p(e),lazyMap:function*(t){yield p(e);},tap:t=>p(e),tapLeft:t=>(t(e),p(e)),mapLeft:t=>p(t(e)),bimap:(t,r)=>p(t(e)),fold:(t,r)=>t(e),foldLeft:t=>r=>t,foldRight:t=>r=>t,match:t=>t.Left(e),swap:()=>c(e),then:(t,r)=>Promise.reject(e).then(null,r),toValue:()=>({_tag:"Left",value:e}),pipeEither:(t,r)=>t(e),pipe:t=>t(e),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Left",value:e}),toYAML:()=>`_tag: Left
|
|
7
|
-
value: ${se(e)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Left",value:e})).toString("base64")}),get size(){return 0},get isEmpty(){return true},contains:t=>false,reduce:t=>{throw new Error("Cannot reduce a Left")},reduceRight:t=>{throw new Error("Cannot reduceRight a Left")},count:t=>0,find:t=>b(),exists:t=>false,forEach:t=>{}}),c=e=>Be(e),p=e=>Oe(e),Nt=e=>e.isRight(),_t=e=>e.isLeft(),It=(e,t)=>{try{return c(e())}catch(r){return p(t(r))}},Qe=e=>Be(e);console.assert(Qe);var He=e=>Oe(e);console.assert(He);var Mt=async(e,t)=>{try{let r=await e();return c(r)}catch(r){return p(t(r))}},ve={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return p(r.value);t.push(r.value);}return c(t)},traverse:(e,t)=>ve.sequence(e.map(t)),fromNullable:(e,t)=>e==null?p(t):c(e),fromPredicate:(e,t,r)=>t(e)?c(e):p(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return c(r)}catch(r){return p(t(r))}},fromJSON:e=>{let t=JSON.parse(e);return t._tag==="Right"?c(t.value):p(t.value)},fromYAML:e=>{let t=e.split(`
|
|
8
|
-
`),r=t[0]?.split(": ")[1],n=t[1]?.split(": ")[1];if(!r||!n)throw new Error("Invalid YAML format for Either");let o=JSON.parse(n);return r==="Right"?c(o):p(o)},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return ve.fromJSON(t)}};function I(e,t){return {brand:e,validate:t,of:r=>t(r)?f(a$1(e,r)):f.none(),from:r=>t(r)?c(a$1(e,r)):p(`Invalid ${e}: validation failed`),unsafeOf:r=>{if(!t(r))throw new Error(`Invalid ${e}: validation failed`);return a$1(e,r)},is:r=>{try{return t(r)}catch{return false}},unwrap:r=>r,refine:(r,n)=>I(r,o=>t(o)&&n(o))}}var Ge=I("PositiveNumber",e=>e>0),Kt=I("NonNegativeNumber",e=>e>=0),$t=I("IntegerNumber",e=>Number.isInteger(e)),Dt=Ge.refine("PositiveInteger",e=>Number.isInteger(e)),Jt=I("NonEmptyString",e=>e.length>0),Wt=I("EmailAddress",e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),jt=I("UrlString",e=>{try{return new URL(e),!0}catch{return !1}}),qt=I("UUID",e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),Yt=I("ISO8601Date",e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function Qt(e,t,r){return I(e,n=>n>=t&&n<=r)}function Ht(e,t,r){return I(e,n=>n.length>=t&&n.length<=r)}function Gt(e,t){return I(e,r=>t.test(r))}var ye=e=>{let t=n=>typeof n=="function"?n():n,r={when:(n,o)=>e.resolved?r:n?ye({resolved:true,value:t(o)}):r,elseWhen:(n,o)=>e.resolved?r:n?ye({resolved:true,value:t(o)}):r,else:n=>e.resolved?e.value:t(n),getOrThrow:()=>{if(!e.resolved)throw new Error("Conditional expression has no matching condition");return e.value}};return r},Pe=()=>ye({resolved:false}),Ze={of:()=>Pe(),match:e=>t=>{let r=t[e];if(r===void 0)throw new Error(`No case defined for value: ${String(e)}`);return typeof r=="function"?r():r},lazy:()=>{let e={resolved:false},t={when:(r,n)=>(e.resolved||r()&&(e.resolved=true,e.value=n()),t),elseWhen:(r,n)=>(e.resolved||r()&&(e.resolved=true,e.value=n()),t),else:r=>e.resolved?e.value:r()};return t}},er=a(Pe,Ze);var ee=(e,t)=>t===e?true:typeof t=="function"?t(e):t&&typeof t=="object"&&"_"in t?t._(e):typeof t=="object"&&t!==null&&typeof e=="object"&&e!==null?Object.entries(t).every(([r,n])=>{let o=e[r];return ee(o,n)}):false,H=e=>{let t=(o,a)=>typeof o=="function"?o(a):o,r=()=>{for(let{pattern:o,result:a}of e.patterns)if(ee(e.value,o))return {matched:true,result:t(a,e.value)};return {matched:false}},n={case:(o,a)=>{if(e.resolved)return n;let s={...e,patterns:[...e.patterns,{pattern:o,result:a}]};return ee(e.value,o)?H({...s,resolved:true,result:t(a,e.value)}):H(s)},caseValue:(o,a)=>{if(e.resolved)return n;if(e.value===o){let s=typeof a=="function"?a():a;return H({...e,resolved:true,result:s})}return n},caseValues:(o,a)=>{if(e.resolved)return n;if(o.includes(e.value)){let s=typeof a=="function"?a():a;return H({...e,resolved:true,result:s})}return n},when:(o,a)=>n.case(o,a),caseAny:(o,a)=>{if(e.resolved)return n;for(let s of o)if(ee(e.value,s))return H({...e,resolved:true,result:t(a,e.value),patterns:[...e.patterns,{pattern:s,result:a}]});return H({...e,patterns:[...e.patterns,...o.map(s=>({pattern:s,result:a}))]})},default:o=>e.resolved?e.result:t(o,e.value),exhaustive:()=>{let o=r();if(!o.matched)throw new Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return o.result},getOrThrow:o=>{let a=r();if(!a.matched)throw new Error(o||`No matching pattern for value: ${JSON.stringify(e.value)}`);return a.result},toOption:()=>{let o=r();return o.matched?f(o.result):f.none()}};return n},Xe=e=>H({value:e,resolved:false,patterns:[]}),et={exhaustive:e=>t=>{let r=e[t];if(r===void 0)throw new Error(`No case defined for value: ${String(t)}`);return r},partial:e=>({withDefault:t=>r=>{let n=e[r];return n!==void 0?typeof n=="function"?n(r):n:typeof t=="function"?t(r):t}}),withGuards:e=>({withDefault:t=>r=>{for(let[n,o]of e)if(n(r))return typeof o=="function"?o(r):o;return typeof t=="function"?t(r):t}}),struct:()=>{let e=[],t={case:(r,n)=>(e.push({pattern:r,handler:n}),t),build:()=>r=>{for(let{pattern:n,handler:o}of e)if(ee(r,n))return o(r);throw new Error(`No matching pattern for value: ${JSON.stringify(r)}`)}};return t},builder:()=>{let e=[],t,r={case:(n,o)=>(e.push({pattern:n,result:o}),r),when:(n,o)=>(e.push({pattern:n,result:o}),r),default:n=>(t=n,{build:()=>o=>{for(let{pattern:a,result:s}of e)if(ee(o,a))return typeof s=="function"?s(o):s;if(t!==void 0)return typeof t=="function"?t(o):t;throw new Error(`No matching pattern for value: ${JSON.stringify(o)}`)}})};return r}},or=a(Xe,et);function te(e,t){return {...ce({_tag:e,impl:t}),toString(){return `${e}()`}}}var Te="Throwable",L=class e extends Error{constructor(r,n){super(r,{cause:n?.cause});this._tag=Te;this.name=n?.taskInfo?.name||Te,Object.defineProperties(this,{_tag:{value:Te,writable:false,configurable:false},data:{value:n?.data,writable:false,configurable:false},taskInfo:{value:n?.taskInfo,writable:false,configurable:false},name:{value:n?.taskInfo?.name||Te,writable:false,configurable:false}}),n?.cause&&Object.defineProperty(this,"cause",{value:n.cause,writable:false,configurable:false}),n?.stack?this.stack=n.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}static apply(r,n,o){if(r instanceof Error){let u=new e(r.message,{data:n,cause:r.cause||void 0,stack:r.stack||void 0,taskInfo:o});for(let l of Object.keys(r))l in u||(u[l]=r[l]);return u}if(r&&typeof r=="object"){let u=r,l=typeof u.message=="string"?u.message:typeof u.error=="string"?u.error:`Object error: ${JSON.stringify(u,Object.getOwnPropertyNames(u).filter(g=>u[g]!==void 0))}`,E=new e(l,{data:n||u,taskInfo:o});for(let g of Object.keys(u))g in E||(E[g]=u[g]);return E}if(typeof r=="function"){let u=r.name||"anonymous function",l=r.toString().substring(0,100)+(r.toString().length>100?"...":"");return new e(`Function error: ${u}`,{data:n||{functionType:typeof r,functionName:u,functionString:l},taskInfo:o})}let a=typeof r,s=r===null?"null":r===void 0?"undefined":String(r);if(a==="number"){let u=r,l=Number.isNaN(u)?"Number error: NaN":Number.isFinite(u)?`Number error: ${u}`:`Number error: ${u>0?"Infinity":"-Infinity"}`;return new e(l,{data:n||{errorType:a,errorValue:u,originalError:r},taskInfo:o})}if(a==="bigint")return new e(`BigInt error: ${r}n`,{data:n||{errorType:a,errorValue:String(r),originalError:r},taskInfo:o});if(a==="boolean")return new e(`Boolean error: ${r}`,{data:n||{errorType:a,errorValue:r,originalError:r},taskInfo:o});if(a==="symbol"){let u=r.description||"unnamed symbol";return new e(`Symbol error: Symbol(${u})`,{data:n||{errorType:a,symbolDescription:u,originalError:r},taskInfo:o})}let i=typeof r=="string"?r:`${a.charAt(0).toUpperCase()+a.slice(1)} error: ${s}`;return new e(i,{data:n||{errorType:a,errorValue:s,originalError:r},taskInfo:o})}};var R=e=>{let t=new Promise((r,n)=>{try{e(r,n);}catch(o){n(o);}});return {_tag:"FPromise",map:r=>R((n,o)=>{t.then(a=>{try{n(r(a));}catch(s){o(s);}}).catch(o);}),flatMap:r=>R((n,o)=>{t.then(a=>{try{let s=r(a);"_tag"in s&&s._tag==="FPromise"?s.then(n,o):Promise.resolve(s).then(n,o);}catch(s){o(s);}}).catch(o);}),flatMapAsync:async r=>{let n=await t,o=r(n);return o instanceof Promise?o:new Promise((a,s)=>{o.then(a,s);})},tap:r=>R((n,o)=>{t.then(a=>{try{r(a),n(a);}catch(s){o(s);}}).catch(o);}),mapError:r=>R((n,o)=>{t.then(n).catch(a=>{try{let s={originalError:a,stack:a instanceof Error?a.stack:void 0,timestamp:Date.now()};o(r(a,s));}catch(s){o(s);}});}),tapError:r=>R((n,o)=>{t.then(n).catch(a=>{try{r(a),o(a);}catch(s){o(s);}});}),recover:r=>R(n=>{t.then(n).catch(()=>n(r));}),recoverWith:r=>R(n=>{t.then(n).catch(o=>{try{n(r(o));}catch{n(null);}});}),recoverWithF:r=>R((n,o)=>{t.then(n).catch(a=>{try{r(a).then(n,o);}catch(s){o(s);}});}),filterError:(r,n)=>R((o,a)=>{t.then(o).catch(s=>{if(r(s))try{n(s).then(o,a);}catch(i){a(i);}else a(s);});}),logError:r=>R((n,o)=>{t.then(n).catch(a=>{try{let s={originalError:a,stack:a instanceof Error?a.stack:void 0,timestamp:Date.now()};r(a,s);}catch{}finally{o(a);}});}),then:(r,n)=>t.then(r,n),toPromise:()=>t,toEither:()=>t,fold:(r,n)=>R((o,a)=>{t.then(s=>{try{o(n(s));}catch(i){a(i);}}).catch(s=>{try{o(r(s));}catch(i){a(i);}});})}},tt={resolve:e=>R(t=>t(e)),reject:e=>R((t,r)=>r(e)),from:e=>R((t,r)=>{e.then(t).catch(r);}),fromEither:e=>e.isRight()?R(t=>t(e.value)):R((t,r)=>r(e.value)),all:e=>R((t,r)=>{Promise.all(e.map(n=>n instanceof Promise?n:Promise.resolve(n))).then(t).catch(r);}),allSettled:e=>R(t=>{let r=[],n=0;if(e.length===0){t([]);return}e.forEach((o,a)=>{Promise.resolve(o).then(s=>{r[a]=c(s),n++,n===e.length&&t(r);}).catch(s=>{r[a]=p(s),n++,n===e.length&&t(r);});});}),race:e=>R((t,r)=>{Promise.race(e).then(t,r);}),any:e=>R((t,r)=>{if(typeof Promise.any=="function")Promise.any(e).then(t,r);else {let n=0,o=[];if(e.length===0){r(new AggregateError([],"All promises were rejected"));return}e.forEach((a,s)=>{Promise.resolve(a).then(t).catch(i=>{o[s]=i,n++,n===e.length&&r(new AggregateError(o,"All promises were rejected"));});});}}),retryWithBackoff:(e,t)=>{let{maxRetries:r,baseDelay:n=100,shouldRetry:o=()=>true}=t;return R((a,s)=>{let i=0,u=()=>{e().toPromise().then(a).catch(l=>{if(i++,i<=r&&o(l,i)){let E=n*Math.pow(2,i-1);setTimeout(u,E);}else s(l);});};u();})}},ge=a(R,tt);function rt(e){return e instanceof Error&&typeof e=="object"&&true&&e._tag==="Throwable"}var Ne=(e,t,r)=>{let n=r?.name||"TaskException",o=r?.description||"Unspecified TaskException",a={name:n,description:o},s=L.apply(e,t,a);return {...te("TaskException",p(s)),_task:a}},_e=(e,t)=>{let r=t?.name||"TaskResult",n=t?.description||"Unspecified TaskResult";return {...te("TaskResult",c(e)),_task:{name:r,description:n}}},Ee=()=>{let e=new AbortController,t=[];return {token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.push(n);}},cancel(){e.signal.aborted||(e.abort(),t.forEach(n=>{try{n();}catch(o){console.error("Error in cancellation callback:",o);}}));}}},nt=e=>{let t=e?.name||"Task",r=e?.description||"",n={Async:(o,a=u=>u,s=()=>{},i)=>ge(async(u,l)=>{let E=false,g=null,C=()=>{};if(i){if(i.isCancelled){try{await s();}catch(A){l(L.apply(A,void 0,{name:t,description:r}));return}l(L.apply(new Error("Task was cancelled before execution started"),void 0,{name:t,description:r}));return}let v=()=>{E=true,g=new Error("Task was cancelled during execution");};i.onCancel(v),C=()=>{};}try{let v=await o();if(E){try{await s();}catch(A){l(L.apply(A,void 0,{name:t,description:r}));return}l(g?L.apply(g,void 0,{name:t,description:r}):L.apply(new Error("Task was cancelled during execution"),void 0,{name:t,description:r}));return}try{await s();}catch(A){l(L.apply(A,void 0,{name:t,description:r}));return}u(v);}catch(v){if(E){try{await s();}catch(A){l(L.apply(A,void 0,{name:t,description:r}));return}l(g?L.apply(g,void 0,{name:t,description:r}):L.apply(new Error("Task was cancelled during execution"),void 0,{name:t,description:r}));return}try{await s();}catch(A){l(L.apply(A,void 0,{name:t,description:r}));return}try{if(v instanceof Error&&rt(v)){let A=new Error(`${t}: ${v.message}`),G=L.apply(A,void 0,{name:t,description:r});Object.defineProperty(G,"cause",{value:v,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{a(v);}catch(j){console.error("Error in error handler:",j);}}),l(G);}else {let A=await a(v);l(L.apply(A,void 0,{name:t,description:r}));}}catch(A){l(L.apply(A,void 0,{name:t,description:r}));}}finally{C();}}),Sync:(o,a=i=>i,s=()=>{})=>{try{return _e(o(),{name:t,description:r})}catch(i){return Ne(a(i),void 0,{name:t,description:r})}finally{s();}},AsyncWithProgress:(o,a,s=l=>l,i=()=>{},u)=>{let l=E=>{let g=Math.max(0,Math.min(100,E));g<=100&&a(g);};return n.Async(()=>o(l),s,i,u)}};return {...te("Task",n),_type:"Task"}},Ie={success:(e,t)=>_e(e,t),fail:(e,t,r)=>Ne(e,t,r),getErrorChain:e=>{if(!e)return [];let t=[e],r=e;for(;r&&r.cause;){let n=r.cause;if(n)t.push(n),r=n;else break;if(t.length>100)break}return t},formatErrorChain:(e,t)=>{let r=Ie.getErrorChain(e),n=t?.separator||`
|
|
9
|
-
`;return r.map((o,a)=>{if(!o)return `${a>0?"\u21B3 ":""}Unknown error`;let s=o.taskInfo,i=t?.includeTasks&&s?.name?`[${s.name}] `:"",u=o.message||"No message",l=`${a>0?"\u21B3 ":""}${i}${u}`;return t?.includeStackTrace&&o.stack&&(l+=`
|
|
10
|
-
${o.stack.split(`
|
|
11
|
-
`).slice(1).join(`
|
|
12
|
-
`)}`),l}).join(n)},fromPromise:(e,t)=>(...r)=>z(t||{name:"PromiseTask",description:"Task from Promise"}).Async(()=>e(...r),o=>o),toPromise:e=>new Promise((t,r)=>{e.isRight()?t(e.value):r(e.value);}),race:(e,t,r)=>{let n=r?.name||"TaskRace",o=r?.description||"Race between multiple tasks";return z({name:n,description:o}).Async(async()=>{let s=[...e],i;if(typeof t=="number"&&t>0){let u=ge((l,E)=>{i=setTimeout(()=>{E(new Error(`Task race timed out after ${t}ms`));},t);});s.push(u);}try{return await new Promise((u,l)=>{s.forEach(E=>{E.then(g=>u(g),g=>l(g));});})}finally{i&&clearTimeout(i);}},s=>s)},fromNodeCallback:(e,t)=>{let r=t?.name||"NodeCallbackTask",n=t?.description||"Task from Node.js callback function",o={name:r,description:n};return (...a)=>z(o).Async(()=>new Promise((s,i)=>{try{e(...a,(u,l)=>{u?i(u):s(l);});}catch(u){i(u);}}),s=>s)},createCancellationTokenSource:Ee,cancellable:(e,t)=>{let r=Ee();return {task:z(t).Async(()=>e(r.token),o=>o,()=>{},r.token),cancel:()=>r.cancel()}},withProgress:(e,t=()=>{},r)=>{let n=Ee(),o=0,a=i=>{o=Math.max(0,Math.min(100,i)),t(o);};return {task:z(r).Async(()=>e(a,n.token),i=>i,()=>{},n.token),cancel:()=>n.cancel(),currentProgress:()=>o}}},z=a(nt,Ie);var Me={includeTasks:true,includeStackTrace:false,separator:`
|
|
13
|
-
`,includeData:false,maxStackFrames:3,title:"Error",colors:false};function Ve(e){let t=new WeakSet;return JSON.stringify(e,(r,n)=>{if(typeof n=="bigint")return n.toString()+"n";if(typeof n=="object"&&n!==null){if(t.has(n))return "[Circular Reference]";t.add(n);}return r==="stack"&&typeof n=="string"?fe(n):n},2)}function fe(e){if(!e)return "";if(!e)return e;let t=e.split(`
|
|
14
|
-
`),r=t[0],n=t.slice(1).map(o=>o.trim());return [r,...n].join(`
|
|
15
|
-
`)}function Ar(e,t){let r={...Me,...t},n=e instanceof Error?e:L.apply(e),o=z?.getErrorChain?z.getErrorChain(n):[n],a=r.colors?`\x1B[31m${r.title}:\x1B[0m ${n.message}`:`${r.title}: ${n.message}`,s=o.map((u,l)=>{let E=" ".repeat(l),g=l>0?"\u21B3 ":"",C=u.taskInfo,v=r.includeTasks&&C?.name?r.colors?`\x1B[36m[${C.name}]\x1B[0m `:`[${C.name}] `:"",A=`${E}${g}${v}${u.message}`;if(r.includeStackTrace&&u.stack){let j=fe(u.stack).split(`
|
|
16
|
-
`).slice(1),Z=r.maxStackFrames??Me.maxStackFrames??3,ue=j.slice(0,Z).map(le=>`${E} ${r.colors?"\x1B[90m":""}${le}${r.colors?"\x1B[0m":""}`).join(`
|
|
17
|
-
`);A+=`
|
|
18
|
-
${ue}`,j.length>Z&&(A+=`
|
|
19
|
-
${E} ${r.colors?"\x1B[90m":""}...${j.length-Z} more stack frames${r.colors?"\x1B[0m":""}`);}return A}).join(r.separator),i=`${a}
|
|
20
|
-
|
|
21
|
-
${s}`;if(r.includeData){let u=n.data;if(u){let l=r.colors?`
|
|
22
|
-
|
|
23
|
-
\x1B[33mContext:\x1B[0m
|
|
24
|
-
${Ve(u)}`:`
|
|
25
|
-
|
|
26
|
-
Context:
|
|
27
|
-
${Ve(u)}`;i+=l;}}return i}function Rr(){return function(t){if(!t)return t;let r=t instanceof Error?t:new Error(String(t)),n={message:r.message,name:r.name||"Error",stack:r.stack?fe(r.stack):void 0};if(r.taskInfo&&(n.taskInfo=r.taskInfo),r.data&&(n.data=r.data),typeof z?.getErrorChain=="function")try{let o=z.getErrorChain(r);o.length>1&&(n.errorChain=z.formatErrorChain(r,{includeTasks:!0}),n.structuredErrorChain=o.map(a=>({message:a.message,name:a.name,taskInfo:a.taskInfo,stack:a.stack?fe(a.stack):void 0})));}catch{}return Object.getOwnPropertyNames(r).forEach(o=>{if(!n[o]){let a=r[o];n[o]=a;}}),n}}var xr=e=>{let t=new Error(e);return t.name="ParseError",t};var F=(e,t,r,n)=>{let o=L.apply(t,r,{name:e,description:t});return Object.assign(o,{code:e,message:t,status:ot(e),context:r,timestamp:new Date().toISOString(),traceId:n?.traceId})},ot=e=>({VALIDATION_FAILED:400,BAD_REQUEST:400,AUTH_REQUIRED:401,PERMISSION_DENIED:403,NOT_FOUND:404,TIMEOUT:408,CONFLICT:409,RATE_LIMITED:429,INTERNAL_ERROR:500,NETWORK_ERROR:503})[e],at={validation:(e,t,r)=>F("VALIDATION_FAILED",`Validation failed: ${e} ${r}`,{field:e,value:t,rule:r}),network:(e,t,r)=>F("NETWORK_ERROR",`Network error: ${t} ${e}${r?` (${r})`:""}`,{url:e,method:t,statusCode:r}),auth:(e,t)=>F("AUTH_REQUIRED",`Authentication required: ${e}${t?` (role: ${t})`:""}`,{resource:e,requiredRole:t}),notFound:(e,t)=>F("NOT_FOUND",`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,r)=>F("PERMISSION_DENIED",`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:r}),rateLimit:(e,t,r)=>F("RATE_LIMITED",`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:r}),internal:e=>F("INTERNAL_ERROR",`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>F("BAD_REQUEST",`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>F("CONFLICT",`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>F("TIMEOUT",`Request timeout: ${t} exceeded ${e}ms`,{duration:e,operation:t}),isTypedError:e=>typeof e=="object"&&e!==null&&"code"in e&&"message"in e&&"status"in e&&"context"in e&&"_tag"in e&&e._tag==="Throwable",hasCode:(e,t)=>e.code===t},x=Object.assign(F,at);var k=e=>{let t={_tag:"LazyList",[Symbol.iterator]:()=>e[Symbol.iterator](),map:r=>k(function*(){for(let n of e)yield r(n);}()),flatMap:r=>k(function*(){for(let n of e)yield*r(n);}()),filter:r=>k(function*(){for(let n of e)r(n)&&(yield n);}()),take:r=>k(function*(){let n=0;for(let o of e){if(n>=r)break;yield o,n++;}}()),drop:r=>k(function*(){let n=0;for(let o of e)n>=r&&(yield o),n++;}()),takeWhile:r=>k(function*(){for(let n of e){if(!r(n))break;yield n;}}()),dropWhile:r=>k(function*(){let n=true;for(let o of e)n&&r(o)||(n=false,yield o);}()),concat:r=>k(function*(){yield*e,yield*r;}()),zip:r=>k(function*(){let n=e[Symbol.iterator](),o=r[Symbol.iterator]();for(;;){let a=n.next(),s=o.next();if(a.done||s.done)break;yield [a.value,s.value];}}()),toList:()=>y(Array.from(e)),toArray:()=>Array.from(e),forEach:r=>{for(let n of e)r(n);},reduce:(r,n)=>{let o=n;for(let a of e)o=r(o,a);return o},find:r=>{for(let n of e)if(r(n))return f(n);return f.none()},some:r=>{for(let n of e)if(r(n))return true;return false},every:r=>{for(let n of e)if(!r(n))return false;return true},count:()=>{let r=0;for(let n of e)r++;return r},first:()=>{let n=e[Symbol.iterator]().next();return n.done?f.none():f(n.value)},last:()=>{let r,n=false;for(let o of e)r=o,n=true;return n?f(r):f.none()},fold:(r,n)=>{let a=e[Symbol.iterator]().next();return a.done?r():n(a.value)},foldLeft:r=>n=>{let o=r;for(let a of e)o=n(o,a);return o},foldRight:r=>n=>Array.from(e).reduceRight((a,s)=>n(s,a),r),pipe:r=>r(t),serialize:()=>{let r=Array.from(e);return {toJSON:()=>JSON.stringify({_tag:"LazyList",value:r}),toYAML:()=>`_tag: LazyList
|
|
28
|
-
value: ${se(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"LazyList",value:r})).toString("base64")}},toString:()=>{let n=[],o=0,a=false;for(let i of e)if(o<10)n.push(i),o++;else {a=true;break}let s=n.map(i=>String(i)).join(", ");return a?`LazyList(${s}, ...)`:`LazyList(${s})`}};return t},it=e=>k(e),ut={empty:()=>k([]),of:e=>k([e]),from:(...e)=>k(e),iterate:(e,t)=>k(function*(){let r=e;for(;;)yield r,r=t(r);}()),generate:e=>k(function*(){for(;;)yield e();}()),range:(e,t,r=1)=>k(function*(){if(r===0)throw new Error("Step cannot be zero");if(r>0)for(let n=e;n<t;n+=r)yield n;else for(let n=e;n>t;n+=r)yield n;}()),repeat:(e,t)=>k(function*(){if(t===void 0)for(;;)yield e;else for(let r=0;r<t;r++)yield e;}()),cycle:e=>k(function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t;}())},Or=a(it,ut);var N={rule:e=>t=>{if(e==="email")return typeof t!="string"||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?p(x.validation("value",t,"must be a valid email")):c(t);if(e==="url")try{return new URL(String(t)),c(t)}catch{return p(x.validation("value",t,"must be a valid URL"))}if(e==="uuid")return typeof t!="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)?p(x.validation("value",t,"must be a valid UUID")):c(t);if(e==="required")return t==null||t===""?p(x.validation("value",t,"is required")):c(t);if(e==="numeric")return typeof t!="number"&&!/^\d+$/.test(String(t))?p(x.validation("value",t,"must be numeric")):c(t);if(e==="alpha")return typeof t!="string"||!/^[a-zA-Z]+$/.test(t)?p(x.validation("value",t,"must contain only letters")):c(t);if(e==="alphanumeric")return typeof t!="string"||!/^[a-zA-Z0-9]+$/.test(t)?p(x.validation("value",t,"must be alphanumeric")):c(t);if(e.startsWith("min:")){let r=Number(e.split(":")[1]),n=Number(t);return isNaN(n)||n<r?p(x.validation("value",t,`must be at least ${r}`)):c(t)}if(e.startsWith("max:")){let r=Number(e.split(":")[1]),n=Number(t);return isNaN(n)||n>r?p(x.validation("value",t,`must be at most ${r}`)):c(t)}if(e.startsWith("minLength:")){let r=Number(e.split(":")[1]);return String(t).length<r?p(x.validation("value",t,`must be at least ${r} characters`)):c(t)}if(e.startsWith("maxLength:")){let r=Number(e.split(":")[1]);return String(t).length>r?p(x.validation("value",t,`must be at most ${r} characters`)):c(t)}if(e.startsWith("pattern:")){let r=e.substring(8);return new RegExp(r).test(String(t))?c(t):p(x.validation("value",t,`must match pattern ${r}`))}if(e.startsWith("in:")){let r=e.substring(3).split(",");return r.includes(String(t))?c(t):p(x.validation("value",t,`must be one of: ${r.join(", ")}`))}if(e.startsWith("notIn:")){let r=e.substring(6).split(",");return r.includes(String(t))?p(x.validation("value",t,`must not be one of: ${r.join(", ")}`)):c(t)}if(e==="date"){let r=new Date(String(t));return isNaN(r.getTime())?p(x.validation("value",t,"must be a valid date")):c(t)}if(e==="future"){let r=new Date(String(t));return isNaN(r.getTime())||r<=new Date?p(x.validation("value",t,"must be a future date")):c(t)}if(e==="past"){let r=new Date(String(t));return isNaN(r.getTime())||r>=new Date?p(x.validation("value",t,"must be a past date")):c(t)}return c(t)},combine:(...e)=>t=>{for(let r of e){let n=r(t);if(n.isLeft())return n}return c(t)},custom:(e,t)=>r=>e(r)?c(r):p(x.validation("value",r,t)),form:(e,t)=>{let r=[],n={};for(let[o,a]of Object.entries(e)){let s=t[o],i=a(s);if(i.isLeft()){let u=i.fold(E=>E,()=>{throw new Error("Should not be left")}),l=x.validation(o,s,u.context.rule);r.push(l);}else n[o]=i.get();}return r.length>0?p(y(r)):c(n)}},lt={...N,validators:{email:N.rule("email"),url:N.rule("url"),uuid:N.rule("uuid"),required:N.rule("required"),numeric:N.rule("numeric"),positiveNumber:N.combine(N.rule("numeric"),N.rule("min:0")),nonEmptyString:N.combine(N.rule("required"),N.custom(e=>typeof e=="string"&&e.trim().length>0,"must not be empty"))}},Mr=Object.assign(N.rule,lt);function pt(e){return e!=null&&typeof e=="object"&&"getOrElse"in e&&typeof e.getOrElse=="function"&&"getOrThrow"in e&&typeof e.getOrThrow=="function"&&"get"in e&&typeof e.get=="function"&&"orElse"in e&&typeof e.orElse=="function"&&"orNull"in e&&typeof e.orNull=="function"&&"orUndefined"in e&&typeof e.orUndefined=="function"}var Jr={toOption:e=>e.fold(()=>b(),t=>w(t)),toList:e=>e.fold(()=>y([]),t=>y([t])),toEither:(e,t)=>e.fold(()=>p(t),r=>c(r)),isEmpty:e=>e.fold(()=>true,()=>false),size:e=>e.fold(()=>0,()=>1)};var q=e=>e!==null&&typeof e=="object"&&(e._tag==="Some"||e._tag==="None"),K=e=>e!==null&&typeof e=="object"&&e._tag==="List",re=e=>e!==null&&typeof e=="object"&&(e._tag==="Left"||e._tag==="Right"),ne=e=>e!==null&&typeof e=="object"&&(e._tag==="Success"||e._tag==="Failure"),S=()=>{let e=(s,i)=>{if(q(s))return s.map(u=>i(u));if(K(s))return s.map(u=>i(u));if(re(s))return s.map(u=>i(u));if(ne(s))return s.map(u=>i(u));throw new Error(`Unsupported functor type: ${JSON.stringify(s)}`)},t=s=>{if(q(s))return s.get();if(K(s)){let i=s.toArray();if(i.length>0&&K(i[0])){let u=[];for(let l of i)K(l)&&u.push(...l.toArray());return y(u)}return s.flatten()}if(re(s))return s.isRight()?s.fold(()=>null,i=>i):s;if(ne(s))return s.isSuccess()?s.get():s;throw new Error(`Unsupported functor type for flatten: ${JSON.stringify(s)}`)},r=(s,i)=>{if(q(s))return s.flatMap(u=>i(u));if(K(s))return s.flatMap(u=>i(u));if(re(s))return s.flatMap(u=>i(u));if(ne(s))return s.flatMap(u=>i(u));throw new Error(`Unsupported functor type for flatMap: ${JSON.stringify(s)}`)},n=(s,i)=>{if(q(s)&&q(i))return s.flatMap(u=>i.map(l=>u(l)));if(K(s)&&K(i))return s.flatMap(u=>i.map(l=>u(l)));if(re(s)&&re(i))return s.flatMap(u=>i.map(l=>u(l)));if(ne(s)&&ne(i))return s.flatMap(u=>i.map(l=>u(l)));throw new Error(`Unsupported functor type for ap: ${JSON.stringify(s)}`)},o=s=>{if(q(s)){let i=s;if(i.isEmpty)return y([f.none()]);let u=i.get();if(K(u))return u.map(l=>f(l));throw new Error("Unsupported inner container type for sequence")}if(K(s)){let u=s.toArray();if(u.length===0)return f.none();let l=u[0];if(q(l)){for(let g of u)if(g.isEmpty)return f.none();let E=u.map(g=>g.get());return f(y(E))}throw new Error("Unsupported inner container type for sequence")}throw new Error(`Unsupported outer container type for sequence: ${JSON.stringify(s)}`)};return {...te("HKT",{map:e,flatten:t,flatMap:r,ap:n,sequence:o,traverse:(s,i)=>o(e(s,u=>i(u)))}),_type:"HKT"}};S.map=(e,t)=>S().map(e,t);S.flatten=e=>S().flatten(e);S.flatMap=(e,t)=>S().flatMap(e,t);S.ap=(e,t)=>S().ap(e,t);S.sequence=e=>S().sequence(e);S.traverse=(e,t)=>S().traverse(e,t);S.isOption=q;S.isList=K;S.isEither=re;S.isTry=ne;function Hr(e){return {id:e,isSame:r=>r.id===e}}var de=e=>({_tag:"Success",error:void 0,isSuccess:()=>true,isFailure:()=>false,get:()=>e,getOrElse:t=>e,getOrThrow:t=>e,orElse:t=>de(e),orNull:()=>e,orUndefined:()=>e,orThrow:t=>e,toEither:()=>c(e),map:t=>Ae(()=>t(e)),ap:t=>t.map(r=>r(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,r)=>r(e),match:t=>t.Success(e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toString:()=>`Success(${se(e)})`,toValue:()=>({_tag:"Success",value:e}),pipe:t=>t(e),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Success",value:e}),toYAML:()=>`_tag: Success
|
|
29
|
-
value: ${se(e)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Success",value:e})).toString("base64")}),get size(){return 1},get isEmpty(){return false},contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>t(e)?1:0,find:t=>t(e)?f(e):f(void 0),exists:t=>t(e),forEach:t=>t(e)}),$=e=>({_tag:"Failure",error:e,isSuccess:()=>false,isFailure:()=>true,get:()=>{throw e},getOrElse:t=>t,getOrThrow:t=>{throw t||e},orElse:t=>t,orNull:()=>null,orUndefined:()=>{},orThrow:t=>{throw t},toEither:()=>p(e),map:t=>$(e),ap:t=>$(e),flatMap:t=>$(e),flatMapAsync:async t=>$(e),fold:(t,r)=>t(e),match:t=>t.Failure(e),foldLeft:t=>r=>t,foldRight:t=>r=>t,toString:()=>`Failure(${se(e)}))`,toValue:()=>({_tag:"Failure",value:e}),pipe:t=>{throw e},serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Failure",error:e.message,stack:e.stack}),toYAML:()=>`_tag: Failure
|
|
30
|
-
error: ${e.message}
|
|
31
|
-
stack: ${e.stack}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Failure",error:e.message,stack:e.stack})).toString("base64")}),get size(){return 0},get isEmpty(){return true},contains:t=>false,reduce:t=>{throw new Error("Cannot reduce a Failure")},reduceRight:t=>{throw new Error("Cannot reduceRight a Failure")},count:t=>0,find:t=>f(null),exists:t=>false,forEach:t=>{}}),ct=e=>{try{return de(e())}catch(t){return $(t instanceof Error?t:new Error(String(t)))}},Ce={fromJSON:e=>{let t=JSON.parse(e);if(t._tag==="Success")return de(t.value);{let r=new Error(t.error);return t.stack&&(r.stack=t.stack),$(r)}},fromYAML:e=>{let t=e.split(`
|
|
32
|
-
`),r=t[0]?.split(": ")[1];if(!r)return $(new Error("Invalid YAML format for Try"));if(r==="Success"){let n=t[1]?.split(": ")[1];if(!n)return $(new Error("Invalid YAML format for Try Success"));let o=JSON.parse(n);return de(o)}else {let n=t[1]?.split(": ")[1];if(!n)return $(new Error("Invalid YAML format for Try Failure"));let o=t[2]?.split(": "),a=o&&o.length>1?o.slice(1).join(": "):void 0,s=new Error(n);return a&&(s.stack=a),$(s)}},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return Ce.fromJSON(t)}},Ae=a(ct,Ce);var Y=e=>{let t=false,r,n,o=false,a=()=>{if(!t)try{r=e(),t=!0;}catch(i){throw n=i,o=true,t=true,i}if(o)throw n;return r};return {_tag:"Lazy",get isEvaluated(){return t},get:a,getOrElse:i=>{try{return a()}catch{return i}},getOrNull:()=>{try{return a()}catch{return null}},orNull:()=>{try{return a()}catch{return null}},getOrThrow:i=>{try{return a()}catch(u){throw i||u}},orElse:i=>M(()=>{try{return a()}catch{return i.get()}}),orUndefined:()=>{try{return a()}catch{return}},map:i=>M(()=>i(a())),ap:i=>M(()=>i.get()(a())),mapAsync:async i=>{let u=a(),l=await i(u);return M(()=>l)},flatMap:i=>M(()=>i(a()).get()),flatMapAsync:async i=>{let u=a(),l=await i(u);return M(()=>l.get())},filter:i=>M(()=>{let u=a();return i(u)?w(u):b}),recover:i=>M(()=>{try{return a()}catch(u){return i(u)}}),recoverWith:i=>M(()=>{try{return a()}catch(u){return i(u).get()}}),toOption:()=>{try{return w(a())}catch{return b}},toEither:()=>{try{return c(a())}catch(i){return p(i)}},toEitherWith:i=>{try{return c(a())}catch(u){return p(i(u))}},toTry:()=>Ae(()=>a()),tap:i=>M(()=>{let u=a();return i(u),u}),tapError:i=>M(()=>{try{return a()}catch(u){throw i(u),u}}),fold:i=>i(a()),foldWith:(i,u)=>{try{return u(a())}catch(l){return i(l)}},foldLeft:i=>u=>u(i,a()),foldRight:i=>u=>u(a(),i),match:i=>i.Lazy(a()),toString:()=>t&&!o?`Lazy(${se(r)})`:t&&o?`Lazy(<error: ${n instanceof Error?n.message:String(n)}>)`:"Lazy(<not evaluated>)",toValue:()=>t&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false},get size(){try{return a(),1}catch{return 0}},get isEmpty(){try{return a(),!1}catch{return true}},contains:i=>{try{return a()===i}catch{return false}},reduce:i=>a(),reduceRight:i=>a(),count:i=>{try{return i(a())?1:0}catch{return 0}},find:i=>{try{let u=a();return i(u)?w(u):b}catch{return b}},exists:i=>{try{return i(a())}catch{return false}},forEach:i=>{try{i(a());}catch{}},pipe:i=>i(a()),serialize:()=>({toJSON:()=>JSON.stringify(t&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false}),toYAML:()=>t&&!o?`_tag: Lazy
|
|
33
|
-
evaluated: true
|
|
34
|
-
value: ${se(r)}`:`_tag: Lazy
|
|
35
|
-
evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(t&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false})).toString("base64")}),typeable:"Lazy"}},Tt={of:e=>Y(e),fromValue:e=>Y(()=>e),fromOption:(e,t)=>Y(()=>e._tag==="Some"?e.value:t()),fromTry:e=>Y(()=>e.get()),fromEither:e=>Y(()=>e.fold(t=>{throw t},t=>t)),fromPromise:e=>Y(()=>{throw new Error("Promise not yet resolved. Use await on the promise before creating Lazy.")}),fail:e=>Y(()=>{throw e})},M=a(Y,Tt);var ie=Map;var W=e=>{let r={values:new ie(e)},n=()=>Array.from(r.values.entries()).map(([T,m])=>b$1([T,m])),o=T=>W(new ie(r.values).set(T.toArray()[0],T.toArray()[1]).entries()),a=T=>{let m=new ie(r.values);return m.delete(T)?W(m.entries()):W(r.values.entries())},s=T=>{let m=T.toArray();return r.values.get(m[0])===m[1]},i=()=>r.values.size,u=T=>W(Array.from(r.values.entries()).map(([m,_])=>[m,T(_)])),l=T=>{let m=W(r.values.entries()).toList();return W(m.flatMap(T).toArray())},E=T=>{let m=[];for(let[_,X]of r.values.entries()){let ae=T.get(_);ae._tag==="Some"&&ae.value&&m.push([_,ae.value(X)]);}return W(m)},g=async T=>{let m=new ie;for(let[_,X]of r.values.entries()){let ae=await T(X);for(let Je of ae.toList()){let[We,je]=Je.toArray();m.set(We,je);}}return W(m.entries())},C=T=>y(n()).reduce(T),v=T=>y(n()).reduceRight(T),A=T=>m=>y(n()).foldLeft(T)(m),G=T=>m=>y(n()).foldRight(T)(m),j=T=>f(r.values.get(T)),Z=(T,m)=>f(r.values.get(T)).getOrElse(m),oe=()=>r.values.size===0,ue=(T,m)=>f(r.values.get(T)).orElse(m),le=(T,m)=>{if(oe())return T();let _=n();if(_.length===0)return T();let X=_[0];return X===void 0?T():m(X)},be=()=>y(n()),d=()=>Q(n()),B=()=>`Map(${n().toString()})`,O=T=>oe()?T.Empty():T.NonEmpty(n());return {_tag:"Map",[Symbol.iterator]:()=>r.values.entries(),add:o,remove:a,contains:s,get size(){return i()},map:u,ap:E,flatMap:l,flatMapAsync:g,reduce:C,reduceRight:v,foldLeft:A,foldRight:G,fold:le,match:O,get:j,getOrElse:Z,get isEmpty(){return oe()},orElse:ue,toList:be,toSet:d,toString:B,toValue:()=>({_tag:"Map",value:Array.from(r.values.entries())}),pipe:T=>T(Array.from(r.values.entries())),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())}),toYAML:()=>`_tag: Map
|
|
36
|
-
value: ${JSON.stringify(Array.from(r.values.entries()))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())})).toString("base64")})}},ft=e=>W(e),Fe={fromJSON:e=>{let t=JSON.parse(e);return Re(t.value)},fromYAML:e=>{let r=e.split(`
|
|
37
|
-
`)[1]?.split(": ")[1];if(!r)return Re([]);let n=JSON.parse(r);return Re(n)},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return Fe.fromJSON(t)}},Re=a(ft,Fe);var dt={default:e=>t=>e(t),when:(e,t)=>r=>e(r)?t(r):void 0};function Le(e){let t=e;return {get(){return t},set(n){t=n;},update(n){t=n(t);},getAndSet(n){let o=t;return t=n,o},updateAndGet(n){return t=n(t),t},getAndUpdate(n){let o=t;return t=n(t),o},compareAndSet(n,o){return t===n?(t=o,true):false},modify(n){let[o,a]=n(t);return t=o,a}}}Le.of=Le;var V=(e=[])=>{let t="Stack",r=[...e],n=()=>r.length,o=()=>r.length===0;return {_tag:t,get size(){return n()},get isEmpty(){return o()},contains:d=>r.includes(d),reduce:d=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduce(d)},reduceRight:d=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduceRight(d)},push:d=>V([...r,d]),pop:()=>{if(o())return [V([]),f(null)];let d=[...r],B=d.pop();return [V(d),f(B)]},peek:()=>o()?f(null):f(r[r.length-1]),map:d=>V(r.map(d)),flatMap:d=>o()?V([]):r.reduce((B,O)=>d(O).toArray().reduce((m,_)=>m.push(_),B),V([])),ap:d=>{let B=[];return r.forEach(O=>{d.toArray().forEach(T=>{B.push(T(O));});}),V(B)},flatMapAsync:async d=>o()?V([]):(await Promise.all(r.map(async O=>await d(O)))).reduce((O,T)=>T.toArray().reduce((m,_)=>m.push(_),O),V([])),toList:()=>y(r),toArray:()=>[...r],toString:()=>`Stack(${r.join(", ")})`,fold:(d,B)=>{if(o())return d();let O=r[r.length-1];return O!==void 0?B(O):d()},foldLeft:d=>B=>r.reduce(B,d),foldRight:d=>B=>r.reduceRight((O,T)=>B(T,O),d),match:d=>o()?d.Empty():d.NonEmpty([...r]),toValue:()=>({_tag:"Stack",value:r}),pipe:d=>d([...r]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Stack",value:r}),toYAML:()=>`_tag: Stack
|
|
38
|
-
value: ${JSON.stringify(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Stack",value:r})).toString("base64")})}},mt=(e=[])=>V(e),Ke={empty:()=>V([]),of:e=>V([e]),fromJSON:e=>{let t=JSON.parse(e);return xe(t.value)},fromYAML:e=>{let r=e.split(`
|
|
39
|
-
`)[1]?.split(": ")[1];if(!r)return xe([]);let n=JSON.parse(r);return xe(n)},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return Ke.fromJSON(t)}},xe=a(mt,Ke);function On(e){let t=ce({_tag:e._tag,impl:e.impl});return {...t,toValue:()=>({_tag:t._tag,value:e.value})}}var w=e=>({_tag:"Some",value:e,isEmpty:false,isSome:()=>true,isNone:()=>false,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:t=>w(e),orNull:()=>e,orUndefined:()=>e,map:t=>w(t(e)),ap:t=>t._tag==="Some"&&t.value?w(t.value(e)):D,filter(t){return t(e)?w(e):D},count:t=>t(e)?1:0,find:t=>t(e)?w(e):D,exists:t=>t(e),forEach:t=>t(e),fold:(t,r)=>r(e),match:t=>t.Some(e),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>y([e]),contains:t=>t===e,size:1,toEither:t=>c(e),toString:()=>`Some(${se(e)})`,toValue:()=>({_tag:"Some",value:e}),pipe:t=>t(e),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Some",value:e}),toYAML:()=>`_tag: Some
|
|
40
|
-
value: ${se(e)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Some",value:e})).toString("base64")})}),D={_tag:"None",value:void 0,isEmpty:true,isSome:()=>false,isNone:()=>true,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,getOrThrow(e){throw e},orElse:e=>e,orNull:()=>null,orUndefined:()=>{},map:e=>D,ap:e=>D,filter(e){return D},count:e=>0,find:e=>D,exists:e=>false,forEach:e=>{},flatMap:e=>D,flatMapAsync:async e=>D,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),match:e=>e.None(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>y([]),contains:()=>false,size:0,toEither:e=>p(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0}),pipe:e=>e(void 0),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"None",value:null}),toYAML:()=>`_tag: None
|
|
41
|
-
value: null`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"None",value:null})).toString("base64")})},b=()=>D,yt=e=>e!=null?w(e):b(),De={from:e=>f(e),none:()=>b(),fromJSON:e=>{let t=JSON.parse(e);return t._tag==="Some"?w(t.value):b()},fromYAML:e=>{let t=e.split(`
|
|
42
|
-
`),r=t[0]?.split(": ")[1],n=t[1]?.split(": ")[1];if(!r||!n)return b();let o=n==="null"?null:JSON.parse(n);return r==="Some"?w(o):b()},fromBinary:e=>{let t=Buffer.from(e,"base64").toString();return De.fromJSON(t)}},f=a(yt,De);export{Hr as $,Yt as A,Qt as B,Ht as C,Gt as D,er as E,or as F,te as G,Te as H,L as I,tt as J,ge as K,rt as L,Ne as M,_e as N,Ee as O,z as P,Ve as Q,fe as R,Ar as S,Rr as T,xr as U,x as V,Or as W,Mr as X,pt as Y,Jr as Z,S as _,w as a,Ae as aa,b,M as ba,yt as c,ie as ca,f as d,Re as da,Q as e,dt as ea,ce as f,Le as fa,me as g,xe as ga,y as h,On as ha,c as i,p as j,Nt as k,_t as l,It as m,Qe as n,He as o,Mt as p,ve as q,I as r,Ge as s,Kt as t,$t as u,Dt as v,Jt as w,Wt as x,jt as y,qt as z};//# sourceMappingURL=chunk-6KFGLFLL.mjs.map
|
|
43
|
-
//# sourceMappingURL=chunk-6KFGLFLL.mjs.map
|