functype 0.4.2 → 0.8.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/chunk-2I2NKDFN.mjs +1 -0
- package/dist/chunk-3Y43FJKZ.mjs +1 -0
- package/dist/chunk-4AEODSGH.mjs +1 -0
- package/dist/chunk-4PGXHDAS.js +1 -0
- package/dist/chunk-E3BAZBU2.js +1 -0
- package/dist/chunk-E6RS47F7.js +1 -0
- package/dist/chunk-FMHIRYL5.mjs +1 -0
- package/dist/chunk-GPS3OL5F.mjs +1 -0
- package/dist/chunk-HJAAA6CD.mjs +1 -0
- package/dist/chunk-KWPKGISB.js +1 -0
- package/dist/chunk-OXLZ6UIZ.js +1 -0
- package/dist/chunk-PMZTOIT2.js +1 -0
- package/dist/chunk-REXFLQTJ.js +1 -0
- package/dist/chunk-TVCOFH5I.js +1 -0
- package/dist/chunk-VK5GL6NM.mjs +1 -0
- package/dist/chunk-VUD7L2T6.mjs +1 -0
- package/dist/chunk-WDHUQRFT.js +1 -0
- package/dist/chunk-ZMF3MVW7.mjs +1 -0
- package/dist/collections/index.d.mts +1 -1
- package/dist/collections/index.d.ts +1 -1
- package/dist/either/Either.d.mts +1 -1
- package/dist/either/Either.d.ts +1 -1
- package/dist/either/Either.js +1 -1
- package/dist/either/Either.mjs +1 -1
- package/dist/either/index.d.mts +1 -1
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.js +1 -1
- package/dist/either/index.mjs +1 -1
- package/dist/error/ParseError.d.mts +6 -2
- package/dist/error/ParseError.d.ts +6 -2
- package/dist/error/ParseError.js +1 -1
- package/dist/error/ParseError.mjs +1 -1
- package/dist/functor/index.d.mts +11 -11
- package/dist/functor/index.d.ts +11 -11
- package/dist/index-BB5a793T.d.mts +208 -0
- package/dist/index-DyWcaZaG.d.ts +208 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterable/Seq.d.mts +1 -1
- package/dist/iterable/Seq.d.ts +1 -1
- package/dist/iterable/Seq.js +1 -1
- package/dist/iterable/Seq.mjs +1 -1
- package/dist/iterable/index.d.mts +1 -1
- package/dist/iterable/index.d.ts +1 -1
- package/dist/iterable/index.js +1 -1
- package/dist/iterable/index.mjs +1 -1
- package/dist/list/List.d.mts +1 -1
- package/dist/list/List.d.ts +1 -1
- package/dist/list/List.js +1 -1
- package/dist/list/List.mjs +1 -1
- package/dist/list/index.d.mts +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +1 -1
- package/dist/list/index.mjs +1 -1
- package/dist/map/Map.d.mts +1 -1
- package/dist/map/Map.d.ts +1 -1
- package/dist/map/Map.js +1 -1
- package/dist/map/Map.mjs +1 -1
- package/dist/map/index.d.mts +1 -1
- package/dist/map/index.d.ts +1 -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 +1 -1
- package/dist/option/Option.d.ts +1 -1
- package/dist/option/Option.js +1 -1
- package/dist/option/Option.mjs +1 -1
- package/dist/option/index.d.mts +1 -1
- package/dist/option/index.d.ts +1 -1
- package/dist/option/index.js +1 -1
- package/dist/option/index.mjs +1 -1
- package/dist/set/Set.d.mts +1 -1
- package/dist/set/Set.d.ts +1 -1
- package/dist/set/Set.js +1 -1
- package/dist/set/Set.mjs +1 -1
- package/dist/set/index.d.mts +1 -1
- package/dist/set/index.d.ts +1 -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 +1 -1
- package/dist/try/Try.d.ts +1 -1
- package/dist/try/Try.js +1 -1
- package/dist/try/Try.mjs +1 -1
- package/dist/try/index.d.mts +1 -1
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/Tuple.d.mts +7 -15
- package/dist/tuple/Tuple.d.ts +7 -15
- package/dist/tuple/Tuple.js +1 -1
- package/dist/tuple/Tuple.mjs +1 -1
- package/dist/tuple/index.d.mts +0 -1
- package/dist/tuple/index.d.ts +0 -1
- package/dist/tuple/index.js +1 -1
- package/dist/tuple/index.mjs +1 -1
- package/dist/util/index.d.mts +1 -1
- package/dist/util/index.d.ts +1 -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 +6 -6
- package/lib/either/Either.d.ts +28 -28
- package/lib/either/index.d.ts +1 -1
- package/lib/error/ParseError.d.ts +6 -2
- package/lib/functor/index.d.ts +10 -10
- package/lib/index.d.ts +7 -4
- package/lib/iterable/Seq.d.ts +27 -24
- package/lib/iterable/index.d.ts +7 -7
- package/lib/list/List.d.ts +19 -21
- package/lib/list/index.d.ts +4 -3
- package/lib/map/Map.d.ts +14 -35
- package/lib/map/index.d.ts +1 -1
- package/lib/option/Option.d.ts +28 -40
- package/lib/option/index.d.ts +6 -5
- package/lib/set/Set.d.ts +15 -18
- package/lib/set/index.d.ts +1 -1
- package/lib/try/Try.d.ts +24 -18
- package/lib/try/index.d.ts +1 -1
- package/lib/tuple/Tuple.d.ts +6 -13
- package/lib/tuple/index.d.ts +5 -1
- package/lib/util/index.d.ts +1 -1
- package/package.json +6 -6
- package/dist/chunk-2XH6TPQK.mjs +0 -1
- package/dist/chunk-35UIDXTO.js +0 -1
- package/dist/chunk-3APFKSCC.js +0 -1
- package/dist/chunk-3EH27NX2.js +0 -1
- package/dist/chunk-74TKYQJS.mjs +0 -0
- package/dist/chunk-BYDMB2VV.js +0 -1
- package/dist/chunk-CFYIJKWF.mjs +0 -1
- package/dist/chunk-GTO34VMN.mjs +0 -1
- package/dist/chunk-HC3O3O2B.mjs +0 -1
- package/dist/chunk-HOO2EPER.mjs +0 -1
- package/dist/chunk-IC6AOOR5.mjs +0 -1
- package/dist/chunk-JR557W27.mjs +0 -1
- package/dist/chunk-KY3WKBLM.mjs +0 -1
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-QQAQYRPV.js +0 -1
- package/dist/chunk-RM3O3IPT.js +0 -1
- package/dist/chunk-SKJIJETA.js +0 -1
- package/dist/chunk-T7AA7TJX.mjs +0 -1
- package/dist/chunk-TYHKMGLC.mjs +0 -1
- package/dist/chunk-V5UFW2E4.js +0 -1
- package/dist/chunk-XVHCBGUW.js +0 -1
- package/dist/chunk-ZTL76QDL.js +0 -1
- package/dist/index-Dbjb4MUT.d.ts +0 -232
- package/dist/index-UMWeD2QH.d.mts +0 -232
package/dist/tuple/Tuple.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import { ArrayType,
|
|
1
|
+
import { ArrayType, ArrayFunctor } from '../functor/index.js';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
get(index:
|
|
5
|
-
getAs<U>(index: number, f?: (item: T) => boolean): U;
|
|
6
|
-
map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
|
|
7
|
-
flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
|
|
8
|
-
toArray(): T;
|
|
9
|
-
};
|
|
10
|
-
declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
|
|
11
|
-
private readonly values;
|
|
12
|
-
constructor(values: T);
|
|
3
|
+
type Tuple<T extends ArrayType> = {
|
|
4
|
+
get<K extends number>(index: K): T[K];
|
|
13
5
|
map<U extends ArrayType>(f: (value: T) => U): Tuple<U>;
|
|
14
6
|
flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>;
|
|
15
|
-
get(index: number): T[number];
|
|
16
|
-
getAs<U>(index: number, f?: (item: T) => boolean): U;
|
|
17
7
|
toArray(): T;
|
|
18
|
-
|
|
8
|
+
[Symbol.iterator](): Iterator<T[number]>;
|
|
9
|
+
} & ArrayFunctor<T>;
|
|
10
|
+
declare const Tuple: <T extends ArrayType>(values: T) => Tuple<T>;
|
|
19
11
|
|
|
20
|
-
export { Tuple
|
|
12
|
+
export { Tuple };
|
package/dist/tuple/Tuple.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOXLZ6UIZjs = require('../chunk-OXLZ6UIZ.js');exports.Tuple = _chunkOXLZ6UIZjs.a;
|
package/dist/tuple/Tuple.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-2I2NKDFN.mjs";export{a as Tuple};
|
package/dist/tuple/index.d.mts
CHANGED
package/dist/tuple/index.d.ts
CHANGED
package/dist/tuple/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 _chunkE3BAZBU2js = require('../chunk-E3BAZBU2.js');var _chunkOXLZ6UIZjs = require('../chunk-OXLZ6UIZ.js');exports.Tuple = _chunkOXLZ6UIZjs.a; exports.t = _chunkE3BAZBU2js.a; exports.tuple = _chunkE3BAZBU2js.b;
|
package/dist/tuple/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as c}from"../chunk-
|
|
1
|
+
import{a as b,b as c}from"../chunk-4AEODSGH.mjs";import{a}from"../chunk-2I2NKDFN.mjs";export{a as Tuple,b as t,c as tuple};
|
package/dist/util/index.d.mts
CHANGED
package/dist/util/index.d.ts
CHANGED
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 _chunk4PGXHDASjs = require('../chunk-4PGXHDAS.js');require('../chunk-TVCOFH5I.js');require('../chunk-KWPKGISB.js');require('../chunk-3VJERXBP.js');var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');require('../chunk-WDHUQRFT.js');require('../chunk-BNNK42JC.js');var n=s=>{let r=parseInt(s,10);return isNaN(r)?_chunk4PGXHDASjs.a.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunk4PGXHDASjs.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-3Y43FJKZ.mjs";import"../chunk-HJAAA6CD.mjs";import"../chunk-GPS3OL5F.mjs";import"../chunk-HA5XD5KC.mjs";import{a as o}from"../chunk-VK5GL6NM.mjs";import"../chunk-FMHIRYL5.mjs";import"../chunk-RRAIFS3D.mjs";var n=s=>{let r=parseInt(s,10);return isNaN(r)?e(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');
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');exports.isIterable = _chunkBNNK42JCjs.a;
|
package/dist/util/isIterable.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-RRAIFS3D.mjs";
|
|
1
|
+
import{a}from"../chunk-RRAIFS3D.mjs";export{a as isIterable};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export type
|
|
4
|
-
toList():
|
|
5
|
-
toSet():
|
|
1
|
+
import { List } from "../list";
|
|
2
|
+
import { Set } from "../set";
|
|
3
|
+
export type Converters<A> = {
|
|
4
|
+
toList(): List<A>;
|
|
5
|
+
toSet(): Set<A>;
|
|
6
6
|
toString(): string;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
8
|
+
export type Collection<A> = Converters<A>;
|
package/lib/either/Either.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Functor, Type } from "../functor";
|
|
2
2
|
import { List } from "../list";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { Option } from "../option";
|
|
4
|
+
import { Typeable } from "../index";
|
|
5
|
+
export type Either<L extends Type, R extends Type> = {
|
|
6
|
+
readonly _tag: "Left" | "Right";
|
|
5
7
|
value: L | R;
|
|
6
|
-
isLeft()
|
|
7
|
-
isRight()
|
|
8
|
-
map<U>(f: (value: R) => U)
|
|
9
|
-
flatMap<U>(f: (value: R) => Either<L, U>)
|
|
10
|
-
toOption()
|
|
11
|
-
toList()
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
isLeft: () => boolean;
|
|
9
|
+
isRight: () => boolean;
|
|
10
|
+
map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
|
|
11
|
+
flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
|
|
12
|
+
toOption: () => Option<R>;
|
|
13
|
+
toList: () => List<R>;
|
|
14
|
+
valueOf: () => {
|
|
15
|
+
_tag: "Left" | "Right";
|
|
16
|
+
value: L | R;
|
|
17
|
+
};
|
|
18
|
+
toString: () => string;
|
|
19
|
+
} & Functor<R> & Typeable;
|
|
20
|
+
export declare const Right: <L, R>(value: R) => Either<L, R>;
|
|
21
|
+
export declare const Left: <L, R>(value: L) => Either<L, R>;
|
|
22
|
+
export declare const isRight: <L, R>(either: Either<L, R>) => either is Either<L, R> & {
|
|
14
23
|
value: R;
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
};
|
|
25
|
+
export declare const isLeft: <L, R>(either: Either<L, R>) => either is Either<L, R> & {
|
|
24
26
|
value: L;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
toList(): List<R>;
|
|
32
|
-
}
|
|
27
|
+
};
|
|
28
|
+
export declare const tryCatch: <L, R>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
|
|
29
|
+
export declare const match: <L, R, U>(either: Either<L, R>, patterns: {
|
|
30
|
+
Left: (value: L) => U;
|
|
31
|
+
Right: (value: R) => U;
|
|
32
|
+
}) => U;
|
package/lib/either/index.d.ts
CHANGED
package/lib/functor/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export type SingleType =
|
|
1
|
+
export type SingleType = unknown;
|
|
2
2
|
export type ArrayType = SingleType[];
|
|
3
3
|
export type Type = SingleType | ArrayType;
|
|
4
|
-
export type
|
|
5
|
-
map(f: (value: A) => Type):
|
|
6
|
-
flatMap(f: (value: A) =>
|
|
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
7
|
};
|
|
8
|
-
export type
|
|
9
|
-
map<B extends Type>(f: (value: A) => B):
|
|
10
|
-
flatMap<B extends Type>(f: (value: A) =>
|
|
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
11
|
};
|
|
12
|
-
export type
|
|
13
|
-
map<U extends ArrayType>(f: (value: A) => U):
|
|
14
|
-
flatMap<U extends ArrayType>(f: (value: A) =>
|
|
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
15
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type
|
|
1
|
+
import { Functor, Type } from "./functor";
|
|
2
|
+
export type Traversable<A extends Type> = Functor<A> & {
|
|
3
3
|
get size(): number;
|
|
4
4
|
get isEmpty(): boolean;
|
|
5
5
|
contains(value: A): boolean;
|
|
@@ -8,12 +8,15 @@ export type _Traversable_<A extends Type> = _Functor_<A> & {
|
|
|
8
8
|
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
9
9
|
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
10
10
|
};
|
|
11
|
+
export * from "./either";
|
|
11
12
|
export * from "./functor";
|
|
12
13
|
export * from "./iterable";
|
|
13
14
|
export * from "./list";
|
|
14
15
|
export * from "./map";
|
|
15
16
|
export * from "./option";
|
|
16
|
-
export * from "./either";
|
|
17
17
|
export * from "./set";
|
|
18
|
-
export * from "./tuple";
|
|
19
18
|
export * from "./try";
|
|
19
|
+
export * from "./tuple";
|
|
20
|
+
export type Typeable = {
|
|
21
|
+
_tag: Type;
|
|
22
|
+
};
|
package/lib/iterable/Seq.d.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
+
import { Option } from "../option";
|
|
1
2
|
import { _Iterable_ } from "./index";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
3
|
+
export type Seq<A> = {
|
|
4
|
+
readonly length: number;
|
|
5
|
+
readonly [Symbol.iterator]: () => Iterator<A>;
|
|
6
|
+
map: <B>(f: (a: A) => B) => Seq<B>;
|
|
7
|
+
flatMap: <B>(f: (a: A) => _Iterable_<B>) => Seq<B>;
|
|
8
|
+
forEach: (f: (a: A) => void) => void;
|
|
9
|
+
count: (p: (x: A) => boolean) => number;
|
|
10
|
+
exists: (p: (a: A) => boolean) => boolean;
|
|
11
|
+
filter: (p: (a: A) => boolean) => Seq<A>;
|
|
12
|
+
filterNot: (p: (a: A) => boolean) => Seq<A>;
|
|
13
|
+
find: (p: (a: A) => boolean) => Option<A>;
|
|
14
|
+
readonly head: A;
|
|
15
|
+
readonly headOption: Option<A>;
|
|
16
|
+
readonly isEmpty: boolean;
|
|
17
|
+
readonly size: number;
|
|
18
|
+
toArray: () => A[];
|
|
19
|
+
reduce: (f: (prev: A, curr: A) => A) => A;
|
|
20
|
+
reduceRight: (f: (prev: A, curr: A) => A) => A;
|
|
21
|
+
foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
|
|
22
|
+
foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
|
|
23
|
+
valueOf: () => {
|
|
24
|
+
values: A[];
|
|
25
|
+
};
|
|
26
|
+
} & _Iterable_<A>;
|
|
27
|
+
export declare const createSeq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
|
|
28
|
+
export declare const Seq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
|
package/lib/iterable/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Functor, Type } from "../functor";
|
|
2
|
+
import { Option } from "../option";
|
|
3
3
|
export type _Iterable_<A extends Type> = {
|
|
4
4
|
count(p: (x: A) => boolean): number;
|
|
5
|
-
find(p: (a: A) => boolean):
|
|
5
|
+
find(p: (a: A) => boolean): Option<A>;
|
|
6
6
|
forEach(f: (a: A) => void): void;
|
|
7
|
-
exists(p: (a: A) => boolean):
|
|
7
|
+
exists(p: (a: A) => boolean): boolean;
|
|
8
8
|
filter(p: (a: A) => boolean): _Iterable_<A>;
|
|
9
9
|
filterNot(p: (a: A) => boolean): _Iterable_<A>;
|
|
10
10
|
reduce(f: (b: A, a: A) => A): A;
|
|
@@ -12,11 +12,11 @@ export type _Iterable_<A extends Type> = {
|
|
|
12
12
|
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
13
13
|
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
14
14
|
get head(): A;
|
|
15
|
-
get headOption():
|
|
15
|
+
get headOption(): Option<A>;
|
|
16
16
|
get isEmpty(): boolean;
|
|
17
17
|
map<B extends Type>(f: (a: A) => B): _Iterable_<B>;
|
|
18
|
-
flatMap<B extends Type>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
|
|
18
|
+
flatMap<B extends Type>(f: (a: A) => _Iterable_<B> | Iterable<B>): _Iterable_<B>;
|
|
19
19
|
get size(): number;
|
|
20
20
|
toArray(): readonly A[];
|
|
21
|
-
} &
|
|
21
|
+
} & Functor<A>;
|
|
22
22
|
export { Seq } from "./Seq";
|
package/lib/list/List.d.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
+
import { Collection } from "../collections";
|
|
1
2
|
import { _Iterable_ } from "../iterable";
|
|
2
|
-
import {
|
|
3
|
-
import { _Collection } from "../collections";
|
|
3
|
+
import { Option } from "../option";
|
|
4
4
|
import { Set } from "../set";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
toString(): string;
|
|
23
|
-
}
|
|
5
|
+
export type List<A> = {
|
|
6
|
+
add: (item: A) => List<A>;
|
|
7
|
+
map: <B>(f: (a: A) => B) => List<B>;
|
|
8
|
+
flatMap: <B>(f: (a: A) => _Iterable_<B>) => List<B>;
|
|
9
|
+
remove: (value: A) => List<A>;
|
|
10
|
+
contains: (value: A) => boolean;
|
|
11
|
+
removeAt: (index: number) => List<A>;
|
|
12
|
+
get: (index: number) => Option<A>;
|
|
13
|
+
concat: (other: List<A>) => List<A>;
|
|
14
|
+
toList: () => List<A>;
|
|
15
|
+
toSet: () => Set<A>;
|
|
16
|
+
toString: () => string;
|
|
17
|
+
valueOf: () => {
|
|
18
|
+
values: A[];
|
|
19
|
+
};
|
|
20
|
+
} & ArrayLike<A> & _Iterable_<A> & Collection<A>;
|
|
21
|
+
export declare const List: <A>(values?: Iterable<A> | _Iterable_<A>) => List<A>;
|
package/lib/list/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Type } from "../functor";
|
|
2
|
+
import { List } from "./List";
|
|
3
|
+
declare const list: <T extends Type>(items: T[] | undefined) => List<T>;
|
|
4
|
+
export { list, List };
|
package/lib/map/Map.d.ts
CHANGED
|
@@ -1,37 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
map<U>(f: (value:
|
|
10
|
-
flatMap<
|
|
11
|
-
get(key: K):
|
|
1
|
+
import { Collection } from "../collections";
|
|
2
|
+
import { _Iterable_, Traversable } from "../index";
|
|
3
|
+
import { Option } from "../option";
|
|
4
|
+
import { Tuple } from "../tuple";
|
|
5
|
+
type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
|
|
6
|
+
export type Map<K, V> = {
|
|
7
|
+
add(item: Tuple<[K, V]>): Map<K, V>;
|
|
8
|
+
remove(value: K): Map<K, V>;
|
|
9
|
+
map<U>(f: (value: V) => U): Map<K, U>;
|
|
10
|
+
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => _Iterable_<[K2, V2]>): Map<K2, V2>;
|
|
11
|
+
get(key: K): Option<V>;
|
|
12
12
|
getOrElse(key: K, defaultValue: V): V;
|
|
13
|
-
orElse(key: K, alternative:
|
|
14
|
-
} & SafeTraversable<K, V> &
|
|
15
|
-
export declare
|
|
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
|
-
}
|
|
13
|
+
orElse(key: K, alternative: Option<V>): Option<V>;
|
|
14
|
+
} & SafeTraversable<K, V> & Collection<Tuple<[K, V]>>;
|
|
15
|
+
export declare const Map: <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>;
|
|
37
16
|
export {};
|
package/lib/map/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Map
|
|
1
|
+
export { Map } from "./Map";
|
package/lib/option/Option.d.ts
CHANGED
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Functor, Type } from "../functor";
|
|
2
|
+
import { Traversable, Typeable } from "../index";
|
|
3
3
|
import { _Iterable_ } from "../iterable";
|
|
4
|
-
export type
|
|
4
|
+
export type Option<T extends Type> = {
|
|
5
|
+
readonly _tag: "Some" | "None";
|
|
6
|
+
readonly value: T | undefined;
|
|
7
|
+
isEmpty: boolean;
|
|
5
8
|
get(): T;
|
|
6
9
|
getOrElse(defaultValue: T): T;
|
|
7
|
-
orElse(alternative:
|
|
8
|
-
map<U extends Type>(f: (value: T) => U):
|
|
9
|
-
flatMap<U extends Type>(f: (value: T) =>
|
|
10
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
11
|
+
map<U extends Type>(f: (value: T) => U): Option<U>;
|
|
12
|
+
flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
|
|
13
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
14
|
+
reduceRight<U>(f: (acc: U, value: T) => U): U;
|
|
15
|
+
foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
|
|
16
|
+
foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
|
|
10
17
|
toList(): _Iterable_<T>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
18
|
+
contains(value: T): boolean;
|
|
19
|
+
size: number;
|
|
20
|
+
valueOf(): {
|
|
21
|
+
_tag: "Some" | "None";
|
|
22
|
+
value?: T;
|
|
23
|
+
};
|
|
24
|
+
toString(): string;
|
|
25
|
+
} & Traversable<T> & Functor<T> & Typeable;
|
|
26
|
+
export declare const Some: <T extends Type>(value: T) => Option<T>;
|
|
27
|
+
export declare const None: <T extends Type>() => Option<T>;
|
|
28
|
+
export declare const Option: <T extends Type>(value: T | null | undefined) => Option<T>;
|
|
29
|
+
export declare const match: <T extends Type, U>(option: Option<T>, patterns: {
|
|
30
|
+
Some: (value: T) => U;
|
|
31
|
+
None: () => U;
|
|
32
|
+
}) => U;
|
package/lib/option/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export
|
|
1
|
+
import { Type } from "../functor";
|
|
2
|
+
import { None, Option, Some } from "./Option";
|
|
3
|
+
export declare const option: <T extends Type>(value?: T) => Option<T>;
|
|
4
|
+
export declare const some: <T extends Type>(value: T) => Option<T>;
|
|
5
|
+
export declare const none: <T extends Type>() => Option<T>;
|
|
6
|
+
export { None, Option, Some };
|
package/lib/set/Set.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
toSet(): _Set_<A>;
|
|
17
|
-
toString(): string;
|
|
18
|
-
}
|
|
1
|
+
import { Collection } from "../collections";
|
|
2
|
+
import { _Iterable_ } from "../iterable";
|
|
3
|
+
import { List } from "../list";
|
|
4
|
+
export type Set<A> = {
|
|
5
|
+
add: (value: A) => Set<A>;
|
|
6
|
+
remove: (value: A) => Set<A>;
|
|
7
|
+
contains: (value: A) => boolean;
|
|
8
|
+
has: (value: A) => boolean;
|
|
9
|
+
map: <B>(f: (a: A) => B) => Set<B>;
|
|
10
|
+
flatMap: <B>(f: (a: A) => _Iterable_<B>) => Set<B>;
|
|
11
|
+
toList: () => List<A>;
|
|
12
|
+
toSet: () => Set<A>;
|
|
13
|
+
toString: () => string;
|
|
14
|
+
} & _Iterable_<A> & Collection<A>;
|
|
15
|
+
export declare const Set: <A>(iterable?: Iterable<A> | _Iterable_<A>) => Set<A>;
|
package/lib/set/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Set
|
|
1
|
+
export { Set } from "./Set";
|