fnts 2.2.0 → 3.0.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/LICENSE +1 -1
- package/README.md +1 -1
- package/apply.js +6 -17
- package/compose.js +3 -16
- package/curry.js +6 -20
- package/either/either-sync.d.ts +1 -1
- package/either/either-sync.js +5 -8
- package/either/either.d.ts +2 -2
- package/either/either.js +5 -8
- package/either/index.d.ts +4 -4
- package/either/index.js +4 -11
- package/either/left.js +8 -13
- package/either/operators/bifold/bifold.d.ts +3 -3
- package/either/operators/bifold/bifold.js +7 -10
- package/either/operators/bifold/bifoldl.d.ts +2 -2
- package/either/operators/bifold/bifoldl.js +5 -8
- package/either/operators/bifold/bifoldr.d.ts +2 -2
- package/either/operators/bifold/bifoldr.js +5 -8
- package/either/operators/bifold/index.d.ts +3 -3
- package/either/operators/bifold/index.js +3 -9
- package/either/operators/bifold-map/bifold-map.d.ts +1 -1
- package/either/operators/bifold-map/bifold-map.js +16 -23
- package/either/operators/bifold-map/bifoldl-map.d.ts +3 -3
- package/either/operators/bifold-map/bifoldl-map.js +9 -16
- package/either/operators/bifold-map/bifoldr-map.d.ts +3 -3
- package/either/operators/bifold-map/bifoldr-map.js +9 -16
- package/either/operators/bifold-map/index.d.ts +3 -3
- package/either/operators/bifold-map/index.js +3 -9
- package/either/operators/bimap/bimap.d.ts +1 -1
- package/either/operators/bimap/bimap.js +10 -17
- package/either/operators/bimap/first.d.ts +2 -2
- package/either/operators/bimap/first.js +12 -19
- package/either/operators/bimap/index.d.ts +3 -3
- package/either/operators/bimap/index.js +3 -9
- package/either/operators/bimap/second.d.ts +2 -2
- package/either/operators/bimap/second.js +12 -19
- package/either/operators/bindr.d.ts +1 -1
- package/either/operators/bindr.js +11 -18
- package/either/operators/guards.d.ts +3 -3
- package/either/operators/guards.js +7 -13
- package/either/operators/index.d.ts +5 -5
- package/either/operators/index.js +5 -30
- package/either/right.js +8 -13
- package/guard.d.ts +3 -3
- package/guard.js +8 -19
- package/identity.js +1 -4
- package/index.d.ts +9 -11
- package/index.js +9 -25
- package/inject.js +7 -18
- package/{get.d.ts → lens/get.d.ts} +8 -3
- package/lens/get.js +29 -0
- package/lens/index.d.ts +3 -0
- package/lens/index.js +3 -0
- package/lens/lens.d.ts +19 -0
- package/lens/lens.js +17 -0
- package/{set.d.ts → lens/set.d.ts} +11 -5
- package/lens/set.js +45 -0
- package/maybe/index.d.ts +3 -3
- package/maybe/index.js +3 -9
- package/maybe/just.js +8 -13
- package/maybe/maybe.d.ts +2 -2
- package/maybe/maybe.js +5 -8
- package/maybe/nothing.js +7 -12
- package/maybe/operators/bind.d.ts +1 -1
- package/maybe/operators/bind.js +11 -18
- package/maybe/operators/fmap.d.ts +1 -1
- package/maybe/operators/fmap.js +12 -19
- package/maybe/operators/fold-map.d.ts +3 -3
- package/maybe/operators/fold-map.js +9 -16
- package/maybe/operators/fold.d.ts +3 -3
- package/maybe/operators/fold.js +7 -10
- package/maybe/operators/guards.d.ts +3 -3
- package/maybe/operators/guards.js +7 -13
- package/maybe/operators/index.d.ts +5 -5
- package/maybe/operators/index.js +5 -26
- package/package.json +11 -4
- package/permutation/index.d.ts +2 -2
- package/permutation/index.js +2 -7
- package/permutation/permutation-2.js +5 -12
- package/permutation/permutation-3.d.ts +1 -1
- package/permutation/permutation-3.js +5 -12
- package/pipe.js +4 -16
- package/rethrow.js +3 -6
- package/tap.d.ts +1 -1
- package/tap.js +4 -7
- package/tsconfig.json +2 -3
- package/types/index.d.ts +10 -10
- package/get.js +0 -26
- package/set.js +0 -42
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ TypeScript / JavaScript functional programming utilities inspired by the
|
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
|
-
**TypeScript
|
|
24
|
+
**TypeScript 5.0 is required for this package's typings to work properly.**
|
|
25
25
|
|
|
26
26
|
```shell
|
|
27
27
|
npm i fnts
|
package/apply.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Application
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
4
|
/**
|
|
7
5
|
* Applies all functions on curried arguments and returns an array of results.
|
|
8
6
|
*/
|
|
9
|
-
function apply() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var args = [];
|
|
16
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
17
|
-
args[_i] = arguments[_i];
|
|
18
|
-
}
|
|
19
|
-
var length = functions.length;
|
|
20
|
-
var result = new Array(length);
|
|
21
|
-
for (var index = 0; index < length; index += 1) {
|
|
22
|
-
result[index] = functions[index].apply(functions, args);
|
|
7
|
+
export default function apply(...functions) {
|
|
8
|
+
return (...args) => {
|
|
9
|
+
const length = functions.length;
|
|
10
|
+
const result = new Array(length);
|
|
11
|
+
for (let index = 0; index < length; index += 1) {
|
|
12
|
+
result[index] = functions[index](...args);
|
|
23
13
|
}
|
|
24
14
|
return result;
|
|
25
15
|
};
|
|
26
16
|
}
|
|
27
|
-
exports.default = apply;
|
package/compose.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Composition
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
4
|
/**
|
|
7
5
|
* (B -> C) . (A -> B) = A -> C
|
|
8
6
|
*/
|
|
9
|
-
function compose(f, g) {
|
|
10
|
-
var maybeArgs = [];
|
|
11
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
12
|
-
maybeArgs[_i - 2] = arguments[_i];
|
|
13
|
-
}
|
|
7
|
+
export default function compose(f, g, ...maybeArgs) {
|
|
14
8
|
return maybeArgs.length === 0
|
|
15
|
-
?
|
|
16
|
-
|
|
17
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18
|
-
args[_i] = arguments[_i];
|
|
19
|
-
}
|
|
20
|
-
return f(g.apply(void 0, args));
|
|
21
|
-
}
|
|
22
|
-
: f(g.apply(void 0, maybeArgs));
|
|
9
|
+
? (...args) => f(g(...args))
|
|
10
|
+
: f(g(...maybeArgs));
|
|
23
11
|
}
|
|
24
|
-
exports.default = compose;
|
package/curry.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Curry
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
4
|
/**
|
|
7
5
|
* Creates an auto-curried function from the one provided.
|
|
8
6
|
* Until the curried function receives an expected number of arguments,
|
|
@@ -11,27 +9,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
9
|
* of arguments.
|
|
12
10
|
* Any excess arguments will not be applied.
|
|
13
11
|
*/
|
|
14
|
-
function curry(fn, length) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var args = [];
|
|
18
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
-
args[_i] = arguments[_i];
|
|
20
|
-
}
|
|
21
|
-
var argsLength = args.length;
|
|
12
|
+
export default function curry(fn, length = fn.length) {
|
|
13
|
+
return (...args) => {
|
|
14
|
+
const argsLength = args.length;
|
|
22
15
|
if (argsLength === length) {
|
|
23
|
-
return fn
|
|
16
|
+
return fn(...args);
|
|
24
17
|
}
|
|
25
18
|
if (argsLength > length) {
|
|
26
|
-
return fn
|
|
19
|
+
return fn(...args.slice(0, length));
|
|
27
20
|
}
|
|
28
|
-
return curry(
|
|
29
|
-
var nextArgs = [];
|
|
30
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
-
nextArgs[_i] = arguments[_i];
|
|
32
|
-
}
|
|
33
|
-
return fn.apply(void 0, args.concat(nextArgs));
|
|
34
|
-
}, length - argsLength);
|
|
21
|
+
return curry((...nextArgs) => fn(...args.concat(nextArgs)), length - argsLength);
|
|
35
22
|
};
|
|
36
23
|
}
|
|
37
|
-
exports.default = curry;
|
package/either/either-sync.d.ts
CHANGED
package/either/either-sync.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var right_1 = require("./right");
|
|
4
|
+
import left from './left.js';
|
|
5
|
+
import right from './right.js';
|
|
8
6
|
/**
|
|
9
7
|
* Type constructor for `Either`.
|
|
10
8
|
* Creates either `Right` of the value provided,
|
|
11
9
|
* or `Left` of the thrown error.
|
|
12
10
|
*/
|
|
13
|
-
function eitherSync(value) {
|
|
11
|
+
export default function eitherSync(value) {
|
|
14
12
|
try {
|
|
15
|
-
return (
|
|
13
|
+
return right(value());
|
|
16
14
|
}
|
|
17
15
|
catch (error) {
|
|
18
|
-
return (
|
|
16
|
+
return left(error);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
exports.default = eitherSync;
|
package/either/either.d.ts
CHANGED
package/either/either.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var right_1 = require("./right");
|
|
4
|
+
import left from './left.js';
|
|
5
|
+
import right from './right.js';
|
|
8
6
|
/**
|
|
9
7
|
* Type constructor for `Either`.
|
|
10
8
|
* Creates either `Right` of the value provided,
|
|
11
9
|
* or `Left` of the error thrown.
|
|
12
10
|
*/
|
|
13
|
-
function either(value) {
|
|
11
|
+
export default function either(value) {
|
|
14
12
|
return value()
|
|
15
|
-
.then(
|
|
16
|
-
.catch(
|
|
13
|
+
.then(right)
|
|
14
|
+
.catch(left);
|
|
17
15
|
}
|
|
18
|
-
exports.default = either;
|
package/either/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default, Either } from './either';
|
|
2
|
-
export { default as left, Left } from './left';
|
|
3
|
-
export { default as right, Right } from './right';
|
|
4
|
-
export { default as eitherSync } from './either-sync';
|
|
1
|
+
export { default, Either } from './either.js';
|
|
2
|
+
export { default as left, Left } from './left.js';
|
|
3
|
+
export { default as right, Right } from './right.js';
|
|
4
|
+
export { default as eitherSync } from './either-sync.js';
|
package/either/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return either_1.default; } });
|
|
6
|
-
var left_1 = require("./left");
|
|
7
|
-
Object.defineProperty(exports, "left", { enumerable: true, get: function () { return left_1.default; } });
|
|
8
|
-
var right_1 = require("./right");
|
|
9
|
-
Object.defineProperty(exports, "right", { enumerable: true, get: function () { return right_1.default; } });
|
|
10
|
-
var either_sync_1 = require("./either-sync");
|
|
11
|
-
Object.defineProperty(exports, "eitherSync", { enumerable: true, get: function () { return either_sync_1.default; } });
|
|
1
|
+
export { default } from './either.js';
|
|
2
|
+
export { default as left } from './left.js';
|
|
3
|
+
export { default as right } from './right.js';
|
|
4
|
+
export { default as eitherSync } from './either-sync.js';
|
package/either/left.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.lid = void 0;
|
|
7
4
|
/**
|
|
8
5
|
* Internal unique identifier for `Left`.
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const lid = Symbol.for('@@functional/left');
|
|
11
8
|
/**
|
|
12
9
|
* Constructor function for `Left`.
|
|
13
10
|
* Creates the special object with one property, represented as unique symbol
|
|
14
11
|
* key, holding the provided value.
|
|
15
12
|
*/
|
|
16
|
-
function left(value) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_a[exports.lid] = value,
|
|
13
|
+
export default function left(value) {
|
|
14
|
+
return {
|
|
15
|
+
[lid]: value,
|
|
20
16
|
// @ts-expect-error: Undocumented API for external use
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
17
|
+
toString() {
|
|
18
|
+
return `Left ${value}`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
25
21
|
}
|
|
26
|
-
exports.default = left;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import { Left } from '../../left';
|
|
5
|
-
import { Right } from '../../right';
|
|
6
|
-
import type { Either } from '../../either';
|
|
4
|
+
import { Left } from '../../left.js';
|
|
5
|
+
import { Right } from '../../right.js';
|
|
6
|
+
import type { Either } from '../../either.js';
|
|
7
7
|
/**
|
|
8
8
|
* A type to unwrap either the left or the right value type
|
|
9
9
|
* of the provided `Monad`.
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var right_1 = require("../../right");
|
|
4
|
+
import { isLeft } from '../guards.js';
|
|
5
|
+
import { lid } from '../../left.js';
|
|
6
|
+
import { rid } from '../../right.js';
|
|
9
7
|
/**
|
|
10
8
|
* Unwraps either the left or the right value of the provided `monad`.
|
|
11
9
|
*/
|
|
12
|
-
function bifold(monad) {
|
|
13
|
-
return
|
|
14
|
-
? monad[
|
|
15
|
-
: monad[
|
|
10
|
+
export default function bifold(monad) {
|
|
11
|
+
return isLeft(monad)
|
|
12
|
+
? monad[lid]
|
|
13
|
+
: monad[rid];
|
|
16
14
|
}
|
|
17
|
-
exports.default = bifold;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import { Left } from '../../left';
|
|
5
|
-
import type { Either } from '../../either';
|
|
4
|
+
import { Left } from '../../left.js';
|
|
5
|
+
import type { Either } from '../../either.js';
|
|
6
6
|
/**
|
|
7
7
|
* A type to unwrap the left value type of the provided `Monad`.
|
|
8
8
|
* If the `Monad` is `Right`, returns `undefined`.
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var left_1 = require("../../left");
|
|
4
|
+
import { isLeft } from '../guards.js';
|
|
5
|
+
import { lid } from '../../left.js';
|
|
8
6
|
/**
|
|
9
7
|
* Returns the left value of the provided `monad`.
|
|
10
8
|
* If the `monad` is `Right`, returns `undefined`.
|
|
11
9
|
*/
|
|
12
|
-
function bifoldl(monad) {
|
|
13
|
-
return
|
|
14
|
-
? monad[
|
|
10
|
+
export default function bifoldl(monad) {
|
|
11
|
+
return isLeft(monad)
|
|
12
|
+
? monad[lid]
|
|
15
13
|
: undefined;
|
|
16
14
|
}
|
|
17
|
-
exports.default = bifoldl;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import { Right } from '../../right';
|
|
5
|
-
import type { Either } from '../../either';
|
|
4
|
+
import { Right } from '../../right.js';
|
|
5
|
+
import type { Either } from '../../either.js';
|
|
6
6
|
/**
|
|
7
7
|
* A type to unwrap the right value type of the provided `Monad`.
|
|
8
8
|
* If the `Monad` is `Left`, returns `undefined`.
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var right_1 = require("../../right");
|
|
4
|
+
import { isRight } from '../guards.js';
|
|
5
|
+
import { rid } from '../../right.js';
|
|
8
6
|
/**
|
|
9
7
|
* Returns the right value of the provided `monad`.
|
|
10
8
|
* If the `monad` is `Left`, returns `undefined`.
|
|
11
9
|
*/
|
|
12
|
-
function bifoldr(monad) {
|
|
13
|
-
return
|
|
14
|
-
? monad[
|
|
10
|
+
export default function bifoldr(monad) {
|
|
11
|
+
return isRight(monad)
|
|
12
|
+
? monad[rid]
|
|
15
13
|
: undefined;
|
|
16
14
|
}
|
|
17
|
-
exports.default = bifoldr;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default, Bifold } from './bifold';
|
|
2
|
-
export { default as bifoldl, Bifoldl } from './bifoldl';
|
|
3
|
-
export { default as bifoldr, Bifoldr } from './bifoldr';
|
|
1
|
+
export { default, Bifold } from './bifold.js';
|
|
2
|
+
export { default as bifoldl, Bifoldl } from './bifoldl.js';
|
|
3
|
+
export { default as bifoldr, Bifoldr } from './bifoldr.js';
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var bifold_1 = require("./bifold");
|
|
5
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return bifold_1.default; } });
|
|
6
|
-
var bifoldl_1 = require("./bifoldl");
|
|
7
|
-
Object.defineProperty(exports, "bifoldl", { enumerable: true, get: function () { return bifoldl_1.default; } });
|
|
8
|
-
var bifoldr_1 = require("./bifoldr");
|
|
9
|
-
Object.defineProperty(exports, "bifoldr", { enumerable: true, get: function () { return bifoldr_1.default; } });
|
|
1
|
+
export { default } from './bifold.js';
|
|
2
|
+
export { default as bifoldl } from './bifoldl.js';
|
|
3
|
+
export { default as bifoldr } from './bifoldr.js';
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function bifoldMap() {
|
|
13
|
-
var args = [];
|
|
14
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15
|
-
args[_i] = arguments[_i];
|
|
16
|
-
}
|
|
4
|
+
import bifold from '../bifold/index.js';
|
|
5
|
+
import compose from '../../../compose.js';
|
|
6
|
+
import { isEither, isLeft } from '../guards.js';
|
|
7
|
+
import permutation3 from '../../../permutation/permutation-3.js';
|
|
8
|
+
import bifoldlMap from './bifoldl-map.js';
|
|
9
|
+
import bifoldrMap from './bifoldr-map.js';
|
|
10
|
+
export default function bifoldMap(...args) {
|
|
17
11
|
if (args.length === 1) {
|
|
18
|
-
return
|
|
19
|
-
return (
|
|
12
|
+
return (monad) => {
|
|
13
|
+
return compose(args[0], bifold, monad);
|
|
20
14
|
};
|
|
21
15
|
}
|
|
22
|
-
if (args.length === 2 &&
|
|
23
|
-
return (
|
|
16
|
+
if (args.length === 2 && isEither(args[0])) {
|
|
17
|
+
return compose(args[1], bifold, args[0]);
|
|
24
18
|
}
|
|
25
|
-
return (
|
|
26
|
-
return (
|
|
27
|
-
? (
|
|
28
|
-
: (
|
|
29
|
-
})
|
|
19
|
+
return permutation3((monad, mapLeft, mapRight) => {
|
|
20
|
+
return (isLeft(monad)
|
|
21
|
+
? bifoldlMap(monad, mapLeft)
|
|
22
|
+
: bifoldrMap(monad, mapRight));
|
|
23
|
+
})(...args);
|
|
30
24
|
}
|
|
31
|
-
exports.default = bifoldMap;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import type { Left } from '../../left';
|
|
5
|
-
import type { Either } from '../../either';
|
|
4
|
+
import type { Left } from '../../left.js';
|
|
5
|
+
import type { Either } from '../../either.js';
|
|
6
6
|
import type { Map } from '../../../types/map';
|
|
7
|
-
import { Bifoldl } from '../bifold/bifoldl';
|
|
7
|
+
import { Bifoldl } from '../bifold/bifoldl.js';
|
|
8
8
|
/**
|
|
9
9
|
* Maps provided `monad`'s left value to a new value,
|
|
10
10
|
* then returns it or `undefined`.
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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)
|
|
4
|
+
import { isLeft } from '../guards.js';
|
|
5
|
+
import compose from '../../../compose.js';
|
|
6
|
+
import bifoldl from '../bifold/bifoldl.js';
|
|
7
|
+
import permutation2 from '../../../permutation/permutation-2.js';
|
|
8
|
+
export default function bifoldlMap(...args) {
|
|
9
|
+
return permutation2((monad, map) => {
|
|
10
|
+
return isLeft(monad)
|
|
11
|
+
? compose(map, bifoldl, monad)
|
|
18
12
|
: undefined;
|
|
19
|
-
})
|
|
13
|
+
})(...args);
|
|
20
14
|
}
|
|
21
|
-
exports.default = bifoldlMap;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import { Right } from '../../right';
|
|
5
|
-
import type { Either } from '../../either';
|
|
4
|
+
import { Right } from '../../right.js';
|
|
5
|
+
import type { Either } from '../../either.js';
|
|
6
6
|
import type { Map } from '../../../types/map';
|
|
7
|
-
import { Bifoldr } from '../bifold/bifoldr';
|
|
7
|
+
import { Bifoldr } from '../bifold/bifoldr.js';
|
|
8
8
|
/**
|
|
9
9
|
* Maps provided `monad`'s right value to a new value,
|
|
10
10
|
* then returns it or `undefined`.
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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)
|
|
4
|
+
import { isRight } from '../guards.js';
|
|
5
|
+
import compose from '../../../compose.js';
|
|
6
|
+
import bifoldr from '../bifold/bifoldr.js';
|
|
7
|
+
import permutation2 from '../../../permutation/permutation-2.js';
|
|
8
|
+
export default function bifoldrMap(...args) {
|
|
9
|
+
return permutation2((monad, map) => {
|
|
10
|
+
return isRight(monad)
|
|
11
|
+
? compose(map, bifoldr, monad)
|
|
18
12
|
: undefined;
|
|
19
|
-
})
|
|
13
|
+
})(...args);
|
|
20
14
|
}
|
|
21
|
-
exports.default = bifoldrMap;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './bifold-map';
|
|
2
|
-
export { default as bifoldlMap } from './bifoldl-map';
|
|
3
|
-
export { default as bifoldrMap } from './bifoldr-map';
|
|
1
|
+
export { default } from './bifold-map.js';
|
|
2
|
+
export { default as bifoldlMap } from './bifoldl-map.js';
|
|
3
|
+
export { default as bifoldrMap } from './bifoldr-map.js';
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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; } });
|
|
1
|
+
export { default } from './bifold-map.js';
|
|
2
|
+
export { default as bifoldlMap } from './bifoldl-map.js';
|
|
3
|
+
export { default as bifoldrMap } from './bifoldr-map.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import type { Either } from '../../either';
|
|
4
|
+
import type { Either } from '../../either.js';
|
|
5
5
|
import type { Map } from '../../../types/map';
|
|
6
6
|
/**
|
|
7
7
|
* Maps left and right values of the provided `monad` to a new `Either` monad.
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module Either Operators
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return (0, permutation_3_1.default)(function (monad, mapLeft, mapRight) {
|
|
16
|
-
return (0, guards_1.isLeft)(monad)
|
|
17
|
-
? (0, first_1.default)(monad, mapLeft)
|
|
18
|
-
: (0, second_1.default)(monad, mapRight);
|
|
19
|
-
}).apply(void 0, args);
|
|
4
|
+
import { isLeft } from '../guards.js';
|
|
5
|
+
import permutation3 from '../../../permutation/permutation-3.js';
|
|
6
|
+
import first from './first.js';
|
|
7
|
+
import second from './second.js';
|
|
8
|
+
export default function bimap(...args) {
|
|
9
|
+
return permutation3((monad, mapLeft, mapRight) => {
|
|
10
|
+
return isLeft(monad)
|
|
11
|
+
? first(monad, mapLeft)
|
|
12
|
+
: second(monad, mapRight);
|
|
13
|
+
})(...args);
|
|
20
14
|
}
|
|
21
|
-
exports.default = bimap;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Either Operators
|
|
3
3
|
*/
|
|
4
|
-
import { Left } from '../../left';
|
|
5
|
-
import type { Either } from '../../either';
|
|
4
|
+
import { Left } from '../../left.js';
|
|
5
|
+
import type { Either } from '../../either.js';
|
|
6
6
|
import type { Map } from '../../../types/map';
|
|
7
7
|
export type First<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Either<infer LeftValue, any> ? LeftValue : never;
|
|
8
8
|
/**
|