fnts 1.7.0 → 1.9.0-rc.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/either/left.d.ts +1 -1
- package/either/operators/bifold/bifold.d.ts +4 -4
- package/either/operators/bifold/bifold.js +6 -4
- package/either/operators/bifold/bifoldl.d.ts +7 -2
- package/either/operators/bifold/bifoldl.js +2 -2
- package/either/operators/bifold/bifoldr.d.ts +7 -2
- package/either/operators/bifold/bifoldr.js +2 -2
- package/either/operators/{bifold-map.d.ts → bifold-map/bifold-map.d.ts} +2 -2
- package/either/operators/{bifold-map.js → bifold-map/bifold-map.js} +9 -6
- package/either/operators/bifold-map/bifoldl-map.d.ts +27 -0
- package/either/operators/bifold-map/bifoldl-map.js +21 -0
- package/either/operators/bifold-map/bifoldr-map.d.ts +27 -0
- package/either/operators/bifold-map/bifoldr-map.js +21 -0
- package/either/operators/bifold-map/index.d.ts +3 -0
- package/either/operators/bifold-map/index.js +9 -0
- package/either/operators/bimap/bimap.js +3 -2
- package/either/operators/bimap/first.js +5 -4
- package/either/operators/bimap/second.js +4 -3
- package/either/operators/bindr.js +3 -2
- package/either/operators/guards.d.ts +4 -4
- package/either/operators/guards.js +6 -6
- package/either/right.d.ts +1 -1
- package/guard.d.ts +1 -1
- package/guard.js +2 -2
- package/maybe/just.d.ts +2 -2
- package/maybe/maybe.d.ts +1 -6
- package/maybe/nothing.d.ts +1 -1
- package/maybe/nothing.js +1 -1
- package/maybe/operators/bind.d.ts +2 -2
- package/maybe/operators/bind.js +3 -2
- package/maybe/operators/fmap.d.ts +2 -2
- package/maybe/operators/fmap.js +4 -3
- package/maybe/operators/fold-map.d.ts +14 -3
- package/maybe/operators/fold-map.js +4 -3
- package/maybe/operators/fold.d.ts +5 -1
- package/maybe/operators/guards.d.ts +4 -4
- package/maybe/operators/guards.js +6 -6
- package/package.json +1 -1
- package/rethrow.d.ts +1 -1
- package/rethrow.js +3 -3
- package/ternary.d.ts +2 -0
- package/ternary.js +2 -0
- package/tsconfig.json +2 -2
package/either/left.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export declare type Left<Value> = {
|
|
|
18
18
|
* Creates the special object with one property, represented as unique symbol
|
|
19
19
|
* key, holding the provided value.
|
|
20
20
|
*/
|
|
21
|
-
export default function left<Value>(value
|
|
21
|
+
export default function left<Value = undefined>(value?: Value): Left<Value>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import { Left } from '../../left';
|
|
5
|
+
import { Right } from '../../right';
|
|
6
6
|
import type { Either } from '../../either';
|
|
7
7
|
/**
|
|
8
8
|
* A type to unwrap either the left or the right value type
|
|
9
9
|
* of the provided `Monad`.
|
|
10
10
|
*/
|
|
11
|
-
export declare type Bifold<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Right<infer RightValue> ? RightValue : never;
|
|
11
|
+
export declare type Bifold<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Right<infer RightValue> ? RightValue : Monad extends Either<infer LeftValue, infer RightValue> ? LeftValue | RightValue : never;
|
|
12
12
|
/**
|
|
13
13
|
* Unwraps either the left or the right value of the provided `monad`.
|
|
14
14
|
*/
|
|
15
|
-
export default function bifold<
|
|
15
|
+
export default function bifold<LeftValue, RightValue>(monad: Either<LeftValue, RightValue>): LeftValue | RightValue;
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* @module Either Operators
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var guards_1 = require("../guards");
|
|
7
|
+
var left_1 = require("../../left");
|
|
8
|
+
var right_1 = require("../../right");
|
|
8
9
|
/**
|
|
9
10
|
* Unwraps either the left or the right value of the provided `monad`.
|
|
10
11
|
*/
|
|
11
12
|
function bifold(monad) {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
return (0, guards_1.isLeft)(monad)
|
|
14
|
+
? monad[left_1.lid]
|
|
15
|
+
: monad[right_1.rid];
|
|
14
16
|
}
|
|
15
17
|
exports.default = bifold;
|
|
@@ -7,9 +7,14 @@ import type { Either } from '../../either';
|
|
|
7
7
|
* A type to unwrap the left value type of the provided `Monad`.
|
|
8
8
|
* If the `Monad` is `Right`, returns `undefined`.
|
|
9
9
|
*/
|
|
10
|
-
export declare type Bifoldl<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : undefined;
|
|
10
|
+
export declare type Bifoldl<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Either<infer LeftValue, any> ? LeftValue | undefined : never;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the left value of the provided `monad`.
|
|
13
13
|
* If the `monad` is `Right`, returns `undefined`.
|
|
14
14
|
*/
|
|
15
|
-
export default function bifoldl<
|
|
15
|
+
export default function bifoldl<LeftValue>(monad: Either<LeftValue, any>): LeftValue | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the left value of the provided `monad`.
|
|
18
|
+
* If the `monad` is `Right`, returns `undefined`.
|
|
19
|
+
*/
|
|
20
|
+
export default function bifoldl<Monad extends Left<any>>(monad: Monad): Bifoldl<Monad>;
|
|
@@ -10,8 +10,8 @@ var left_1 = require("../../left");
|
|
|
10
10
|
* If the `monad` is `Right`, returns `undefined`.
|
|
11
11
|
*/
|
|
12
12
|
function bifoldl(monad) {
|
|
13
|
-
return (
|
|
13
|
+
return (0, guards_1.isLeft)(monad)
|
|
14
14
|
? monad[left_1.lid]
|
|
15
|
-
: undefined
|
|
15
|
+
: undefined;
|
|
16
16
|
}
|
|
17
17
|
exports.default = bifoldl;
|
|
@@ -7,9 +7,14 @@ import type { Either } from '../../either';
|
|
|
7
7
|
* A type to unwrap the right value type of the provided `Monad`.
|
|
8
8
|
* If the `Monad` is `Left`, returns `undefined`.
|
|
9
9
|
*/
|
|
10
|
-
export declare type Bifoldr<Monad extends Either<any, any>> = Monad extends Right<infer RightValue> ? RightValue : undefined;
|
|
10
|
+
export declare type Bifoldr<Monad extends Either<any, any>> = Monad extends Right<infer RightValue> ? RightValue : Monad extends Either<any, infer RightValue> ? RightValue | undefined : never;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the right value of the provided `monad`.
|
|
13
13
|
* If the `monad` is `Left`, returns `undefined`.
|
|
14
14
|
*/
|
|
15
|
-
export default function bifoldr<
|
|
15
|
+
export default function bifoldr<RightValue>(monad: Either<any, RightValue>): RightValue | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the right value of the provided `monad`.
|
|
18
|
+
* If the `monad` is `Left`, returns `undefined`.
|
|
19
|
+
*/
|
|
20
|
+
export default function bifoldr<Monad extends Right<any>>(monad: Monad): Bifoldr<Monad>;
|
|
@@ -10,8 +10,8 @@ var right_1 = require("../../right");
|
|
|
10
10
|
* If the `monad` is `Left`, returns `undefined`.
|
|
11
11
|
*/
|
|
12
12
|
function bifoldr(monad) {
|
|
13
|
-
return (
|
|
13
|
+
return (0, guards_1.isRight)(monad)
|
|
14
14
|
? monad[right_1.rid]
|
|
15
|
-
: undefined
|
|
15
|
+
: undefined;
|
|
16
16
|
}
|
|
17
17
|
exports.default = bifoldr;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import type { Either } from '
|
|
5
|
-
import type { Map } from '
|
|
4
|
+
import type { Either } from '../../either';
|
|
5
|
+
import type { Map } from '../../../types/map';
|
|
6
6
|
/**
|
|
7
7
|
* Maps provided `monad` to a value,
|
|
8
8
|
* then returns it.
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* @module Either Operators
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
6
|
+
var bifold_1 = require("../bifold");
|
|
7
|
+
var compose_1 = require("../../../compose");
|
|
8
|
+
var guards_1 = require("../guards");
|
|
9
|
+
var permutation_3_1 = require("../../../permutation/permutation-3");
|
|
10
|
+
var bifoldl_map_1 = require("./bifoldl-map");
|
|
11
|
+
var bifoldr_map_1 = require("./bifoldr-map");
|
|
11
12
|
function bifoldMap() {
|
|
12
13
|
var args = [];
|
|
13
14
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -22,7 +23,9 @@ function bifoldMap() {
|
|
|
22
23
|
return (0, compose_1.default)(args[1], bifold_1.default)(args[0]);
|
|
23
24
|
}
|
|
24
25
|
return (0, permutation_3_1.default)(function (monad, mapLeft, mapRight) {
|
|
25
|
-
return (0,
|
|
26
|
+
return ((0, guards_1.isLeft)(monad)
|
|
27
|
+
? (0, bifoldl_map_1.default)(monad, mapLeft)
|
|
28
|
+
: (0, bifoldr_map_1.default)(monad, mapRight));
|
|
26
29
|
}).apply(void 0, args);
|
|
27
30
|
}
|
|
28
31
|
exports.default = bifoldMap;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Either Operators
|
|
3
|
+
*/
|
|
4
|
+
import type { Left } from '../../left';
|
|
5
|
+
import type { Either } from '../../either';
|
|
6
|
+
import type { Map } from '../../../types/map';
|
|
7
|
+
import { Bifoldl } from '../bifold/bifoldl';
|
|
8
|
+
/**
|
|
9
|
+
* Maps provided `monad`'s left value to a new value,
|
|
10
|
+
* then returns it or `undefined`.
|
|
11
|
+
*/
|
|
12
|
+
export default function bifoldlMap<LeftValue, Value>(map: Map<LeftValue, Value>): (monad: Either<LeftValue, any>) => Value | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Maps provided `monad`'s left value to a new value,
|
|
15
|
+
* then returns it or `undefined`.
|
|
16
|
+
*/
|
|
17
|
+
export default function bifoldlMap<LeftValue, Value>(monad: Either<LeftValue, any>, map: Map<LeftValue, Value>): Value | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Maps provided `monad`'s left value to a new value,
|
|
20
|
+
* then returns it or `undefined`.
|
|
21
|
+
*/
|
|
22
|
+
export default function bifoldlMap<Monad extends Left<any>, Value>(map: Map<Bifoldl<Monad>, Value>): (monad: Monad) => Value;
|
|
23
|
+
/**
|
|
24
|
+
* Maps provided `monad`'s left value to a new value,
|
|
25
|
+
* then returns it or `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
export default function bifoldlMap<Monad extends Left<any>, Value>(monad: Monad, map: Map<Bifoldl<Monad>, Value>): Value;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Either Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var guards_1 = require("../guards");
|
|
7
|
+
var compose_1 = require("../../../compose");
|
|
8
|
+
var bifoldl_1 = require("../bifold/bifoldl");
|
|
9
|
+
var permutation_2_1 = require("../../../permutation/permutation-2");
|
|
10
|
+
function bifoldlMap() {
|
|
11
|
+
var args = [];
|
|
12
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
+
args[_i] = arguments[_i];
|
|
14
|
+
}
|
|
15
|
+
return (0, permutation_2_1.default)(function (monad, map) {
|
|
16
|
+
return (0, guards_1.isLeft)(monad)
|
|
17
|
+
? (0, compose_1.default)(map, bifoldl_1.default)(monad)
|
|
18
|
+
: undefined;
|
|
19
|
+
}).apply(void 0, args);
|
|
20
|
+
}
|
|
21
|
+
exports.default = bifoldlMap;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Either Operators
|
|
3
|
+
*/
|
|
4
|
+
import { Right } from '../../right';
|
|
5
|
+
import type { Either } from '../../either';
|
|
6
|
+
import type { Map } from '../../../types/map';
|
|
7
|
+
import { Bifoldr } from '../bifold/bifoldr';
|
|
8
|
+
/**
|
|
9
|
+
* Maps provided `monad`'s right value to a new value,
|
|
10
|
+
* then returns it or `undefined`.
|
|
11
|
+
*/
|
|
12
|
+
export default function bifoldrMap<RightValue, Value>(map: Map<RightValue, Value>): (monad: Either<any, RightValue>) => Value | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Maps provided `monad`'s right value to a new value,
|
|
15
|
+
* then returns it or `undefined`.
|
|
16
|
+
*/
|
|
17
|
+
export default function bifoldrMap<RightValue, Value>(monad: Either<any, RightValue>, map: Map<RightValue, Value>): Value | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Maps provided `monad`'s right value to a new value,
|
|
20
|
+
* then returns it or `undefined`.
|
|
21
|
+
*/
|
|
22
|
+
export default function bifoldrMap<Monad extends Right<any>, Value>(map: Map<Bifoldr<Monad>, Value>): (monad: Monad) => Value;
|
|
23
|
+
/**
|
|
24
|
+
* Maps provided `monad`'s right value to a new value,
|
|
25
|
+
* then returns it or `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
export default function bifoldrMap<Monad extends Right<any>, Value>(monad: Monad, map: Map<Bifoldr<Monad>, Value>): Value;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Either Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var guards_1 = require("../guards");
|
|
7
|
+
var compose_1 = require("../../../compose");
|
|
8
|
+
var bifoldr_1 = require("../bifold/bifoldr");
|
|
9
|
+
var permutation_2_1 = require("../../../permutation/permutation-2");
|
|
10
|
+
function bifoldrMap() {
|
|
11
|
+
var args = [];
|
|
12
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
+
args[_i] = arguments[_i];
|
|
14
|
+
}
|
|
15
|
+
return (0, permutation_2_1.default)(function (monad, map) {
|
|
16
|
+
return (0, guards_1.isRight)(monad)
|
|
17
|
+
? (0, compose_1.default)(map, bifoldr_1.default)(monad)
|
|
18
|
+
: undefined;
|
|
19
|
+
}).apply(void 0, args);
|
|
20
|
+
}
|
|
21
|
+
exports.default = bifoldrMap;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bifoldrMap = exports.bifoldlMap = exports.default = void 0;
|
|
4
|
+
var bifold_map_1 = require("./bifold-map");
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return bifold_map_1.default; } });
|
|
6
|
+
var bifoldl_map_1 = require("./bifoldl-map");
|
|
7
|
+
Object.defineProperty(exports, "bifoldlMap", { enumerable: true, get: function () { return bifoldl_map_1.default; } });
|
|
8
|
+
var bifoldr_map_1 = require("./bifoldr-map");
|
|
9
|
+
Object.defineProperty(exports, "bifoldrMap", { enumerable: true, get: function () { return bifoldr_map_1.default; } });
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var guards_1 = require("../guards");
|
|
7
|
-
var ternary_1 = require("../../../ternary");
|
|
8
7
|
var permutation_3_1 = require("../../../permutation/permutation-3");
|
|
9
8
|
var first_1 = require("./first");
|
|
10
9
|
var second_1 = require("./second");
|
|
@@ -14,7 +13,9 @@ function bimap() {
|
|
|
14
13
|
args[_i] = arguments[_i];
|
|
15
14
|
}
|
|
16
15
|
return (0, permutation_3_1.default)(function (monad, mapLeft, mapRight) {
|
|
17
|
-
return (0,
|
|
16
|
+
return (0, guards_1.isLeft)(monad)
|
|
17
|
+
? (0, first_1.default)(monad, mapLeft)
|
|
18
|
+
: (0, second_1.default)(monad, mapRight);
|
|
18
19
|
}).apply(void 0, args);
|
|
19
20
|
}
|
|
20
21
|
exports.default = bimap;
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* @module Either Operators
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var left_1 = require("../../left");
|
|
6
7
|
var guards_1 = require("../guards");
|
|
7
|
-
var bifold_1 = require("../bifold");
|
|
8
8
|
var compose_1 = require("../../../compose");
|
|
9
|
-
var
|
|
10
|
-
var left_1 = require("../../left");
|
|
9
|
+
var bifoldl_1 = require("../bifold/bifoldl");
|
|
11
10
|
var identity_1 = require("../../../identity");
|
|
12
11
|
var permutation_2_1 = require("../../../permutation/permutation-2");
|
|
13
12
|
function first() {
|
|
@@ -16,7 +15,9 @@ function first() {
|
|
|
16
15
|
args[_i] = arguments[_i];
|
|
17
16
|
}
|
|
18
17
|
return (0, permutation_2_1.default)(function (monad, mapLeft) {
|
|
19
|
-
return (0,
|
|
18
|
+
return (0, guards_1.isLeft)(monad)
|
|
19
|
+
? (0, compose_1.default)((left_1.default), mapLeft, bifoldl_1.default)(monad)
|
|
20
|
+
: (0, identity_1.default)(monad);
|
|
20
21
|
}).apply(void 0, args);
|
|
21
22
|
}
|
|
22
23
|
exports.default = first;
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* @module Either Operators
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var right_1 = require("../../right");
|
|
6
7
|
var bifold_1 = require("../bifold");
|
|
7
8
|
var guards_1 = require("../guards");
|
|
8
9
|
var compose_1 = require("../../../compose");
|
|
9
|
-
var ternary_1 = require("../../../ternary");
|
|
10
10
|
var identity_1 = require("../../../identity");
|
|
11
|
-
var right_1 = require("../../right");
|
|
12
11
|
var permutation_2_1 = require("../../../permutation/permutation-2");
|
|
13
12
|
function second() {
|
|
14
13
|
var args = [];
|
|
@@ -16,7 +15,9 @@ function second() {
|
|
|
16
15
|
args[_i] = arguments[_i];
|
|
17
16
|
}
|
|
18
17
|
return (0, permutation_2_1.default)(function (monad, mapRight) {
|
|
19
|
-
return (0,
|
|
18
|
+
return (0, guards_1.isRight)(monad)
|
|
19
|
+
? (0, compose_1.default)((right_1.default), mapRight, bifold_1.bifoldr)(monad)
|
|
20
|
+
: (0, identity_1.default)(monad);
|
|
20
21
|
}).apply(void 0, args);
|
|
21
22
|
}
|
|
22
23
|
exports.default = second;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var compose_1 = require("../../compose");
|
|
7
|
-
var ternary_1 = require("../../ternary");
|
|
8
7
|
var identity_1 = require("../../identity");
|
|
9
8
|
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
10
9
|
var bifold_1 = require("./bifold");
|
|
@@ -15,7 +14,9 @@ function bindr() {
|
|
|
15
14
|
args[_i] = arguments[_i];
|
|
16
15
|
}
|
|
17
16
|
return (0, permutation_2_1.default)(function (monad, mapRight) {
|
|
18
|
-
return (0,
|
|
17
|
+
return (0, guards_1.isRight)(monad)
|
|
18
|
+
? (0, compose_1.default)(mapRight, bifold_1.bifoldr)(monad)
|
|
19
|
+
: (0, identity_1.default)(monad);
|
|
19
20
|
}).apply(void 0, args);
|
|
20
21
|
}
|
|
21
22
|
exports.default = bindr;
|
|
@@ -5,13 +5,13 @@ import { Left } from '../left';
|
|
|
5
5
|
import { Right } from '../right';
|
|
6
6
|
import type { Either } from '../either';
|
|
7
7
|
/**
|
|
8
|
-
* Type guard function to tell if the provided `
|
|
8
|
+
* Type guard function to tell if the provided `value` is `Left`.
|
|
9
9
|
*/
|
|
10
|
-
export declare function isLeft<LeftValue>(
|
|
10
|
+
export declare function isLeft<LeftValue>(value: any): value is Left<LeftValue>;
|
|
11
11
|
/**
|
|
12
|
-
* Type guard function to tell if the provided `
|
|
12
|
+
* Type guard function to tell if the provided `value` is `Right`.
|
|
13
13
|
*/
|
|
14
|
-
export declare function isRight<RightValue>(
|
|
14
|
+
export declare function isRight<RightValue>(value: any): value is Right<RightValue>;
|
|
15
15
|
/**
|
|
16
16
|
* Type guard function to tell if the provided `value` is `Either`.
|
|
17
17
|
*/
|
|
@@ -7,17 +7,17 @@ exports.isEither = exports.isRight = exports.isLeft = void 0;
|
|
|
7
7
|
var left_1 = require("../left");
|
|
8
8
|
var right_1 = require("../right");
|
|
9
9
|
/**
|
|
10
|
-
* Type guard function to tell if the provided `
|
|
10
|
+
* Type guard function to tell if the provided `value` is `Left`.
|
|
11
11
|
*/
|
|
12
|
-
function isLeft(
|
|
13
|
-
return Object.prototype.hasOwnProperty.call(
|
|
12
|
+
function isLeft(value) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(value, left_1.lid);
|
|
14
14
|
}
|
|
15
15
|
exports.isLeft = isLeft;
|
|
16
16
|
/**
|
|
17
|
-
* Type guard function to tell if the provided `
|
|
17
|
+
* Type guard function to tell if the provided `value` is `Right`.
|
|
18
18
|
*/
|
|
19
|
-
function isRight(
|
|
20
|
-
return Object.prototype.hasOwnProperty.call(
|
|
19
|
+
function isRight(value) {
|
|
20
|
+
return Object.prototype.hasOwnProperty.call(value, right_1.rid);
|
|
21
21
|
}
|
|
22
22
|
exports.isRight = isRight;
|
|
23
23
|
/**
|
package/either/right.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export declare type Right<Value> = {
|
|
|
18
18
|
* Creates the special object with one property, represented as unique symbol
|
|
19
19
|
* key, holding the provided value.
|
|
20
20
|
*/
|
|
21
|
-
export default function right<Value>(value
|
|
21
|
+
export default function right<Value = undefined>(value?: Value): Right<Value>;
|
package/guard.d.ts
CHANGED
|
@@ -16,4 +16,4 @@ export declare type GuardQualifier<Function extends VariadicFunction> = [
|
|
|
16
16
|
*
|
|
17
17
|
* When no `validator` succeeds, the default executor is run.
|
|
18
18
|
*/
|
|
19
|
-
export default function guard<Function extends VariadicFunction>(...qualifiers: [...GuardQualifier<Function>[], Function]):
|
|
19
|
+
export default function guard<Function extends VariadicFunction>(...qualifiers: [...GuardQualifier<Function>[], Function]): Function;
|
package/guard.js
CHANGED
|
@@ -18,7 +18,7 @@ function guard() {
|
|
|
18
18
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
19
|
qualifiers[_i] = arguments[_i];
|
|
20
20
|
}
|
|
21
|
-
return function () {
|
|
21
|
+
return (function () {
|
|
22
22
|
var args = [];
|
|
23
23
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24
24
|
args[_i] = arguments[_i];
|
|
@@ -31,6 +31,6 @@ function guard() {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return qualifiers[length].apply(qualifiers, args);
|
|
34
|
-
};
|
|
34
|
+
});
|
|
35
35
|
}
|
|
36
36
|
exports.default = guard;
|
package/maybe/just.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ export declare const jid: unique symbol;
|
|
|
11
11
|
* key, holding the provided value type.
|
|
12
12
|
*/
|
|
13
13
|
export declare type Just<Value> = {
|
|
14
|
-
[jid]:
|
|
14
|
+
[jid]: Value;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Constructor function for `Just`.
|
|
18
18
|
* Creates the special object with one property, represented as unique symbol
|
|
19
19
|
* key, holding the provided value.
|
|
20
20
|
*/
|
|
21
|
-
export default function just<Value
|
|
21
|
+
export default function just<Value>(value: Value): Just<Value>;
|
package/maybe/maybe.d.ts
CHANGED
|
@@ -12,9 +12,4 @@ export declare type Maybe<Value> = Just<Value> | Nothing;
|
|
|
12
12
|
* Constructor function for `Maybe`.
|
|
13
13
|
* Creates either `just` of a provided value, or `nothing`.
|
|
14
14
|
*/
|
|
15
|
-
export default function maybe(value: null | undefined):
|
|
16
|
-
/**
|
|
17
|
-
* Constructor function for `Maybe`.
|
|
18
|
-
* Creates either `just` of a provided value, or `nothing`.
|
|
19
|
-
*/
|
|
20
|
-
export default function maybe<Value>(value: Value | null | undefined): Just<Value>;
|
|
15
|
+
export default function maybe<Value>(value: Value | null | undefined): Maybe<Value>;
|
package/maybe/nothing.d.ts
CHANGED
package/maybe/nothing.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.nid = Symbol.for('@@functional/nothing');
|
|
|
16
16
|
function nothing() {
|
|
17
17
|
var _a;
|
|
18
18
|
return _a = {},
|
|
19
|
-
_a[exports.nid] =
|
|
19
|
+
_a[exports.nid] = undefined,
|
|
20
20
|
// @ts-expect-error: Undocumented API for external use
|
|
21
21
|
_a.toString = function () {
|
|
22
22
|
return 'Nothing';
|
|
@@ -7,9 +7,9 @@ import type { Map } from '../../types/map';
|
|
|
7
7
|
* Binds the value of the `monad` to new monad created
|
|
8
8
|
* by the `transition` function.
|
|
9
9
|
*/
|
|
10
|
-
export default function bind<Value, NextValue>(map: Map<Value, Maybe<NextValue>>): (monad: Maybe<Value>) => Maybe<
|
|
10
|
+
export default function bind<Value, NextValue>(map: Map<Value, Maybe<NextValue>>): (monad: Maybe<Value>) => Maybe<NextValue>;
|
|
11
11
|
/**
|
|
12
12
|
* Binds the value of the `monad` to new monad created
|
|
13
13
|
* by the `transition` function.
|
|
14
14
|
*/
|
|
15
|
-
export default function bind<Value, NextValue>(monad: Maybe<Value>, map: Map<Value, Maybe<NextValue>>): Maybe<
|
|
15
|
+
export default function bind<Value, NextValue>(monad: Maybe<Value>, map: Map<Value, Maybe<NextValue>>): Maybe<NextValue>;
|
package/maybe/operators/bind.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var compose_1 = require("../../compose");
|
|
7
|
-
var ternary_1 = require("../../ternary");
|
|
8
7
|
var identity_1 = require("../../identity");
|
|
9
8
|
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
10
9
|
var fold_1 = require("./fold");
|
|
@@ -15,7 +14,9 @@ function bind() {
|
|
|
15
14
|
args[_i] = arguments[_i];
|
|
16
15
|
}
|
|
17
16
|
return (0, permutation_2_1.default)(function (monad, map) {
|
|
18
|
-
return (0,
|
|
17
|
+
return (0, guards_1.isJust)(monad)
|
|
18
|
+
? (0, compose_1.default)(map, fold_1.default)(monad)
|
|
19
|
+
: (0, identity_1.default)(monad);
|
|
19
20
|
}).apply(void 0, args);
|
|
20
21
|
}
|
|
21
22
|
exports.default = bind;
|
|
@@ -7,9 +7,9 @@ import type { Map } from '../../types/map';
|
|
|
7
7
|
* Maps the value of the provided `monad` through the `transition` function
|
|
8
8
|
* and returns a new `Maybe` of the mapped value.
|
|
9
9
|
*/
|
|
10
|
-
export default function fmap<Value, NextValue
|
|
10
|
+
export default function fmap<Value, NextValue>(map: Map<Value, NextValue>): (monad: Maybe<Value>) => Maybe<NextValue>;
|
|
11
11
|
/**
|
|
12
12
|
* Maps the value of the provided `monad` through the `transition` function
|
|
13
13
|
* and returns a new `Maybe` of the mapped value.
|
|
14
14
|
*/
|
|
15
|
-
export default function fmap<Value, NextValue
|
|
15
|
+
export default function fmap<Value, NextValue>(monad: Maybe<Value>, map: Map<Value, NextValue>): Maybe<NextValue>;
|
package/maybe/operators/fmap.js
CHANGED
|
@@ -7,16 +7,17 @@ var compose_1 = require("../../compose");
|
|
|
7
7
|
var identity_1 = require("../../identity");
|
|
8
8
|
var maybe_1 = require("../maybe");
|
|
9
9
|
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
10
|
-
var
|
|
10
|
+
var fold_map_1 = require("./fold-map");
|
|
11
11
|
var guards_1 = require("./guards");
|
|
12
|
-
var ternary_1 = require("../../ternary");
|
|
13
12
|
function fmap() {
|
|
14
13
|
var args = [];
|
|
15
14
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
15
|
args[_i] = arguments[_i];
|
|
17
16
|
}
|
|
18
17
|
return (0, permutation_2_1.default)(function (monad, map) {
|
|
19
|
-
return (0,
|
|
18
|
+
return (0, guards_1.isJust)(monad)
|
|
19
|
+
? (0, compose_1.default)((maybe_1.default), (0, fold_map_1.default)(map))(monad)
|
|
20
|
+
: (0, identity_1.default)(monad);
|
|
20
21
|
}).apply(void 0, args);
|
|
21
22
|
}
|
|
22
23
|
exports.default = fmap;
|
|
@@ -5,17 +5,28 @@ import type { Just } from '../just';
|
|
|
5
5
|
import type { Maybe } from '../maybe';
|
|
6
6
|
import type { Nothing } from '../nothing';
|
|
7
7
|
import type { Map } from '../../types/map';
|
|
8
|
+
import { Fold } from './fold';
|
|
8
9
|
/**
|
|
9
10
|
* A type to unwrap the provided `Monad` into the new value type.
|
|
10
11
|
*/
|
|
11
|
-
export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends Just<any> ?
|
|
12
|
+
export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends Just<any> ? NextValue : Monad extends Nothing ? undefined : Monad extends Maybe<any> ? NextValue | undefined : never;
|
|
12
13
|
/**
|
|
13
14
|
* Maps the value of the provided `monad` through the `transition` function
|
|
14
15
|
* and returns the mapped value or `null`.
|
|
15
16
|
*/
|
|
16
|
-
export default function foldMap<Value, NextValue
|
|
17
|
+
export default function foldMap<Value, NextValue>(map: Map<Value, NextValue>): (monad: Maybe<Value>) => NextValue | undefined;
|
|
17
18
|
/**
|
|
18
19
|
* Maps the value of the provided `monad` through the `transition` function
|
|
19
20
|
* and returns the mapped value or `null`.
|
|
20
21
|
*/
|
|
21
|
-
export default function foldMap<Value, NextValue
|
|
22
|
+
export default function foldMap<Value, NextValue>(monad: Maybe<Value>, map: Map<Value, NextValue>): NextValue | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Maps the value of the provided `monad` through the `transition` function
|
|
25
|
+
* and returns the mapped value or `null`.
|
|
26
|
+
*/
|
|
27
|
+
export default function foldMap<Monad extends Just<any>, NextValue>(map: Map<Fold<Monad>, NextValue>): (monad: Monad) => NextValue;
|
|
28
|
+
/**
|
|
29
|
+
* Maps the value of the provided `monad` through the `transition` function
|
|
30
|
+
* and returns the mapped value or `null`.
|
|
31
|
+
*/
|
|
32
|
+
export default function foldMap<Monad extends Just<any>, NextValue>(monad: Monad, map: Map<Fold<Monad>, NextValue>): NextValue;
|
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var compose_1 = require("../../compose");
|
|
7
|
-
var ternary_1 = require("../../ternary");
|
|
8
7
|
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
9
|
-
var fold_1 = require("./fold");
|
|
10
8
|
var guards_1 = require("./guards");
|
|
9
|
+
var fold_1 = require("./fold");
|
|
11
10
|
function foldMap() {
|
|
12
11
|
var args = [];
|
|
13
12
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
13
|
args[_i] = arguments[_i];
|
|
15
14
|
}
|
|
16
15
|
return (0, permutation_2_1.default)(function (monad, map) {
|
|
17
|
-
return (0,
|
|
16
|
+
return (0, guards_1.isJust)(monad)
|
|
17
|
+
? (0, compose_1.default)(map, fold_1.default)(monad)
|
|
18
|
+
: undefined;
|
|
18
19
|
}).apply(void 0, args);
|
|
19
20
|
}
|
|
20
21
|
exports.default = foldMap;
|
|
@@ -7,7 +7,11 @@ import { Nothing } from '../nothing';
|
|
|
7
7
|
/**
|
|
8
8
|
* A type to unwrap the value type of the provided `Monad`.
|
|
9
9
|
*/
|
|
10
|
-
export declare type Fold<Monad extends Maybe<any>> = Monad extends Just<infer Value> ? Value : Monad extends Nothing ?
|
|
10
|
+
export declare type Fold<Monad extends Maybe<any>> = Monad extends Just<infer Value> ? Value : Monad extends Nothing ? undefined : Monad extends Maybe<infer Value> ? Value | undefined : never;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the value of the provided `monad`.
|
|
13
|
+
*/
|
|
14
|
+
export default function fold<Value>(monad: Maybe<Value>): Value | undefined;
|
|
11
15
|
/**
|
|
12
16
|
* Returns the value of the provided `monad`.
|
|
13
17
|
*/
|
|
@@ -5,13 +5,13 @@ import { Just } from '../just';
|
|
|
5
5
|
import type { Maybe } from '../maybe';
|
|
6
6
|
import { Nothing } from '../nothing';
|
|
7
7
|
/**
|
|
8
|
-
* Type guard function to tell if the provided `
|
|
8
|
+
* Type guard function to tell if the provided `value` is `Just`.
|
|
9
9
|
*/
|
|
10
|
-
export declare function isJust<Value>(
|
|
10
|
+
export declare function isJust<Value>(value: any): value is Just<Value>;
|
|
11
11
|
/**
|
|
12
|
-
* Type guard function to tell if the provided `
|
|
12
|
+
* Type guard function to tell if the provided `value` is `Nothing`.
|
|
13
13
|
*/
|
|
14
|
-
export declare function isNothing
|
|
14
|
+
export declare function isNothing(value: any): value is Nothing;
|
|
15
15
|
/**
|
|
16
16
|
* Type guard function to tell if the provided `value` is `Maybe`.
|
|
17
17
|
*/
|
|
@@ -7,17 +7,17 @@ exports.isMaybe = exports.isNothing = exports.isJust = void 0;
|
|
|
7
7
|
var just_1 = require("../just");
|
|
8
8
|
var nothing_1 = require("../nothing");
|
|
9
9
|
/**
|
|
10
|
-
* Type guard function to tell if the provided `
|
|
10
|
+
* Type guard function to tell if the provided `value` is `Just`.
|
|
11
11
|
*/
|
|
12
|
-
function isJust(
|
|
13
|
-
return Object.prototype.hasOwnProperty.call(
|
|
12
|
+
function isJust(value) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(value, just_1.jid);
|
|
14
14
|
}
|
|
15
15
|
exports.isJust = isJust;
|
|
16
16
|
/**
|
|
17
|
-
* Type guard function to tell if the provided `
|
|
17
|
+
* Type guard function to tell if the provided `value` is `Nothing`.
|
|
18
18
|
*/
|
|
19
|
-
function isNothing(
|
|
20
|
-
return Object.prototype.hasOwnProperty.call(
|
|
19
|
+
function isNothing(value) {
|
|
20
|
+
return Object.prototype.hasOwnProperty.call(value, nothing_1.nid);
|
|
21
21
|
}
|
|
22
22
|
exports.isNothing = isNothing;
|
|
23
23
|
/**
|
package/package.json
CHANGED
package/rethrow.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ import type { Effect } from './types/effect';
|
|
|
6
6
|
* Rethrows a received error
|
|
7
7
|
* performing an optional side effect.
|
|
8
8
|
*/
|
|
9
|
-
export default function rethrow<Error>(effect
|
|
9
|
+
export default function rethrow<Error>(effect?: Effect<(error: Error) => never>): (error: Error) => never;
|
package/rethrow.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* @module Side Effects
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var inject_1 = require("./inject");
|
|
7
6
|
/**
|
|
8
7
|
* Rethrows a received error
|
|
9
8
|
* performing an optional side effect.
|
|
10
9
|
*/
|
|
11
10
|
function rethrow(effect) {
|
|
12
|
-
return
|
|
11
|
+
return function (error) {
|
|
12
|
+
effect === null || effect === void 0 ? void 0 : effect(error);
|
|
13
13
|
throw error;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
}
|
|
16
16
|
exports.default = rethrow;
|
package/ternary.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ import type { Map } from './types/map';
|
|
|
6
6
|
* Functional alternative to the ternary operator.
|
|
7
7
|
* Enforces the same return type for both branches,
|
|
8
8
|
* the result is evaluated lazily.
|
|
9
|
+
*
|
|
10
|
+
* @deprecated
|
|
9
11
|
*/
|
|
10
12
|
export default function ternary<Value, Return>(predicate: Map<Value, boolean>, left: Map<Value, Return>, right: Map<Value, Return>): Map<Value, Return>;
|
package/ternary.js
CHANGED
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
* Functional alternative to the ternary operator.
|
|
8
8
|
* Enforces the same return type for both branches,
|
|
9
9
|
* the result is evaluated lazily.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated
|
|
10
12
|
*/
|
|
11
13
|
function ternary(predicate, left, right) {
|
|
12
14
|
return function (value) {
|
package/tsconfig.json
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"alwaysStrict": true,
|
|
12
12
|
"skipLibCheck": true,
|
|
13
13
|
"noImplicitAny": true,
|
|
14
|
-
"noUnusedLocals":
|
|
14
|
+
"noUnusedLocals": false,
|
|
15
15
|
"strictNullChecks": true,
|
|
16
16
|
"noImplicitReturns": true,
|
|
17
|
-
"noUnusedParameters":
|
|
17
|
+
"noUnusedParameters": false,
|
|
18
18
|
"strictFunctionTypes": true,
|
|
19
19
|
"strictBindCallApply": true,
|
|
20
20
|
"noStrictGenericChecks": true,
|