functype 0.4.0 → 0.4.1
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/{chunk-LO5XBCIY.js → chunk-3APFKSCC.js} +1 -1
- package/dist/chunk-63PL65AF.js +1 -0
- package/dist/chunk-6FZZWNOL.js +1 -0
- package/dist/{chunk-UVR6IELR.mjs → chunk-E35CYHY2.mjs} +1 -1
- package/dist/chunk-HH4VYR73.js +1 -0
- package/dist/chunk-HOO2EPER.mjs +1 -0
- package/dist/{chunk-OLJYBLCT.js → chunk-I4BEM5D2.js} +1 -1
- package/dist/chunk-J4OZ7K3I.mjs +1 -0
- package/dist/{chunk-U37JTC3U.mjs → chunk-JR557W27.mjs} +1 -1
- package/dist/{chunk-D22QKJZO.js → chunk-O2XFH626.js} +1 -1
- package/dist/chunk-R7GOBZSO.mjs +1 -0
- package/dist/{chunk-SPNWCOGV.mjs → chunk-RLT5VF56.mjs} +1 -1
- package/dist/chunk-SKJIJETA.js +1 -0
- package/dist/{chunk-WMSIRQ3W.mjs → chunk-TYHKMGLC.mjs} +1 -1
- package/dist/{chunk-CPB6NX2S.js → chunk-XKON5UBC.js} +1 -1
- package/dist/{chunk-S5YAJ7CP.mjs → chunk-Z2XAS3AB.mjs} +1 -1
- package/dist/collections/index.d.mts +2 -1
- package/dist/collections/index.d.ts +2 -1
- package/dist/either/Either.d.mts +2 -1
- package/dist/either/Either.d.ts +2 -1
- package/dist/either/Either.js +1 -1
- package/dist/either/Either.mjs +1 -1
- package/dist/either/index.d.mts +2 -1
- package/dist/either/index.d.ts +2 -1
- package/dist/either/index.js +1 -1
- package/dist/either/index.mjs +1 -1
- package/dist/error/ParseError.js +1 -1
- package/dist/error/ParseError.mjs +1 -1
- package/dist/{index-BSx1ncJ9.d.ts → index-BIu07QR3.d.ts} +5 -4
- package/dist/{index-uP_Hoh2D.d.mts → index-DC8arpKk.d.mts} +5 -4
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterable/Seq.d.mts +2 -1
- package/dist/iterable/Seq.d.ts +2 -1
- package/dist/iterable/Seq.js +1 -1
- package/dist/iterable/Seq.mjs +1 -1
- package/dist/iterable/index.d.mts +2 -1
- package/dist/iterable/index.d.ts +2 -1
- package/dist/iterable/index.js +1 -1
- package/dist/iterable/index.mjs +1 -1
- package/dist/list/List.d.mts +2 -1
- package/dist/list/List.d.ts +2 -1
- package/dist/list/List.js +1 -1
- package/dist/list/List.mjs +1 -1
- package/dist/list/index.d.mts +2 -1
- package/dist/list/index.d.ts +2 -1
- package/dist/list/index.js +1 -1
- package/dist/list/index.mjs +1 -1
- package/dist/map/Map.d.mts +2 -1
- package/dist/map/Map.d.ts +2 -1
- package/dist/map/Map.js +1 -1
- package/dist/map/Map.mjs +1 -1
- package/dist/map/index.d.mts +2 -1
- package/dist/map/index.d.ts +2 -1
- package/dist/map/index.js +1 -1
- package/dist/map/index.mjs +1 -1
- package/dist/map/shim.js +1 -1
- package/dist/map/shim.mjs +1 -1
- package/dist/option/Option.d.mts +2 -1
- package/dist/option/Option.d.ts +2 -1
- package/dist/option/Option.js +1 -1
- package/dist/option/Option.mjs +1 -1
- package/dist/option/index.d.mts +2 -1
- package/dist/option/index.d.ts +2 -1
- package/dist/option/index.js +1 -1
- package/dist/option/index.mjs +1 -1
- package/dist/set/Set.d.mts +2 -1
- package/dist/set/Set.d.ts +2 -1
- package/dist/set/Set.js +1 -1
- package/dist/set/Set.mjs +1 -1
- package/dist/set/index.d.mts +2 -1
- package/dist/set/index.d.ts +2 -1
- package/dist/set/index.js +1 -1
- package/dist/set/index.mjs +1 -1
- package/dist/set/shim.js +1 -1
- package/dist/set/shim.mjs +1 -1
- package/dist/try/Try.d.mts +2 -1
- package/dist/try/Try.d.ts +2 -1
- package/dist/try/Try.js +1 -1
- package/dist/try/Try.mjs +1 -1
- package/dist/try/index.d.mts +2 -1
- package/dist/try/index.d.ts +2 -1
- package/dist/try/index.js +1 -1
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/Tuple.d.mts +1 -0
- package/dist/tuple/Tuple.d.ts +1 -0
- package/dist/tuple/Tuple.js +1 -1
- package/dist/tuple/Tuple.mjs +1 -1
- package/dist/tuple/index.d.mts +8 -2
- package/dist/tuple/index.d.ts +8 -2
- package/dist/tuple/index.js +1 -1
- package/dist/tuple/index.mjs +1 -1
- package/dist/util/index.d.mts +2 -1
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.js +1 -1
- package/dist/util/index.mjs +1 -1
- package/dist/util/isIterable.js +1 -1
- package/dist/util/isIterable.mjs +1 -1
- package/lib/collections/index.d.ts +8 -0
- package/lib/either/Either.d.ts +32 -0
- package/lib/either/index.d.ts +4 -0
- package/lib/error/ParseError.d.ts +2 -0
- package/lib/functor/index.d.ts +15 -0
- package/lib/index.d.ts +19 -0
- package/lib/iterable/Seq.d.ts +25 -0
- package/lib/iterable/index.d.ts +22 -0
- package/lib/list/List.d.ts +23 -0
- package/lib/list/index.d.ts +3 -0
- package/lib/map/Map.d.ts +37 -0
- package/lib/map/index.d.ts +1 -0
- package/lib/map/shim.d.ts +2 -0
- package/lib/option/Option.d.ts +44 -0
- package/lib/option/index.d.ts +5 -0
- package/lib/set/Set.d.ts +18 -0
- package/lib/set/index.d.ts +1 -0
- package/lib/set/shim.d.ts +2 -0
- package/lib/try/Try.d.ts +19 -0
- package/lib/try/index.d.ts +1 -0
- package/lib/tuple/Tuple.d.ts +16 -0
- package/lib/tuple/index.d.ts +1 -0
- package/lib/util/index.d.ts +3 -0
- package/lib/util/isIterable.d.ts +1 -0
- package/package.json +12 -12
- package/dist/chunk-4P46BMZQ.js +0 -1
- package/dist/chunk-7JTQ2BTE.mjs +0 -1
- package/dist/chunk-GZIDEEAG.mjs +0 -1
- package/dist/chunk-HF33BEHO.js +0 -1
- package/dist/chunk-LBQXRIXP.mjs +0 -0
- package/dist/chunk-LLZGG3YT.js +0 -1
- package/dist/chunk-TVZBBVEV.js +0 -1
package/dist/try/Try.d.ts
CHANGED
package/dist/try/Try.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkI4BEM5D2js = require('../chunk-I4BEM5D2.js');require('../chunk-63PL65AF.js');require('../chunk-HH4VYR73.js');require('../chunk-XKON5UBC.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.Try = _chunkI4BEM5D2js.a;
|
package/dist/try/Try.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-RLT5VF56.mjs";import"../chunk-J4OZ7K3I.mjs";import"../chunk-Z2XAS3AB.mjs";import"../chunk-E35CYHY2.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as Try};
|
package/dist/try/index.d.mts
CHANGED
package/dist/try/index.d.ts
CHANGED
package/dist/try/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6BEXQNLZ.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6BEXQNLZ.js');var _chunkI4BEM5D2js = require('../chunk-I4BEM5D2.js');require('../chunk-63PL65AF.js');require('../chunk-HH4VYR73.js');require('../chunk-XKON5UBC.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.Try = _chunkI4BEM5D2js.a;
|
package/dist/try/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-Q4H3PCBH.mjs";import{a}from"../chunk-
|
|
1
|
+
import"../chunk-Q4H3PCBH.mjs";import{a}from"../chunk-RLT5VF56.mjs";import"../chunk-J4OZ7K3I.mjs";import"../chunk-Z2XAS3AB.mjs";import"../chunk-E35CYHY2.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as Try};
|
package/dist/tuple/Tuple.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
|
|
|
5
5
|
getAs<U>(index: number, f?: (item: T) => boolean): U;
|
|
6
6
|
map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
|
|
7
7
|
flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
|
|
8
|
+
toArray(): T;
|
|
8
9
|
};
|
|
9
10
|
declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
|
|
10
11
|
private readonly values;
|
package/dist/tuple/Tuple.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
|
|
|
5
5
|
getAs<U>(index: number, f?: (item: T) => boolean): U;
|
|
6
6
|
map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
|
|
7
7
|
flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
|
|
8
|
+
toArray(): T;
|
|
8
9
|
};
|
|
9
10
|
declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
|
|
10
11
|
private readonly values;
|
package/dist/tuple/Tuple.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-O2XFH626.js');exports.Tuple = _chunkV5UFW2E4js.a;
|
package/dist/tuple/Tuple.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-
|
|
1
|
+
import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-JR557W27.mjs";export{a as Tuple};
|
package/dist/tuple/index.d.mts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
1
|
+
import { ArrayType } from '../functor/index.mjs';
|
|
2
|
+
import { Tuple } from './Tuple.mjs';
|
|
3
|
+
export { _Tuple_ } from './Tuple.mjs';
|
|
4
|
+
|
|
5
|
+
declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
|
|
6
|
+
declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
|
|
7
|
+
|
|
8
|
+
export { Tuple, t, tuple };
|
package/dist/tuple/index.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
1
|
+
import { ArrayType } from '../functor/index.js';
|
|
2
|
+
import { Tuple } from './Tuple.js';
|
|
3
|
+
export { _Tuple_ } from './Tuple.js';
|
|
4
|
+
|
|
5
|
+
declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
|
|
6
|
+
declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
|
|
7
|
+
|
|
8
|
+
export { Tuple, t, tuple };
|
package/dist/tuple/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSKJIJETAjs = require('../chunk-SKJIJETA.js');var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-O2XFH626.js');exports.Tuple = _chunkV5UFW2E4js.a; exports.t = _chunkSKJIJETAjs.a; exports.tuple = _chunkSKJIJETAjs.b;
|
package/dist/tuple/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import{a as b,b as c}from"../chunk-HOO2EPER.mjs";import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-JR557W27.mjs";export{a as Tuple,b as t,c as tuple};
|
package/dist/util/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParseError } from '../error/ParseError.mjs';
|
|
2
|
-
import { E as Either } from '../index-
|
|
2
|
+
import { E as Either } from '../index-DC8arpKk.mjs';
|
|
3
3
|
import '../functor/index.mjs';
|
|
4
4
|
import '../tuple/Tuple.mjs';
|
|
5
|
+
import '../tuple/index.mjs';
|
|
5
6
|
|
|
6
7
|
declare const parseNumber: (input: string) => Either<ParseError, number>;
|
|
7
8
|
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParseError } from '../error/ParseError.js';
|
|
2
|
-
import { E as Either } from '../index-
|
|
2
|
+
import { E as Either } from '../index-BIu07QR3.js';
|
|
3
3
|
import '../functor/index.js';
|
|
4
4
|
import '../tuple/Tuple.js';
|
|
5
|
+
import '../tuple/index.js';
|
|
5
6
|
|
|
6
7
|
declare const parseNumber: (input: string) => Either<ParseError, number>;
|
|
7
8
|
|
package/dist/util/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk63PL65AFjs = require('../chunk-63PL65AF.js');require('../chunk-HH4VYR73.js');require('../chunk-XKON5UBC.js');require('../chunk-3VJERXBP.js');var _chunkZTL76QDLjs = require('../chunk-ZTL76QDL.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');var n=s=>{let r=parseInt(s,10);return isNaN(r)?_chunk63PL65AFjs.a.call(void 0, new (0, _chunkZTL76QDLjs.a)(`${r}`)):_chunk63PL65AFjs.b.call(void 0, r)};exports.parseNumber = n;
|
package/dist/util/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t}from"../chunk-
|
|
1
|
+
import{a as e,b as t}from"../chunk-J4OZ7K3I.mjs";import"../chunk-Z2XAS3AB.mjs";import"../chunk-E35CYHY2.mjs";import"../chunk-HA5XD5KC.mjs";import{a as o}from"../chunk-CFYIJKWF.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";var n=s=>{let r=parseInt(s,10);return isNaN(r)?e(new o(`${r}`)):t(r)};export{n as parseNumber};
|
package/dist/util/isIterable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');require('../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.isIterable = _chunkBNNK42JCjs.a;
|
package/dist/util/isIterable.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-RRAIFS3D.mjs";import"../chunk-
|
|
1
|
+
import{a}from"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as isIterable};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { _Option_ } from "../option";
|
|
2
|
+
import { List } from "../list";
|
|
3
|
+
import { _Functor_ } from "../functor";
|
|
4
|
+
export type Either<L, R> = {
|
|
5
|
+
value: L | R;
|
|
6
|
+
isLeft(): boolean;
|
|
7
|
+
isRight(): boolean;
|
|
8
|
+
map<U>(f: (value: R) => U): Either<L, U>;
|
|
9
|
+
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
10
|
+
toOption(): _Option_<R>;
|
|
11
|
+
toList(): List<R>;
|
|
12
|
+
} & _Functor_<R>;
|
|
13
|
+
export declare class Right<L, R> implements Either<L, R> {
|
|
14
|
+
value: R;
|
|
15
|
+
constructor(value: R);
|
|
16
|
+
isLeft(): this is Left<L, R>;
|
|
17
|
+
isRight(): this is Right<L, R>;
|
|
18
|
+
map<U>(f: (value: R) => U): Either<L, U>;
|
|
19
|
+
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
20
|
+
toOption(): _Option_<R>;
|
|
21
|
+
toList(): List<R>;
|
|
22
|
+
}
|
|
23
|
+
export declare class Left<L, R> implements Either<L, R> {
|
|
24
|
+
value: L;
|
|
25
|
+
constructor(value: L);
|
|
26
|
+
isLeft(): this is Left<L, R>;
|
|
27
|
+
isRight(): this is Right<L, R>;
|
|
28
|
+
map<U>(_f: (value: R) => U): Either<L, U>;
|
|
29
|
+
flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
|
|
30
|
+
toOption(): _Option_<R>;
|
|
31
|
+
toList(): List<R>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SingleType = any;
|
|
2
|
+
export type ArrayType = SingleType[];
|
|
3
|
+
export type Type = SingleType | ArrayType;
|
|
4
|
+
export type _AbstractFunctor_<A extends Type> = {
|
|
5
|
+
map(f: (value: A) => Type): _AbstractFunctor_<Type>;
|
|
6
|
+
flatMap(f: (value: A) => _AbstractFunctor_<Type>): _AbstractFunctor_<Type>;
|
|
7
|
+
};
|
|
8
|
+
export type _Functor_<A extends Type> = _AbstractFunctor_<A> & {
|
|
9
|
+
map<B extends Type>(f: (value: A) => B): _Functor_<B>;
|
|
10
|
+
flatMap<B extends Type>(f: (value: A) => _Functor_<B>): _Functor_<B>;
|
|
11
|
+
};
|
|
12
|
+
export type _ArrayFunctor_<A extends ArrayType> = _AbstractFunctor_<A> & {
|
|
13
|
+
map<U extends ArrayType>(f: (value: A) => U): _ArrayFunctor_<U>;
|
|
14
|
+
flatMap<U extends ArrayType>(f: (value: A) => _ArrayFunctor_<U>): _ArrayFunctor_<U>;
|
|
15
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { _Functor_, Type } from "./functor";
|
|
2
|
+
export type _Traversable_<A extends Type> = _Functor_<A> & {
|
|
3
|
+
get size(): number;
|
|
4
|
+
get isEmpty(): boolean;
|
|
5
|
+
contains(value: A): boolean;
|
|
6
|
+
reduce(f: (b: A, a: A) => A): A;
|
|
7
|
+
reduceRight(f: (b: A, a: A) => A): A;
|
|
8
|
+
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
9
|
+
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
10
|
+
};
|
|
11
|
+
export * from "./functor";
|
|
12
|
+
export * from "./iterable";
|
|
13
|
+
export * from "./list";
|
|
14
|
+
export * from "./map";
|
|
15
|
+
export * from "./option";
|
|
16
|
+
export * from "./either";
|
|
17
|
+
export * from "./set";
|
|
18
|
+
export * from "./tuple";
|
|
19
|
+
export * from "./try";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { _Iterable_ } from "./index";
|
|
2
|
+
import { _Option_ } from "../option";
|
|
3
|
+
export declare class Seq<A> implements _Iterable_<A> {
|
|
4
|
+
protected readonly values: Iterable<A>;
|
|
5
|
+
constructor(values?: Iterable<A> | _Iterable_<A>);
|
|
6
|
+
readonly [n: number]: A;
|
|
7
|
+
get length(): number;
|
|
8
|
+
map<B>(f: (a: A) => B): _Iterable_<B>;
|
|
9
|
+
flatMap<B>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
|
|
10
|
+
forEach(f: (a: A) => void): void;
|
|
11
|
+
count(p: (x: A) => boolean): number;
|
|
12
|
+
exists(p: (a: A) => boolean): Boolean;
|
|
13
|
+
filter(p: (a: A) => boolean): _Iterable_<A>;
|
|
14
|
+
filterNot(p: (a: A) => boolean): _Iterable_<A>;
|
|
15
|
+
find(p: (a: A) => boolean): _Option_<A>;
|
|
16
|
+
get head(): A;
|
|
17
|
+
get headOption(): _Option_<A>;
|
|
18
|
+
get isEmpty(): boolean;
|
|
19
|
+
get size(): number;
|
|
20
|
+
toArray(): A[];
|
|
21
|
+
reduce(f: (prev: A, curr: A) => A): A;
|
|
22
|
+
reduceRight(f: (prev: A, curr: A) => A): A;
|
|
23
|
+
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
24
|
+
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { _Functor_, Type } from "../functor";
|
|
2
|
+
import { _Option_ } from "../option";
|
|
3
|
+
export type _Iterable_<A extends Type> = {
|
|
4
|
+
count(p: (x: A) => boolean): number;
|
|
5
|
+
find(p: (a: A) => boolean): _Option_<A>;
|
|
6
|
+
forEach(f: (a: A) => void): void;
|
|
7
|
+
exists(p: (a: A) => boolean): Boolean;
|
|
8
|
+
filter(p: (a: A) => boolean): _Iterable_<A>;
|
|
9
|
+
filterNot(p: (a: A) => boolean): _Iterable_<A>;
|
|
10
|
+
reduce(f: (b: A, a: A) => A): A;
|
|
11
|
+
reduceRight(f: (b: A, a: A) => A): A;
|
|
12
|
+
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
13
|
+
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
14
|
+
get head(): A;
|
|
15
|
+
get headOption(): _Option_<A>;
|
|
16
|
+
get isEmpty(): boolean;
|
|
17
|
+
map<B extends Type>(f: (a: A) => B): _Iterable_<B>;
|
|
18
|
+
flatMap<B extends Type>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
|
|
19
|
+
get size(): number;
|
|
20
|
+
toArray(): readonly A[];
|
|
21
|
+
} & _Functor_<A>;
|
|
22
|
+
export { Seq } from "./Seq";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _Iterable_ } from "../iterable";
|
|
2
|
+
import { Seq } from "../iterable";
|
|
3
|
+
import { _Collection } from "../collections";
|
|
4
|
+
import { Set } from "../set";
|
|
5
|
+
import { _Option_ } from "../option";
|
|
6
|
+
export interface _List_<T> extends _Iterable_<T>, ArrayLike<T> {
|
|
7
|
+
add(item: T): _List_<T>;
|
|
8
|
+
}
|
|
9
|
+
export declare class List<A> extends Seq<A> implements _List_<A>, _Collection<A> {
|
|
10
|
+
constructor(values?: Iterable<A> | _Iterable_<A>);
|
|
11
|
+
readonly [n: number]: A;
|
|
12
|
+
map<B>(f: (a: A) => B): List<B>;
|
|
13
|
+
flatMap<B>(f: (a: A) => _Iterable_<B>): List<B>;
|
|
14
|
+
remove(value: A): List<A>;
|
|
15
|
+
contains(value: A): boolean;
|
|
16
|
+
add(item: A): List<A>;
|
|
17
|
+
removeAt(index: number): List<A>;
|
|
18
|
+
get(index: number): _Option_<A>;
|
|
19
|
+
concat(other: List<A>): List<A>;
|
|
20
|
+
toList(): _List_<A>;
|
|
21
|
+
toSet(): Set<A>;
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
package/lib/map/Map.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { _Tuple_, Tuple } from "../tuple";
|
|
2
|
+
import { _Set_ } from "../set";
|
|
3
|
+
import { _Option_ } from "../option";
|
|
4
|
+
import { _List_ } from "../list";
|
|
5
|
+
import { _Traversable_ } from "../index";
|
|
6
|
+
import { _Collection } from "../collections";
|
|
7
|
+
type SafeTraversable<K, V> = Omit<_Traversable_<_Tuple_<[K, V]>>, "map" | "flatMap">;
|
|
8
|
+
export type _Map_<K, V> = {
|
|
9
|
+
map<U>(f: (value: any) => U): _Map_<K, U>;
|
|
10
|
+
flatMap<U>(f: (value: any) => _Map_<K, U>): _Map_<K, U>;
|
|
11
|
+
get(key: K): _Option_<V>;
|
|
12
|
+
getOrElse(key: K, defaultValue: V): V;
|
|
13
|
+
orElse(key: K, alternative: _Option_<V>): _Option_<V>;
|
|
14
|
+
} & SafeTraversable<K, V> & _Collection<_Tuple_<[K, V]>>;
|
|
15
|
+
export declare class Map<K, V> implements _Map_<K, V> {
|
|
16
|
+
private values;
|
|
17
|
+
private get entries();
|
|
18
|
+
constructor(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null);
|
|
19
|
+
add(item: _Tuple_<[K, V]>): Map<K, V>;
|
|
20
|
+
remove(value: _Tuple_<[K, V]>): Map<K, V>;
|
|
21
|
+
contains(value: _Tuple_<[K, V]>): boolean;
|
|
22
|
+
get size(): number;
|
|
23
|
+
map<U>(f: (value: V) => U): _Map_<K, U>;
|
|
24
|
+
flatMap<U>(f: (value: V) => _Map_<K, U>): _Map_<K, U>;
|
|
25
|
+
reduce(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
|
|
26
|
+
reduceRight(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
|
|
27
|
+
foldLeft<B>(z: B): (op: (b: B, a: _Tuple_<[K, V]>) => B) => B;
|
|
28
|
+
foldRight<B>(z: B): (op: (a: _Tuple_<[K, V]>, b: B) => B) => B;
|
|
29
|
+
get(key: K): _Option_<V>;
|
|
30
|
+
getOrElse(key: K, defaultValue: V): V;
|
|
31
|
+
get isEmpty(): boolean;
|
|
32
|
+
orElse(key: K, alternative: _Option_<V>): _Option_<V>;
|
|
33
|
+
toList(): _List_<Tuple<[K, V]>>;
|
|
34
|
+
toSet(): _Set_<Tuple<[K, V]>>;
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Map, _Map_ } from "./Map";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { _Functor_, Type } from "../functor";
|
|
2
|
+
import { _Traversable_ } from "../index";
|
|
3
|
+
import { _Iterable_ } from "../iterable";
|
|
4
|
+
export type _Option_<T extends Type> = {
|
|
5
|
+
get(): T;
|
|
6
|
+
getOrElse(defaultValue: T): T;
|
|
7
|
+
orElse(alternative: _Option_<T>): _Option_<T>;
|
|
8
|
+
map<U extends Type>(f: (value: T) => U): _Option_<U>;
|
|
9
|
+
flatMap<U extends Type>(f: (value: T) => _Option_<U>): _Option_<U>;
|
|
10
|
+
toList(): _Iterable_<T>;
|
|
11
|
+
valueOf(): Object;
|
|
12
|
+
} & _Traversable_<T> & _Functor_<T>;
|
|
13
|
+
export declare class Some<A extends Type> implements _Option_<A> {
|
|
14
|
+
private value;
|
|
15
|
+
constructor(value: A);
|
|
16
|
+
get isEmpty(): boolean;
|
|
17
|
+
get(): A;
|
|
18
|
+
getOrElse(defaultValue: A): A;
|
|
19
|
+
orElse(alternative: _Option_<A>): _Option_<A>;
|
|
20
|
+
map<U extends Type>(f: (value: A) => U): _Option_<U>;
|
|
21
|
+
flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
|
|
22
|
+
reduce<U>(f: (acc: U, value: A) => U): U;
|
|
23
|
+
reduceRight<U>(f: (acc: U, value: A) => U): U;
|
|
24
|
+
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
25
|
+
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
26
|
+
toList(): _Iterable_<A>;
|
|
27
|
+
contains(value: A): boolean;
|
|
28
|
+
get size(): number;
|
|
29
|
+
}
|
|
30
|
+
export declare class None<A extends Type> implements _Option_<A> {
|
|
31
|
+
get isEmpty(): boolean;
|
|
32
|
+
get(): A;
|
|
33
|
+
getOrElse(defaultValue: A): A;
|
|
34
|
+
orElse(alternative: _Option_<A>): _Option_<A>;
|
|
35
|
+
map<U extends Type>(f: (value: A) => U): _Option_<U>;
|
|
36
|
+
flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
|
|
37
|
+
reduce(f: (acc: A, value: A) => A): A;
|
|
38
|
+
reduceRight(f: (b: A, a: A) => A): A;
|
|
39
|
+
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
40
|
+
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
41
|
+
toList(): _Iterable_<A>;
|
|
42
|
+
contains(value: A): boolean;
|
|
43
|
+
get size(): number;
|
|
44
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { None, _Option_, Some } from "./Option";
|
|
2
|
+
export declare const option: <T extends unknown>(value?: T) => _Option_<T>;
|
|
3
|
+
export declare const some: <T extends unknown>(value: T) => _Option_<T>;
|
|
4
|
+
export declare const none: <T extends unknown>() => _Option_<T>;
|
|
5
|
+
export { _Option_, Some, None };
|
package/lib/set/Set.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _Iterable_, Seq } from "../iterable";
|
|
2
|
+
import { _List_ } from "../list";
|
|
3
|
+
import { _Collection } from "../collections";
|
|
4
|
+
export type _Set_<T> = {
|
|
5
|
+
has(value: T): boolean;
|
|
6
|
+
} & _Iterable_<T> & _Collection<T>;
|
|
7
|
+
export declare class Set<A> extends Seq<A> implements _Set_<A> {
|
|
8
|
+
constructor(iterable?: Iterable<A> | _Iterable_<A>);
|
|
9
|
+
add(value: A): Set<A>;
|
|
10
|
+
remove(value: A): Set<A>;
|
|
11
|
+
contains(value: A): boolean;
|
|
12
|
+
has(value: A): boolean;
|
|
13
|
+
map<B>(f: (a: A) => B): Set<B>;
|
|
14
|
+
flatMap<B>(f: (a: A) => _Iterable_<B>): Set<B>;
|
|
15
|
+
toList(): _List_<A>;
|
|
16
|
+
toSet(): _Set_<A>;
|
|
17
|
+
toString(): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Set, _Set_ } from "./Set";
|
package/lib/try/Try.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Either } from "../either";
|
|
2
|
+
export type _Try_<T> = {
|
|
3
|
+
isSuccess(): boolean;
|
|
4
|
+
isFailure(): boolean;
|
|
5
|
+
getOrElse(defaultValue: T): T;
|
|
6
|
+
orElse(alternative: _Try_<T>): _Try_<T>;
|
|
7
|
+
toEither(): Either<Error, T>;
|
|
8
|
+
};
|
|
9
|
+
export declare class Try<T> implements _Try_<T> {
|
|
10
|
+
private readonly value;
|
|
11
|
+
private readonly error;
|
|
12
|
+
private constructor();
|
|
13
|
+
static of<T>(f: () => T): _Try_<T>;
|
|
14
|
+
isSuccess(): boolean;
|
|
15
|
+
isFailure(): boolean;
|
|
16
|
+
getOrElse(defaultValue: T): T;
|
|
17
|
+
orElse(alternative: _Try_<T>): _Try_<T>;
|
|
18
|
+
toEither(): Either<Error, T>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { _Try_, Try } from "./Try";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArrayType, _ArrayFunctor_ } from "../functor";
|
|
2
|
+
export type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
|
|
3
|
+
get(index: number): T[number];
|
|
4
|
+
getAs<U>(index: number, f?: (item: T) => boolean): U;
|
|
5
|
+
map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
|
|
6
|
+
flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
|
|
7
|
+
};
|
|
8
|
+
export declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
|
|
9
|
+
private readonly values;
|
|
10
|
+
constructor(values: T);
|
|
11
|
+
map<U extends ArrayType>(f: (value: T) => U): Tuple<U>;
|
|
12
|
+
flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>;
|
|
13
|
+
get(index: number): T[number];
|
|
14
|
+
getAs<U>(index: number, f?: (item: T) => boolean): U;
|
|
15
|
+
toArray(): T;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tuple, _Tuple_ } from "./Tuple";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isIterable: <T>(value: any) => value is Iterable<T>;
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A smallish functional library for TypeScript",
|
|
5
5
|
"author": "jordan.burke@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"url": "https://github.com/jordanburke/
|
|
7
|
+
"url": "https://github.com/jordanburke/functype",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@types/node": "^20.
|
|
9
|
+
"@types/node": "^20.14.15",
|
|
10
10
|
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
11
11
|
"@typescript-eslint/parser": "^7.5.0",
|
|
12
12
|
"@types/jest": "29.5.12",
|
|
13
13
|
"cross-env": "^7.0.3",
|
|
14
|
-
"eslint": "^
|
|
14
|
+
"eslint": "^9.9.0",
|
|
15
15
|
"eslint-config-prettier": "^9.1.0",
|
|
16
16
|
"eslint-plugin-import": "^2.29.1",
|
|
17
|
-
"eslint-plugin-prettier": "^5.1
|
|
18
|
-
"eslint-plugin-simple-import-sort": "^12.
|
|
19
|
-
"jest": "29.7.0",
|
|
20
|
-
"prettier": "^3.
|
|
21
|
-
"rimraf": "^
|
|
22
|
-
"tsup": "^8.
|
|
23
|
-
"ts-jest": "^29.
|
|
17
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
18
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
19
|
+
"jest": "^29.7.0",
|
|
20
|
+
"prettier": "^3.3.3",
|
|
21
|
+
"rimraf": "^6.0.1",
|
|
22
|
+
"tsup": "^8.2.4",
|
|
23
|
+
"ts-jest": "^29.2.4",
|
|
24
24
|
"ts-node": "^10.9.2",
|
|
25
|
-
"typescript": "^5.4
|
|
25
|
+
"typescript": "^5.5.4"
|
|
26
26
|
},
|
|
27
27
|
"main": "./dist/index.js",
|
|
28
28
|
"module": "./dist/index.mjs",
|
package/dist/chunk-4P46BMZQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('./chunk-V5UFW2E4.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunkCPB6NX2Sjs = require('./chunk-CPB6NX2S.js');var _chunkLO5XBCIYjs = require('./chunk-LO5XBCIY.js');var _chunkD22QKJZOjs = require('./chunk-D22QKJZO.js');var i=class r{constructor(e){_chunkD22QKJZOjs.a.call(void 0, this,"values");this.values=new (0, _chunk5VTXJIR3js.a)(e)}get entries(){return Array.from(this.values.entries()).map(([e,t])=>new (0, _chunkV5UFW2E4js.a)([e,t]))}add(e){return new r(this.values.set(e[0],e[1]).entries())}remove(e){let t=new r([...this.values.entries()]);return t.values.delete(e[0])?t:this}contains(e){return this.values.get(e[0])===e[1]}get size(){return this.values.size}map(e){return new r(Array.from(this.values.entries()).map(t=>[t[0],e(t[1])]))}flatMap(e){let t=[];for(let[n,V]of this.values.entries()){let l=e(V);if(l instanceof r)for(let[f,m]of l.values.entries())t.push([f,m])}return new r(t)}reduce(e){return new (0, _chunkLO5XBCIYjs.f)(this.entries).reduce(e)}reduceRight(e){return new (0, _chunkLO5XBCIYjs.f)(this.entries).reduceRight(e)}foldLeft(e){let t=new (0, _chunkLO5XBCIYjs.f)(this.entries);return n=>t.foldLeft(e)(n)}foldRight(e){let t=new (0, _chunkLO5XBCIYjs.f)(this.entries);return n=>t.foldRight(e)(n)}get(e){return _chunkLO5XBCIYjs.c.call(void 0, this.values.get(e))}getOrElse(e,t){return _chunkLO5XBCIYjs.c.call(void 0, this.values.get(e)).getOrElse(t)}get isEmpty(){return this.values.size===0}orElse(e,t){let n=_chunkLO5XBCIYjs.c.call(void 0, this.values.get(e));return t}toList(){return new (0, _chunkCPB6NX2Sjs.b)(this.entries)}toSet(){return new (0, _chunkCPB6NX2Sjs.a)(this.entries)}toString(){return`Map(${this.entries.toString()})`}},U=new i([["a",1],["b",2],["c",3]]);exports.a = i;
|
package/dist/chunk-7JTQ2BTE.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as K}from"./chunk-2XH6TPQK.mjs";import{a as _}from"./chunk-377WQNCB.mjs";import{a as u,b as o}from"./chunk-UVR6IELR.mjs";import{c as a,f as s}from"./chunk-WMSIRQ3W.mjs";import{a as p}from"./chunk-U37JTC3U.mjs";var i=class r{constructor(e){p(this,"values");this.values=new _(e)}get entries(){return Array.from(this.values.entries()).map(([e,t])=>new K([e,t]))}add(e){return new r(this.values.set(e[0],e[1]).entries())}remove(e){let t=new r([...this.values.entries()]);return t.values.delete(e[0])?t:this}contains(e){return this.values.get(e[0])===e[1]}get size(){return this.values.size}map(e){return new r(Array.from(this.values.entries()).map(t=>[t[0],e(t[1])]))}flatMap(e){let t=[];for(let[n,V]of this.values.entries()){let l=e(V);if(l instanceof r)for(let[f,m]of l.values.entries())t.push([f,m])}return new r(t)}reduce(e){return new s(this.entries).reduce(e)}reduceRight(e){return new s(this.entries).reduceRight(e)}foldLeft(e){let t=new s(this.entries);return n=>t.foldLeft(e)(n)}foldRight(e){let t=new s(this.entries);return n=>t.foldRight(e)(n)}get(e){return a(this.values.get(e))}getOrElse(e,t){return a(this.values.get(e)).getOrElse(t)}get isEmpty(){return this.values.size===0}orElse(e,t){let n=a(this.values.get(e));return t}toList(){return new o(this.entries)}toSet(){return new u(this.entries)}toString(){return`Map(${this.entries.toString()})`}},U=new i([["a",1],["b",2],["c",3]]);export{i as a};
|
package/dist/chunk-GZIDEEAG.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,b as r}from"./chunk-S5YAJ7CP.mjs";var o=t=>new r(t),i=t=>new e(t);export{o as a,i as b};
|
package/dist/chunk-HF33BEHO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCPB6NX2Sjs = require('./chunk-CPB6NX2S.js');var _chunkLO5XBCIYjs = require('./chunk-LO5XBCIY.js');var u=class e{constructor(t){this.value=t}isLeft(){return!1}isRight(){return!0}map(t){return new e(t(this.value))}flatMap(t){return t(this.value)}toOption(){return _chunkLO5XBCIYjs.d.call(void 0, this.value)}toList(){return new (0, _chunkCPB6NX2Sjs.b)([this.value])}},n= exports.b =class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}toOption(){return _chunkLO5XBCIYjs.e.call(void 0, )}toList(){return new _chunkCPB6NX2Sjs.b}};exports.a = u; exports.b = n;
|
package/dist/chunk-LBQXRIXP.mjs
DELETED
|
File without changes
|
package/dist/chunk-LLZGG3YT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHF33BEHOjs = require('./chunk-HF33BEHO.js');var o=t=>new (0, _chunkHF33BEHOjs.b)(t),i= exports.b =t=>new (0, _chunkHF33BEHOjs.a)(t);exports.a = o; exports.b = i;
|
package/dist/chunk-TVZBBVEV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|