fnts 1.1.1 → 1.3.2
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/README.md +4 -50
- package/compose.d.ts +9 -9
- package/compose.js +24 -1
- package/curry.d.ts +8 -5
- package/curry.js +37 -1
- package/either/either-sync.d.ts +4 -2
- package/either/either-sync.js +21 -1
- package/either/either.d.ts +4 -2
- package/either/either.js +18 -1
- package/either/index.d.ts +3 -3
- package/either/index.js +11 -1
- package/either/left.d.ts +4 -2
- package/either/left.js +22 -1
- package/either/operators/bifold/bifold.d.ts +4 -2
- package/either/operators/bifold/bifold.js +15 -1
- package/either/operators/bifold/bifoldl.d.ts +4 -2
- package/either/operators/bifold/bifoldl.js +17 -1
- package/either/operators/bifold/bifoldr.d.ts +4 -2
- package/either/operators/bifold/bifoldr.js +17 -1
- package/either/operators/bifold/index.d.ts +3 -3
- package/either/operators/bifold/index.js +9 -1
- package/either/operators/bifold-map.d.ts +6 -4
- package/either/operators/bifold-map.js +20 -1
- package/either/operators/bimap/bimap.d.ts +6 -4
- package/either/operators/bimap/bimap.js +20 -1
- package/either/operators/bimap/first.d.ts +6 -4
- package/either/operators/bimap/first.js +22 -1
- package/either/operators/bimap/index.d.ts +3 -3
- package/either/operators/bimap/index.js +9 -1
- package/either/operators/bimap/second.d.ts +6 -4
- package/either/operators/bimap/second.js +22 -1
- package/either/operators/guards.d.ts +3 -0
- package/either/operators/guards.js +22 -1
- package/either/operators/index.d.ts +3 -3
- package/either/operators/index.js +24 -1
- package/either/right.d.ts +4 -2
- package/either/right.js +22 -1
- package/guard.d.ts +6 -3
- package/guard.js +36 -1
- package/identity.d.ts +4 -2
- package/identity.js +12 -1
- package/index.d.ts +9 -5
- package/index.js +21 -1
- package/inject.d.ts +15 -0
- package/inject.js +23 -0
- package/maybe/index.d.ts +2 -2
- package/maybe/index.js +9 -1
- package/maybe/just.d.ts +4 -2
- package/maybe/just.js +22 -1
- package/maybe/maybe.d.ts +4 -2
- package/maybe/maybe.js +17 -1
- package/maybe/nothing.d.ts +4 -2
- package/maybe/nothing.js +22 -1
- package/maybe/operators/bind.d.ts +6 -4
- package/maybe/operators/bind.js +21 -1
- package/maybe/operators/fmap.d.ts +6 -4
- package/maybe/operators/fmap.js +22 -1
- package/maybe/operators/fold-map.d.ts +10 -8
- package/maybe/operators/fold-map.js +20 -1
- package/maybe/operators/fold.d.ts +4 -2
- package/maybe/operators/fold.js +17 -1
- package/maybe/operators/guards.d.ts +3 -0
- package/maybe/operators/guards.js +22 -1
- package/maybe/operators/index.d.ts +4 -4
- package/maybe/operators/index.js +14 -1
- package/package.json +10 -4
- package/permutation/index.d.ts +2 -0
- package/permutation/index.js +7 -0
- package/permutation/permutation-2.d.ts +8 -0
- package/permutation/permutation-2.js +18 -0
- package/permutation/permutation-3.d.ts +8 -0
- package/permutation/permutation-3.js +18 -0
- package/pipe.d.ts +9 -9
- package/pipe.js +24 -1
- package/rethrow.d.ts +9 -0
- package/rethrow.js +16 -0
- package/tap.d.ts +11 -0
- package/tap.js +15 -0
- package/ternary.d.ts +10 -0
- package/ternary.js +16 -0
- package/tsconfig.json +1 -1
- package/types/effect.d.ts +11 -0
- package/types/function.d.ts +13 -0
- package/types/gradual.d.ts +17 -0
- package/types/index.d.ts +7 -0
- package/{.internal → types}/last.d.ts +7 -0
- package/types/map.d.ts +8 -0
- package/{.internal → types}/slice.d.ts +7 -0
- package/{.internal → types}/tuple.d.ts +6 -0
- package/.internal/gradual.d.ts +0 -5
- package/.internal/map.d.ts +0 -1
- package/.internal/permutation-of-2.d.ts +0 -1
- package/.internal/permutation-of-2.js +0 -1
- package/.internal/permutation-of-3.d.ts +0 -1
- package/.internal/permutation-of-3.js +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Either Operators
|
|
3
|
+
*/
|
|
1
4
|
import type { Either } from '../../either';
|
|
2
|
-
import type { Map } from '
|
|
5
|
+
import type { Map } from '../../../types/map';
|
|
3
6
|
/**
|
|
4
7
|
* Maps the right value of the provided `monad` to a new `Either` monad
|
|
5
8
|
* with the same left value.
|
|
6
9
|
*/
|
|
7
|
-
export
|
|
10
|
+
export default function second<LeftValue, RightValue, NextRightValue>(mapRight: Map<RightValue, NextRightValue>): (monad: Either<LeftValue, RightValue>) => Either<LeftValue, NextRightValue>;
|
|
8
11
|
/**
|
|
9
12
|
* Maps the right value of the provided `monad` to a new `Either` monad
|
|
10
13
|
* with the same left value.
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
13
|
-
export default second;
|
|
15
|
+
export default function second<LeftValue, RightValue, NextRightValue>(monad: Either<LeftValue, RightValue>, mapRight: Map<RightValue, NextRightValue>): Either<LeftValue, NextRightValue>;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Either Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var bifold_1 = require("../bifold");
|
|
7
|
+
var guards_1 = require("../guards");
|
|
8
|
+
var compose_1 = require("../../../compose");
|
|
9
|
+
var ternary_1 = require("../../../ternary");
|
|
10
|
+
var identity_1 = require("../../../identity");
|
|
11
|
+
var right_1 = require("../../right");
|
|
12
|
+
var permutation_2_1 = require("../../../permutation/permutation-2");
|
|
13
|
+
function second() {
|
|
14
|
+
var args = [];
|
|
15
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
+
args[_i] = arguments[_i];
|
|
17
|
+
}
|
|
18
|
+
return permutation_2_1.default(function (monad, mapRight) {
|
|
19
|
+
return ternary_1.default(guards_1.isRight, compose_1.default(right_1.default, mapRight, bifold_1.bifoldr), identity_1.default)(monad);
|
|
20
|
+
}).apply(void 0, args);
|
|
21
|
+
}
|
|
22
|
+
exports.default = second;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Either Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isRight = exports.isLeft = void 0;
|
|
7
|
+
var left_1 = require("../left");
|
|
8
|
+
var right_1 = require("../right");
|
|
9
|
+
/**
|
|
10
|
+
* Type guard function to tell if the provided `monad` is `Left`.
|
|
11
|
+
*/
|
|
12
|
+
function isLeft(monad) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(monad, left_1.lid);
|
|
14
|
+
}
|
|
15
|
+
exports.isLeft = isLeft;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard function to tell if the provided `monad` is `Right`.
|
|
18
|
+
*/
|
|
19
|
+
function isRight(monad) {
|
|
20
|
+
return Object.prototype.hasOwnProperty.call(monad, right_1.rid);
|
|
21
|
+
}
|
|
22
|
+
exports.isRight = isRight;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { bifoldl, Bifoldl, bifoldr, Bifoldr, bifold, Bifold, } from './bifold';
|
|
1
|
+
export { bifoldl, Bifoldl, bifoldr, Bifoldr, default as bifold, Bifold, } from './bifold';
|
|
2
2
|
export * from './guards';
|
|
3
|
-
export
|
|
4
|
-
export { bimap, first, second } from './bimap';
|
|
3
|
+
export { default as bifoldMap } from './bifold-map';
|
|
4
|
+
export { default as bimap, first, second } from './bimap';
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.second = exports.first = exports.bimap = exports.bifoldMap = exports.bifold = exports.bifoldr = exports.bifoldl = void 0;
|
|
14
|
+
var bifold_1 = require("./bifold");
|
|
15
|
+
Object.defineProperty(exports, "bifoldl", { enumerable: true, get: function () { return bifold_1.bifoldl; } });
|
|
16
|
+
Object.defineProperty(exports, "bifoldr", { enumerable: true, get: function () { return bifold_1.bifoldr; } });
|
|
17
|
+
Object.defineProperty(exports, "bifold", { enumerable: true, get: function () { return bifold_1.default; } });
|
|
18
|
+
__exportStar(require("./guards"), exports);
|
|
19
|
+
var bifold_map_1 = require("./bifold-map");
|
|
20
|
+
Object.defineProperty(exports, "bifoldMap", { enumerable: true, get: function () { return bifold_map_1.default; } });
|
|
21
|
+
var bimap_1 = require("./bimap");
|
|
22
|
+
Object.defineProperty(exports, "bimap", { enumerable: true, get: function () { return bimap_1.default; } });
|
|
23
|
+
Object.defineProperty(exports, "first", { enumerable: true, get: function () { return bimap_1.first; } });
|
|
24
|
+
Object.defineProperty(exports, "second", { enumerable: true, get: function () { return bimap_1.second; } });
|
package/either/right.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Either
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Internal unique identifier for `Right`.
|
|
3
6
|
*/
|
|
@@ -15,5 +18,4 @@ export declare type Right<Value> = {
|
|
|
15
18
|
* Creates the special object with one property, represented as unique symbol
|
|
16
19
|
* key, holding the provided value.
|
|
17
20
|
*/
|
|
18
|
-
export
|
|
19
|
-
export default right;
|
|
21
|
+
export default function right<Value>(value: Value): Right<Value>;
|
package/either/right.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Either
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rid = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Internal unique identifier for `Right`.
|
|
9
|
+
*/
|
|
10
|
+
exports.rid = Symbol.for('@@functional/right');
|
|
11
|
+
/**
|
|
12
|
+
* Constructor function for `Right`.
|
|
13
|
+
* Creates the special object with one property, represented as unique symbol
|
|
14
|
+
* key, holding the provided value.
|
|
15
|
+
*/
|
|
16
|
+
function right(value) {
|
|
17
|
+
var _a;
|
|
18
|
+
return _a = {},
|
|
19
|
+
_a[exports.rid] = value,
|
|
20
|
+
_a;
|
|
21
|
+
}
|
|
22
|
+
exports.default = right;
|
package/guard.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Guard
|
|
3
|
+
*/
|
|
4
|
+
import type { VariadicFunction } from './types/function';
|
|
5
|
+
export declare type GuardQualifier<Function extends VariadicFunction> = [
|
|
2
6
|
validator: <Result extends boolean>(...args: Parameters<Function>) => Result,
|
|
3
7
|
executor: Function
|
|
4
8
|
];
|
|
@@ -12,5 +16,4 @@ export declare type Guard<Function extends (...args: any[]) => any> = [
|
|
|
12
16
|
*
|
|
13
17
|
* When no `validator` succeeds, the default executor is run.
|
|
14
18
|
*/
|
|
15
|
-
export
|
|
16
|
-
export default guard;
|
|
19
|
+
export default function guard<Function extends VariadicFunction>(...qualifiers: [...GuardQualifier<Function>[], Function]): (...args: Parameters<Function>) => ReturnType<Function>;
|
package/guard.js
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Guard
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* A function which accepts the pairs of guards:
|
|
8
|
+
* the first one is the `validator`, expected to return a boolean value.
|
|
9
|
+
*
|
|
10
|
+
* If the value is `true`, it's `executor` should run with the provided `args`
|
|
11
|
+
* and return from the `guards` function.
|
|
12
|
+
* If the value is `false`, the process continues to the next `validator`.
|
|
13
|
+
*
|
|
14
|
+
* When no `validator` succeeds, the default executor is run.
|
|
15
|
+
*/
|
|
16
|
+
function guard() {
|
|
17
|
+
var qualifiers = [];
|
|
18
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
+
qualifiers[_i] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
return function () {
|
|
22
|
+
var args = [];
|
|
23
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24
|
+
args[_i] = arguments[_i];
|
|
25
|
+
}
|
|
26
|
+
var length = qualifiers.length - 1;
|
|
27
|
+
for (var index = 0; index < length; index += 1) {
|
|
28
|
+
var _a = qualifiers[index], validator = _a[0], expression = _a[1];
|
|
29
|
+
if (validator.apply(void 0, args)) {
|
|
30
|
+
return expression.apply(void 0, args);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return qualifiers[length].apply(qualifiers, args);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.default = guard;
|
package/identity.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Identity
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* A type describing the `identity` function.
|
|
3
6
|
*/
|
|
@@ -5,5 +8,4 @@ export declare type Identity<T> = (x: T) => T;
|
|
|
5
8
|
/**
|
|
6
9
|
* A function which returns the provided value.
|
|
7
10
|
*/
|
|
8
|
-
export
|
|
9
|
-
export default identity;
|
|
11
|
+
export default function identity<T>(x: T): T;
|
package/identity.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Identity
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* A function which returns the provided value.
|
|
8
|
+
*/
|
|
9
|
+
function identity(x) {
|
|
10
|
+
return x;
|
|
11
|
+
}
|
|
12
|
+
exports.default = identity;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { default as tap } from './tap';
|
|
2
|
+
export { default as pipe } from './pipe';
|
|
3
|
+
export { default as curry } from './curry';
|
|
4
|
+
export { default as match } from './guard';
|
|
5
|
+
export { default as inject } from './inject';
|
|
6
|
+
export { default as compose } from './compose';
|
|
7
|
+
export { default as rethrow } from './rethrow';
|
|
8
|
+
export { default as ternary } from './ternary';
|
|
9
|
+
export { default as identity } from './identity';
|
package/index.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.identity = exports.ternary = exports.rethrow = exports.compose = exports.inject = exports.match = exports.curry = exports.pipe = exports.tap = void 0;
|
|
4
|
+
var tap_1 = require("./tap");
|
|
5
|
+
Object.defineProperty(exports, "tap", { enumerable: true, get: function () { return tap_1.default; } });
|
|
6
|
+
var pipe_1 = require("./pipe");
|
|
7
|
+
Object.defineProperty(exports, "pipe", { enumerable: true, get: function () { return pipe_1.default; } });
|
|
8
|
+
var curry_1 = require("./curry");
|
|
9
|
+
Object.defineProperty(exports, "curry", { enumerable: true, get: function () { return curry_1.default; } });
|
|
10
|
+
var guard_1 = require("./guard");
|
|
11
|
+
Object.defineProperty(exports, "match", { enumerable: true, get: function () { return guard_1.default; } });
|
|
12
|
+
var inject_1 = require("./inject");
|
|
13
|
+
Object.defineProperty(exports, "inject", { enumerable: true, get: function () { return inject_1.default; } });
|
|
14
|
+
var compose_1 = require("./compose");
|
|
15
|
+
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_1.default; } });
|
|
16
|
+
var rethrow_1 = require("./rethrow");
|
|
17
|
+
Object.defineProperty(exports, "rethrow", { enumerable: true, get: function () { return rethrow_1.default; } });
|
|
18
|
+
var ternary_1 = require("./ternary");
|
|
19
|
+
Object.defineProperty(exports, "ternary", { enumerable: true, get: function () { return ternary_1.default; } });
|
|
20
|
+
var identity_1 = require("./identity");
|
|
21
|
+
Object.defineProperty(exports, "identity", { enumerable: true, get: function () { return identity_1.default; } });
|
package/inject.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Side Effects
|
|
3
|
+
*/
|
|
4
|
+
import type { Effect } from './types/effect';
|
|
5
|
+
import type { VariadicFunction } from './types/function';
|
|
6
|
+
/**
|
|
7
|
+
* Injects a function with a side effect.
|
|
8
|
+
* Returns the copy of the original function.
|
|
9
|
+
*/
|
|
10
|
+
export default function inject<Function extends VariadicFunction>(effect: Effect<Function>): (fn: Function) => Function;
|
|
11
|
+
/**
|
|
12
|
+
* Injects a function with a side effect.
|
|
13
|
+
* Returns the copy of the original function.
|
|
14
|
+
*/
|
|
15
|
+
export default function inject<Function extends VariadicFunction>(fn: Function, effect: Effect<Function>): Function;
|
package/inject.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Side Effects
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var permutation_2_1 = require("./permutation/permutation-2");
|
|
7
|
+
function inject() {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
return permutation_2_1.default(function (fn, effect) {
|
|
13
|
+
return (function () {
|
|
14
|
+
var args = [];
|
|
15
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
+
args[_i] = arguments[_i];
|
|
17
|
+
}
|
|
18
|
+
effect.apply(void 0, args);
|
|
19
|
+
return fn.apply(void 0, args);
|
|
20
|
+
});
|
|
21
|
+
}).apply(void 0, args);
|
|
22
|
+
}
|
|
23
|
+
exports.default = inject;
|
package/maybe/index.d.ts
CHANGED
package/maybe/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nothing = exports.just = exports.default = void 0;
|
|
4
|
+
var maybe_1 = require("./maybe");
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return maybe_1.default; } });
|
|
6
|
+
var just_1 = require("./just");
|
|
7
|
+
Object.defineProperty(exports, "just", { enumerable: true, get: function () { return just_1.default; } });
|
|
8
|
+
var nothing_1 = require("./nothing");
|
|
9
|
+
Object.defineProperty(exports, "nothing", { enumerable: true, get: function () { return nothing_1.default; } });
|
package/maybe/just.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Internal unique identifier for `Just`.
|
|
3
6
|
*/
|
|
@@ -15,5 +18,4 @@ export declare type Just<Value> = {
|
|
|
15
18
|
* Creates the special object with one property, represented as unique symbol
|
|
16
19
|
* key, holding the provided value.
|
|
17
20
|
*/
|
|
18
|
-
export
|
|
19
|
-
export default just;
|
|
21
|
+
export default function just<Value>(value: Value): Just<Value>;
|
package/maybe/just.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jid = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module Maybe
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Internal unique identifier for `Just`.
|
|
9
|
+
*/
|
|
10
|
+
exports.jid = Symbol.for('@@functional/just');
|
|
11
|
+
/**
|
|
12
|
+
* Constructor function for `Just`.
|
|
13
|
+
* Creates the special object with one property, represented as unique symbol
|
|
14
|
+
* key, holding the provided value.
|
|
15
|
+
*/
|
|
16
|
+
function just(value) {
|
|
17
|
+
var _a;
|
|
18
|
+
return _a = {},
|
|
19
|
+
_a[exports.jid] = value,
|
|
20
|
+
_a;
|
|
21
|
+
}
|
|
22
|
+
exports.default = just;
|
package/maybe/maybe.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe
|
|
3
|
+
*/
|
|
1
4
|
import { Just } from './just';
|
|
2
5
|
import { Nothing } from './nothing';
|
|
3
6
|
/**
|
|
@@ -9,5 +12,4 @@ export declare type Maybe<Value> = Just<Value> | Nothing;
|
|
|
9
12
|
* Constructor function for `Maybe`.
|
|
10
13
|
* Creates either `just` of a provided value, or `nothing`.
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
13
|
-
export default maybe;
|
|
15
|
+
export default function maybe<Value>(value: Value | null | undefined): Maybe<Value>;
|
package/maybe/maybe.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Maybe
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var just_1 = require("./just");
|
|
7
|
+
var nothing_1 = require("./nothing");
|
|
8
|
+
/**
|
|
9
|
+
* Constructor function for `Maybe`.
|
|
10
|
+
* Creates either `just` of a provided value, or `nothing`.
|
|
11
|
+
*/
|
|
12
|
+
function maybe(value) {
|
|
13
|
+
return value === null || value === undefined
|
|
14
|
+
? nothing_1.default()
|
|
15
|
+
: just_1.default(value);
|
|
16
|
+
}
|
|
17
|
+
exports.default = maybe;
|
package/maybe/nothing.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Internal unique identifier for `Nothing`.
|
|
3
6
|
*/
|
|
@@ -15,5 +18,4 @@ export declare type Nothing = {
|
|
|
15
18
|
* Creates the special object with one property, represented as unique symbol
|
|
16
19
|
* key, holding the `null` value.
|
|
17
20
|
*/
|
|
18
|
-
export
|
|
19
|
-
export default nothing;
|
|
21
|
+
export default function nothing(): Nothing;
|
package/maybe/nothing.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Maybe
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nid = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Internal unique identifier for `Nothing`.
|
|
9
|
+
*/
|
|
10
|
+
exports.nid = Symbol.for('@@functional/nothing');
|
|
11
|
+
/**
|
|
12
|
+
* Constructor function for `Nothing`.
|
|
13
|
+
* Creates the special object with one property, represented as unique symbol
|
|
14
|
+
* key, holding the `null` value.
|
|
15
|
+
*/
|
|
16
|
+
function nothing() {
|
|
17
|
+
var _a;
|
|
18
|
+
return _a = {},
|
|
19
|
+
_a[exports.nid] = null,
|
|
20
|
+
_a;
|
|
21
|
+
}
|
|
22
|
+
exports.default = nothing;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
1
4
|
import type { Maybe } from '../maybe';
|
|
2
|
-
import type { Map } from '
|
|
5
|
+
import type { Map } from '../../types/map';
|
|
3
6
|
/**
|
|
4
7
|
* Binds the value of the `monad` to new monad created
|
|
5
8
|
* by the `transition` function.
|
|
6
9
|
*/
|
|
7
|
-
export
|
|
10
|
+
export default function bind<Value, NextValue>(transition: Map<Value, Maybe<NextValue>>): (monad: Maybe<Value>) => Maybe<NextValue>;
|
|
8
11
|
/**
|
|
9
12
|
* Binds the value of the `monad` to new monad created
|
|
10
13
|
* by the `transition` function.
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
13
|
-
export default bind;
|
|
15
|
+
export default function bind<Value, NextValue>(monad: Maybe<Value>, transition: Map<Value, Maybe<NextValue>>): Maybe<NextValue>;
|
package/maybe/operators/bind.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Maybe 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 fold_1 = require("./fold");
|
|
11
|
+
var guards_1 = require("./guards");
|
|
12
|
+
function bind() {
|
|
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, transition) {
|
|
18
|
+
return ternary_1.default(guards_1.isJust, compose_1.default(transition, fold_1.default), identity_1.default)(monad);
|
|
19
|
+
}).apply(void 0, args);
|
|
20
|
+
}
|
|
21
|
+
exports.default = bind;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
1
4
|
import { Maybe } from '../maybe';
|
|
2
|
-
import type { Map } from '
|
|
5
|
+
import type { Map } from '../../types/map';
|
|
3
6
|
/**
|
|
4
7
|
* Maps the value of the provided `monad` through the `transition` function
|
|
5
8
|
* and returns a new `Maybe` of the mapped value.
|
|
6
9
|
*/
|
|
7
|
-
export
|
|
10
|
+
export default function fmap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => Maybe<NextValue>;
|
|
8
11
|
/**
|
|
9
12
|
* Maps the value of the provided `monad` through the `transition` function
|
|
10
13
|
* and returns a new `Maybe` of the mapped value.
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
13
|
-
export default fmap;
|
|
15
|
+
export default function fmap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): Maybe<NextValue>;
|
package/maybe/operators/fmap.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Maybe Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var compose_1 = require("../../compose");
|
|
7
|
+
var identity_1 = require("../../identity");
|
|
8
|
+
var maybe_1 = require("../maybe");
|
|
9
|
+
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
10
|
+
var fold_1 = require("./fold");
|
|
11
|
+
var guards_1 = require("./guards");
|
|
12
|
+
var ternary_1 = require("../../ternary");
|
|
13
|
+
function fmap() {
|
|
14
|
+
var args = [];
|
|
15
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
+
args[_i] = arguments[_i];
|
|
17
|
+
}
|
|
18
|
+
return permutation_2_1.default(function (monad, transition) {
|
|
19
|
+
return ternary_1.default(guards_1.isJust, compose_1.default(maybe_1.default, transition, fold_1.default), identity_1.default)(monad);
|
|
20
|
+
}).apply(void 0, args);
|
|
21
|
+
}
|
|
22
|
+
exports.default = fmap;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
1
4
|
import type { Just } from '../just';
|
|
2
5
|
import type { Maybe } from '../maybe';
|
|
3
6
|
import type { Nothing } from '../nothing';
|
|
4
|
-
import type { Map } from '
|
|
7
|
+
import type { Map } from '../../types/map';
|
|
5
8
|
/**
|
|
6
9
|
* A type to unwrap the provided `Monad` into the new value type.
|
|
7
10
|
*/
|
|
@@ -10,30 +13,29 @@ export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends
|
|
|
10
13
|
* Maps the value of the provided `monad` through the `transition` function
|
|
11
14
|
* and returns the mapped value or `null`.
|
|
12
15
|
*/
|
|
13
|
-
export
|
|
16
|
+
export default function foldMap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Just<Value>) => NextValue;
|
|
14
17
|
/**
|
|
15
18
|
* Maps the value of the provided `monad` through the `transition` function
|
|
16
19
|
* and returns the mapped value or `null`.
|
|
17
20
|
*/
|
|
18
|
-
export
|
|
21
|
+
export default function foldMap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Nothing) => null;
|
|
19
22
|
/**
|
|
20
23
|
* Maps the value of the provided `monad` through the `transition` function
|
|
21
24
|
* and returns the mapped value or `null`.
|
|
22
25
|
*/
|
|
23
|
-
export
|
|
26
|
+
export default function foldMap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => NextValue | null;
|
|
24
27
|
/**
|
|
25
28
|
* Maps the value of the provided `monad` through the `transition` function
|
|
26
29
|
* and returns the mapped value or `null`.
|
|
27
30
|
*/
|
|
28
|
-
export
|
|
31
|
+
export default function foldMap<Value, NextValue = Value>(monad: Just<Value>, transition: Map<Value, NextValue>): NextValue;
|
|
29
32
|
/**
|
|
30
33
|
* Maps the value of the provided `monad` through the `transition` function
|
|
31
34
|
* and returns the mapped value or `null`.
|
|
32
35
|
*/
|
|
33
|
-
export
|
|
36
|
+
export default function foldMap<Value, NextValue = Value>(monad: Nothing, transition: Map<Value, NextValue>): null;
|
|
34
37
|
/**
|
|
35
38
|
* Maps the value of the provided `monad` through the `transition` function
|
|
36
39
|
* and returns the mapped value or `null`.
|
|
37
40
|
*/
|
|
38
|
-
export
|
|
39
|
-
export default foldMap;
|
|
41
|
+
export default function foldMap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): NextValue | null;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module Maybe Operators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var compose_1 = require("../../compose");
|
|
7
|
+
var ternary_1 = require("../../ternary");
|
|
8
|
+
var permutation_2_1 = require("../../permutation/permutation-2");
|
|
9
|
+
var fold_1 = require("./fold");
|
|
10
|
+
var guards_1 = require("./guards");
|
|
11
|
+
function foldMap() {
|
|
12
|
+
var args = [];
|
|
13
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
|
+
args[_i] = arguments[_i];
|
|
15
|
+
}
|
|
16
|
+
return permutation_2_1.default(function (monad, transition) {
|
|
17
|
+
return ternary_1.default(guards_1.isJust, compose_1.default(transition, fold_1.default), function () { return null; })(monad);
|
|
18
|
+
}).apply(void 0, args);
|
|
19
|
+
}
|
|
20
|
+
exports.default = foldMap;
|