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.
Files changed (89) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/apply.js +6 -17
  4. package/compose.js +3 -16
  5. package/curry.js +6 -20
  6. package/either/either-sync.d.ts +1 -1
  7. package/either/either-sync.js +5 -8
  8. package/either/either.d.ts +2 -2
  9. package/either/either.js +5 -8
  10. package/either/index.d.ts +4 -4
  11. package/either/index.js +4 -11
  12. package/either/left.js +8 -13
  13. package/either/operators/bifold/bifold.d.ts +3 -3
  14. package/either/operators/bifold/bifold.js +7 -10
  15. package/either/operators/bifold/bifoldl.d.ts +2 -2
  16. package/either/operators/bifold/bifoldl.js +5 -8
  17. package/either/operators/bifold/bifoldr.d.ts +2 -2
  18. package/either/operators/bifold/bifoldr.js +5 -8
  19. package/either/operators/bifold/index.d.ts +3 -3
  20. package/either/operators/bifold/index.js +3 -9
  21. package/either/operators/bifold-map/bifold-map.d.ts +1 -1
  22. package/either/operators/bifold-map/bifold-map.js +16 -23
  23. package/either/operators/bifold-map/bifoldl-map.d.ts +3 -3
  24. package/either/operators/bifold-map/bifoldl-map.js +9 -16
  25. package/either/operators/bifold-map/bifoldr-map.d.ts +3 -3
  26. package/either/operators/bifold-map/bifoldr-map.js +9 -16
  27. package/either/operators/bifold-map/index.d.ts +3 -3
  28. package/either/operators/bifold-map/index.js +3 -9
  29. package/either/operators/bimap/bimap.d.ts +1 -1
  30. package/either/operators/bimap/bimap.js +10 -17
  31. package/either/operators/bimap/first.d.ts +2 -2
  32. package/either/operators/bimap/first.js +12 -19
  33. package/either/operators/bimap/index.d.ts +3 -3
  34. package/either/operators/bimap/index.js +3 -9
  35. package/either/operators/bimap/second.d.ts +2 -2
  36. package/either/operators/bimap/second.js +12 -19
  37. package/either/operators/bindr.d.ts +1 -1
  38. package/either/operators/bindr.js +11 -18
  39. package/either/operators/guards.d.ts +3 -3
  40. package/either/operators/guards.js +7 -13
  41. package/either/operators/index.d.ts +5 -5
  42. package/either/operators/index.js +5 -30
  43. package/either/right.js +8 -13
  44. package/guard.d.ts +3 -3
  45. package/guard.js +8 -19
  46. package/identity.js +1 -4
  47. package/index.d.ts +9 -11
  48. package/index.js +9 -25
  49. package/inject.js +7 -18
  50. package/{get.d.ts → lens/get.d.ts} +8 -3
  51. package/lens/get.js +29 -0
  52. package/lens/index.d.ts +3 -0
  53. package/lens/index.js +3 -0
  54. package/lens/lens.d.ts +19 -0
  55. package/lens/lens.js +17 -0
  56. package/{set.d.ts → lens/set.d.ts} +11 -5
  57. package/lens/set.js +45 -0
  58. package/maybe/index.d.ts +3 -3
  59. package/maybe/index.js +3 -9
  60. package/maybe/just.js +8 -13
  61. package/maybe/maybe.d.ts +2 -2
  62. package/maybe/maybe.js +5 -8
  63. package/maybe/nothing.js +7 -12
  64. package/maybe/operators/bind.d.ts +1 -1
  65. package/maybe/operators/bind.js +11 -18
  66. package/maybe/operators/fmap.d.ts +1 -1
  67. package/maybe/operators/fmap.js +12 -19
  68. package/maybe/operators/fold-map.d.ts +3 -3
  69. package/maybe/operators/fold-map.js +9 -16
  70. package/maybe/operators/fold.d.ts +3 -3
  71. package/maybe/operators/fold.js +7 -10
  72. package/maybe/operators/guards.d.ts +3 -3
  73. package/maybe/operators/guards.js +7 -13
  74. package/maybe/operators/index.d.ts +5 -5
  75. package/maybe/operators/index.js +5 -26
  76. package/package.json +11 -4
  77. package/permutation/index.d.ts +2 -2
  78. package/permutation/index.js +2 -7
  79. package/permutation/permutation-2.js +5 -12
  80. package/permutation/permutation-3.d.ts +1 -1
  81. package/permutation/permutation-3.js +5 -12
  82. package/pipe.js +4 -16
  83. package/rethrow.js +3 -6
  84. package/tap.d.ts +1 -1
  85. package/tap.js +4 -7
  86. package/tsconfig.json +2 -3
  87. package/types/index.d.ts +10 -10
  88. package/get.js +0 -26
  89. package/set.js +0 -42
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021-2021 Dmytro Vasylkivskyi
1
+ Copyright (c) 2021-2024 Dmytro Vasylkivskyi
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 4.7 is required for this package's typings to work properly.**
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
- var functions = [];
11
- for (var _i = 0; _i < arguments.length; _i++) {
12
- functions[_i] = arguments[_i];
13
- }
14
- return function () {
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
- ? function () {
16
- var args = [];
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
- if (length === void 0) { length = fn.length; }
16
- return function () {
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.apply(void 0, args);
16
+ return fn(...args);
24
17
  }
25
18
  if (argsLength > length) {
26
- return fn.apply(void 0, args.slice(0, length));
19
+ return fn(...args.slice(0, length));
27
20
  }
28
- return curry(function () {
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;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module Either
3
3
  */
4
- import type { Either } from './either';
4
+ import type { Either } from './either.js';
5
5
  /**
6
6
  * Type constructor for `Either`.
7
7
  * Creates either `Right` of the value provided,
@@ -1,21 +1,18 @@
1
- "use strict";
2
1
  /**
3
2
  * @module Either
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var left_1 = require("./left");
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 (0, right_1.default)(value());
13
+ return right(value());
16
14
  }
17
15
  catch (error) {
18
- return (0, left_1.default)(error);
16
+ return left(error);
19
17
  }
20
18
  }
21
- exports.default = eitherSync;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @module Either
3
3
  */
4
- import { Left } from './left';
5
- import { Right } from './right';
4
+ import { Left } from './left.js';
5
+ import { Right } from './right.js';
6
6
  /**
7
7
  * Type constructor for `Either`.
8
8
  * Can be either `Right` of the value provided,
package/either/either.js CHANGED
@@ -1,18 +1,15 @@
1
- "use strict";
2
1
  /**
3
2
  * @module Either
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var left_1 = require("./left");
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(right_1.default)
16
- .catch(left_1.default);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.eitherSync = exports.right = exports.left = exports.default = void 0;
4
- var either_1 = require("./either");
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
- exports.lid = Symbol.for('@@functional/left');
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
- var _a;
18
- return _a = {},
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
- _a.toString = function () {
22
- return "Left ".concat(value);
23
- },
24
- _a;
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var guards_1 = require("../guards");
7
- var left_1 = require("../../left");
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 (0, guards_1.isLeft)(monad)
14
- ? monad[left_1.lid]
15
- : monad[right_1.rid];
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var guards_1 = require("../guards");
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 (0, guards_1.isLeft)(monad)
14
- ? monad[left_1.lid]
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var guards_1 = require("../guards");
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 (0, guards_1.isRight)(monad)
14
- ? monad[right_1.rid]
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bifoldr = exports.bifoldl = exports.default = void 0;
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,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 provided `monad` to a value,
@@ -1,31 +1,24 @@
1
- "use strict";
2
1
  /**
3
2
  * @module Either Operators
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
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");
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 function (monad) {
19
- return (0, compose_1.default)(args[0], bifold_1.default, monad);
12
+ return (monad) => {
13
+ return compose(args[0], bifold, monad);
20
14
  };
21
15
  }
22
- if (args.length === 2 && (0, guards_1.isEither)(args[0])) {
23
- return (0, compose_1.default)(args[1], bifold_1.default, args[0]);
16
+ if (args.length === 2 && isEither(args[0])) {
17
+ return compose(args[1], bifold, args[0]);
24
18
  }
25
- return (0, permutation_3_1.default)(function (monad, mapLeft, mapRight) {
26
- return ((0, guards_1.isLeft)(monad)
27
- ? (0, bifoldl_map_1.default)(monad, mapLeft)
28
- : (0, bifoldr_map_1.default)(monad, mapRight));
29
- }).apply(void 0, args);
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
- 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)
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
- }).apply(void 0, args);
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
- 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)
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
- }).apply(void 0, args);
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
- "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; } });
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var guards_1 = require("../guards");
7
- var permutation_3_1 = require("../../../permutation/permutation-3");
8
- var first_1 = require("./first");
9
- var second_1 = require("./second");
10
- function bimap() {
11
- var args = [];
12
- for (var _i = 0; _i < arguments.length; _i++) {
13
- args[_i] = arguments[_i];
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
  /**