fnts 1.5.3 → 1.6.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/either/operators/bifold-map.d.ts +12 -2
- package/either/operators/bifold-map.js +6 -0
- package/either/operators/guards.d.ts +4 -0
- package/either/operators/guards.js +8 -1
- package/maybe/operators/bind.d.ts +2 -2
- package/maybe/operators/bind.js +2 -2
- package/maybe/operators/fmap.d.ts +2 -2
- package/maybe/operators/fmap.js +2 -2
- package/maybe/operators/fold-map.d.ts +2 -2
- package/maybe/operators/fold-map.js +2 -2
- package/maybe/operators/guards.d.ts +4 -0
- package/maybe/operators/guards.js +8 -1
- package/maybe/operators/index.d.ts +1 -1
- package/maybe/operators/index.js +12 -4
- package/package.json +1 -1
|
@@ -3,13 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Either } from '../either';
|
|
5
5
|
import type { Map } from '../../types/map';
|
|
6
|
+
/**
|
|
7
|
+
* Maps provided `monad` to a value,
|
|
8
|
+
* then returns it.
|
|
9
|
+
*/
|
|
10
|
+
export default function bifoldMap<LeftValue, RightValue, Value>(map: Map<LeftValue | RightValue, Value>): (monad: Either<LeftValue, RightValue>) => Value;
|
|
11
|
+
/**
|
|
12
|
+
* Maps provided `monad` to a value,
|
|
13
|
+
* then returns it.
|
|
14
|
+
*/
|
|
15
|
+
export default function bifoldMap<LeftValue, RightValue, Value>(monad: Either<LeftValue, RightValue>, map: Map<LeftValue | RightValue, Value>): Value;
|
|
6
16
|
/**
|
|
7
17
|
* Maps left and right values of the provided `monad` to a value,
|
|
8
18
|
* then returns it.
|
|
9
19
|
*/
|
|
10
|
-
export default function bifoldMap<LeftValue, RightValue,
|
|
20
|
+
export default function bifoldMap<LeftValue, RightValue, Value>(mapLeft: Map<LeftValue, Value>, mapRight: Map<RightValue, Value>): (monad: Either<LeftValue, RightValue>) => Value;
|
|
11
21
|
/**
|
|
12
22
|
* Maps left and right values of the provided `monad` to a value,
|
|
13
23
|
* then returns it.
|
|
14
24
|
*/
|
|
15
|
-
export default function bifoldMap<LeftValue, RightValue,
|
|
25
|
+
export default function bifoldMap<LeftValue, RightValue, Value>(monad: Either<LeftValue, RightValue>, mapLeft: Map<LeftValue, Value>, mapRight: Map<RightValue, Value>): Value;
|
|
@@ -13,6 +13,12 @@ function bifoldMap() {
|
|
|
13
13
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
14
|
args[_i] = arguments[_i];
|
|
15
15
|
}
|
|
16
|
+
if (args.length === 1) {
|
|
17
|
+
return function (monad) { return args[0](monad); };
|
|
18
|
+
}
|
|
19
|
+
if (args.length === 2 && guards_1.isEither(args[0])) {
|
|
20
|
+
return compose_1.default(args[1], bifold_1.default)(args[0]);
|
|
21
|
+
}
|
|
16
22
|
return permutation_3_1.default(function (monad, mapLeft, mapRight) {
|
|
17
23
|
return ternary_1.default(guards_1.isLeft, compose_1.default(mapLeft, bifold_1.bifoldl), compose_1.default(mapRight, bifold_1.bifoldr))(monad);
|
|
18
24
|
}).apply(void 0, args);
|
|
@@ -12,3 +12,7 @@ export declare function isLeft<LeftValue>(monad: Either<LeftValue, any>): monad
|
|
|
12
12
|
* Type guard function to tell if the provided `monad` is `Right`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function isRight<RightValue>(monad: Either<any, RightValue>): monad is Right<RightValue>;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard function to tell if the provided `value` is `Either`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isEither<LeftValue, RightValue>(value: any): value is Either<LeftValue, RightValue>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module Either Operators
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isRight = exports.isLeft = void 0;
|
|
6
|
+
exports.isEither = exports.isRight = exports.isLeft = void 0;
|
|
7
7
|
var left_1 = require("../left");
|
|
8
8
|
var right_1 = require("../right");
|
|
9
9
|
/**
|
|
@@ -20,3 +20,10 @@ function isRight(monad) {
|
|
|
20
20
|
return Object.prototype.hasOwnProperty.call(monad, right_1.rid);
|
|
21
21
|
}
|
|
22
22
|
exports.isRight = isRight;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard function to tell if the provided `value` is `Either`.
|
|
25
|
+
*/
|
|
26
|
+
function isEither(value) {
|
|
27
|
+
return isLeft(value) || isRight(value);
|
|
28
|
+
}
|
|
29
|
+
exports.isEither = isEither;
|
|
@@ -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>(
|
|
10
|
+
export default function bind<Value, NextValue>(map: Map<Value, Maybe<NextValue>>): (monad: Maybe<Value>) => Maybe<NonNullable<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>,
|
|
15
|
+
export default function bind<Value, NextValue>(monad: Maybe<Value>, map: Map<Value, Maybe<NextValue>>): Maybe<NonNullable<NextValue>>;
|
package/maybe/operators/bind.js
CHANGED
|
@@ -14,8 +14,8 @@ function bind() {
|
|
|
14
14
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15
15
|
args[_i] = arguments[_i];
|
|
16
16
|
}
|
|
17
|
-
return permutation_2_1.default(function (monad,
|
|
18
|
-
return ternary_1.default(guards_1.isJust, compose_1.default(
|
|
17
|
+
return permutation_2_1.default(function (monad, map) {
|
|
18
|
+
return ternary_1.default(guards_1.isJust, compose_1.default(map, fold_1.default), identity_1.default)(monad);
|
|
19
19
|
}).apply(void 0, args);
|
|
20
20
|
}
|
|
21
21
|
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 = Value>(
|
|
10
|
+
export default function fmap<Value, NextValue = Value>(map: Map<Value, NextValue>): (monad: Maybe<Value>) => Maybe<NonNullable<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 = Value>(monad: Maybe<Value>,
|
|
15
|
+
export default function fmap<Value, NextValue = Value>(monad: Maybe<Value>, map: Map<Value, NextValue>): Maybe<NonNullable<NextValue>>;
|
package/maybe/operators/fmap.js
CHANGED
|
@@ -15,8 +15,8 @@ function fmap() {
|
|
|
15
15
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
16
|
args[_i] = arguments[_i];
|
|
17
17
|
}
|
|
18
|
-
return permutation_2_1.default(function (monad,
|
|
19
|
-
return ternary_1.default(guards_1.isJust, compose_1.default(maybe_1.default,
|
|
18
|
+
return permutation_2_1.default(function (monad, map) {
|
|
19
|
+
return ternary_1.default(guards_1.isJust, compose_1.default(maybe_1.default, map, fold_1.default), identity_1.default)(monad);
|
|
20
20
|
}).apply(void 0, args);
|
|
21
21
|
}
|
|
22
22
|
exports.default = fmap;
|
|
@@ -13,9 +13,9 @@ export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends
|
|
|
13
13
|
* Maps the value of the provided `monad` through the `transition` function
|
|
14
14
|
* and returns the mapped value or `null`.
|
|
15
15
|
*/
|
|
16
|
-
export default function foldMap<Value, NextValue = Value>(
|
|
16
|
+
export default function foldMap<Value, NextValue = Value>(map: Map<Value, NextValue>): (monad: Maybe<Value>) => FoldMap<Maybe<Value>, NextValue>;
|
|
17
17
|
/**
|
|
18
18
|
* Maps the value of the provided `monad` through the `transition` function
|
|
19
19
|
* and returns the mapped value or `null`.
|
|
20
20
|
*/
|
|
21
|
-
export default function foldMap<Value, NextValue = Value>(monad: Maybe<Value>,
|
|
21
|
+
export default function foldMap<Value, NextValue = Value>(monad: Maybe<Value>, map: Map<Value, NextValue>): FoldMap<Maybe<Value>, NextValue>;
|
|
@@ -13,8 +13,8 @@ function foldMap() {
|
|
|
13
13
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
14
|
args[_i] = arguments[_i];
|
|
15
15
|
}
|
|
16
|
-
return permutation_2_1.default(function (monad,
|
|
17
|
-
return ternary_1.default(guards_1.isJust, compose_1.default(
|
|
16
|
+
return permutation_2_1.default(function (monad, map) {
|
|
17
|
+
return ternary_1.default(guards_1.isJust, compose_1.default(map, fold_1.default), function () { return null; })(monad);
|
|
18
18
|
}).apply(void 0, args);
|
|
19
19
|
}
|
|
20
20
|
exports.default = foldMap;
|
|
@@ -12,3 +12,7 @@ export declare function isJust<Value>(monad: Maybe<Value>): monad is Just<Value>
|
|
|
12
12
|
* Type guard function to tell if the provided `monad` is `Nothing`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function isNothing<Value>(monad: Maybe<Value>): monad is Nothing;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard function to tell if the provided `value` is `Maybe`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isMaybe<Value>(value: any): value is Maybe<Value>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module Maybe Operators
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isNothing = exports.isJust = void 0;
|
|
6
|
+
exports.isMaybe = exports.isNothing = exports.isJust = void 0;
|
|
7
7
|
var just_1 = require("../just");
|
|
8
8
|
var nothing_1 = require("../nothing");
|
|
9
9
|
/**
|
|
@@ -20,3 +20,10 @@ function isNothing(monad) {
|
|
|
20
20
|
return Object.prototype.hasOwnProperty.call(monad, nothing_1.nid);
|
|
21
21
|
}
|
|
22
22
|
exports.isNothing = isNothing;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard function to tell if the provided `value` is `Maybe`.
|
|
25
|
+
*/
|
|
26
|
+
function isMaybe(value) {
|
|
27
|
+
return isJust(value) || isNothing(value);
|
|
28
|
+
}
|
|
29
|
+
exports.isMaybe = isMaybe;
|
package/maybe/operators/index.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.foldMap = exports.
|
|
13
|
+
exports.foldMap = exports.fold = exports.bind = exports.fmap = void 0;
|
|
14
|
+
__exportStar(require("./guards"), exports);
|
|
4
15
|
var fmap_1 = require("./fmap");
|
|
5
16
|
Object.defineProperty(exports, "fmap", { enumerable: true, get: function () { return fmap_1.default; } });
|
|
6
17
|
var bind_1 = require("./bind");
|
|
7
18
|
Object.defineProperty(exports, "bind", { enumerable: true, get: function () { return bind_1.default; } });
|
|
8
19
|
var fold_1 = require("./fold");
|
|
9
20
|
Object.defineProperty(exports, "fold", { enumerable: true, get: function () { return fold_1.default; } });
|
|
10
|
-
var guards_1 = require("./guards");
|
|
11
|
-
Object.defineProperty(exports, "isJust", { enumerable: true, get: function () { return guards_1.isJust; } });
|
|
12
|
-
Object.defineProperty(exports, "isNothing", { enumerable: true, get: function () { return guards_1.isNothing; } });
|
|
13
21
|
var fold_map_1 = require("./fold-map");
|
|
14
22
|
Object.defineProperty(exports, "foldMap", { enumerable: true, get: function () { return fold_map_1.default; } });
|