fnts 1.4.0 → 1.5.3
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/bindr.d.ts +13 -0
- package/either/operators/bindr.js +21 -0
- package/either/operators/index.d.ts +1 -0
- package/either/operators/index.js +3 -1
- package/maybe/just.d.ts +2 -2
- package/maybe/maybe.d.ts +6 -1
- package/maybe/operators/bind.d.ts +2 -2
- package/maybe/operators/fmap.d.ts +2 -2
- package/maybe/operators/fold-map.d.ts +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Either Operators
|
|
3
|
+
*/
|
|
4
|
+
import type { Map } from '../../types';
|
|
5
|
+
import type { Either } from '../either';
|
|
6
|
+
/**
|
|
7
|
+
* Maps right value to a new monad returning it.
|
|
8
|
+
*/
|
|
9
|
+
export default function bindr<LeftValue, RightValue, NextRightValue>(mapRight: Map<RightValue, Either<LeftValue, NextRightValue>>): (monad: Either<LeftValue, RightValue>) => Either<LeftValue, NextRightValue>;
|
|
10
|
+
/**
|
|
11
|
+
* Maps right value to a new monad returning it.
|
|
12
|
+
*/
|
|
13
|
+
export default function bindr<LeftValue, RightValue, NextRightValue>(monad: Either<LeftValue, RightValue>, mapRight: Map<RightValue, Either<LeftValue, NextRightValue>>): Either<LeftValue, NextRightValue>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Either Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var compose_1 = require("../../compose");
|
|
7
|
+
var ternary_1 = require("../../ternary");
|
|
8
|
+
var identity_1 = require("../../identity");
|
|
9
|
+
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
10
|
+
var bifold_1 = require("./bifold");
|
|
11
|
+
var guards_1 = require("./guards");
|
|
12
|
+
function bindr() {
|
|
13
|
+
var args = [];
|
|
14
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15
|
+
args[_i] = arguments[_i];
|
|
16
|
+
}
|
|
17
|
+
return permutation_2_1.default(function (monad, mapRight) {
|
|
18
|
+
return ternary_1.default(guards_1.isRight, compose_1.default(mapRight, bifold_1.bifoldr), identity_1.default)(monad);
|
|
19
|
+
}).apply(void 0, args);
|
|
20
|
+
}
|
|
21
|
+
exports.default = bindr;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { bifoldl, Bifoldl, bifoldr, Bifoldr, default as bifold, Bifold, } from './bifold';
|
|
2
2
|
export * from './guards';
|
|
3
|
+
export { default as bindr } from './bindr';
|
|
3
4
|
export { default as bifoldMap } from './bifold-map';
|
|
4
5
|
export { default as bimap, first, second } from './bimap';
|
|
@@ -10,12 +10,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.second = exports.first = exports.bimap = exports.bifoldMap = exports.bifold = exports.bifoldr = exports.bifoldl = void 0;
|
|
13
|
+
exports.second = exports.first = exports.bimap = exports.bifoldMap = exports.bindr = exports.bifold = exports.bifoldr = exports.bifoldl = void 0;
|
|
14
14
|
var bifold_1 = require("./bifold");
|
|
15
15
|
Object.defineProperty(exports, "bifoldl", { enumerable: true, get: function () { return bifold_1.bifoldl; } });
|
|
16
16
|
Object.defineProperty(exports, "bifoldr", { enumerable: true, get: function () { return bifold_1.bifoldr; } });
|
|
17
17
|
Object.defineProperty(exports, "bifold", { enumerable: true, get: function () { return bifold_1.default; } });
|
|
18
18
|
__exportStar(require("./guards"), exports);
|
|
19
|
+
var bindr_1 = require("./bindr");
|
|
20
|
+
Object.defineProperty(exports, "bindr", { enumerable: true, get: function () { return bindr_1.default; } });
|
|
19
21
|
var bifold_map_1 = require("./bifold-map");
|
|
20
22
|
Object.defineProperty(exports, "bifoldMap", { enumerable: true, get: function () { return bifold_map_1.default; } });
|
|
21
23
|
var bimap_1 = require("./bimap");
|
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]: NonNullable<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 extends NonNullable<any>>(value: Value): Just<Value>;
|
package/maybe/maybe.d.ts
CHANGED
|
@@ -12,4 +12,9 @@ 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
|
|
15
|
+
export default function maybe(value: null | undefined): Nothing;
|
|
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>;
|
|
@@ -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>(transition: Map<Value, Maybe<NextValue>>): (monad: Maybe<Value>) => Maybe<NextValue
|
|
10
|
+
export default function bind<Value, NextValue>(transition: 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>, transition: Map<Value, Maybe<NextValue>>): Maybe<NextValue
|
|
15
|
+
export default function bind<Value, NextValue>(monad: Maybe<Value>, transition: Map<Value, Maybe<NextValue>>): Maybe<NonNullable<NextValue>>;
|
|
@@ -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>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => Maybe<NextValue
|
|
10
|
+
export default function fmap<Value, NextValue = Value>(transition: 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>, transition: Map<Value, NextValue>): Maybe<NextValue
|
|
15
|
+
export default function fmap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): Maybe<NonNullable<NextValue>>;
|
|
@@ -8,14 +8,14 @@ import type { Map } from '../../types/map';
|
|
|
8
8
|
/**
|
|
9
9
|
* A type to unwrap the provided `Monad` into the new value type.
|
|
10
10
|
*/
|
|
11
|
-
export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends Just<any> ? NextValue : Monad extends Nothing ? null : never;
|
|
11
|
+
export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends Just<any> ? NonNullable<NextValue> : Monad extends Nothing ? null : never;
|
|
12
12
|
/**
|
|
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>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => NextValue
|
|
16
|
+
export default function foldMap<Value, NextValue = Value>(transition: 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>, transition: Map<Value, NextValue>): NextValue
|
|
21
|
+
export default function foldMap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): FoldMap<Maybe<Value>, NextValue>;
|