fnts 1.3.2 → 1.5.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/either/left.js CHANGED
@@ -17,6 +17,10 @@ function left(value) {
17
17
  var _a;
18
18
  return _a = {},
19
19
  _a[exports.lid] = value,
20
+ // @ts-expect-error: Undocumented API for external use
21
+ _a.toString = function () {
22
+ return "Left " + value;
23
+ },
20
24
  _a;
21
25
  }
22
26
  exports.default = left;
@@ -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/either/right.js CHANGED
@@ -17,6 +17,10 @@ function right(value) {
17
17
  var _a;
18
18
  return _a = {},
19
19
  _a[exports.rid] = value,
20
+ // @ts-expect-error: Undocumented API for external use
21
+ _a.toString = function () {
22
+ return "Right " + value;
23
+ },
20
24
  _a;
21
25
  }
22
26
  exports.default = right;
package/maybe/just.js CHANGED
@@ -17,6 +17,10 @@ function just(value) {
17
17
  var _a;
18
18
  return _a = {},
19
19
  _a[exports.jid] = value,
20
+ // @ts-expect-error: Undocumented API for external use
21
+ _a.toString = function () {
22
+ return "Just " + value;
23
+ },
20
24
  _a;
21
25
  }
22
26
  exports.default = just;
package/maybe/nothing.js CHANGED
@@ -17,6 +17,10 @@ function nothing() {
17
17
  var _a;
18
18
  return _a = {},
19
19
  _a[exports.nid] = null,
20
+ // @ts-expect-error: Undocumented API for external use
21
+ _a.toString = function () {
22
+ return 'Nothing';
23
+ },
20
24
  _a;
21
25
  }
22
26
  exports.default = nothing;
@@ -9,31 +9,11 @@ import type { Map } from '../../types/map';
9
9
  * A type to unwrap the provided `Monad` into the new value type.
10
10
  */
11
11
  export declare type FoldMap<Monad extends Maybe<any>, NextValue> = Monad extends Just<any> ? NextValue : Monad extends Nothing ? null : never;
12
- /**
13
- * Maps the value of the provided `monad` through the `transition` function
14
- * and returns the mapped value or `null`.
15
- */
16
- export default function foldMap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Just<Value>) => NextValue;
17
- /**
18
- * Maps the value of the provided `monad` through the `transition` function
19
- * and returns the mapped value or `null`.
20
- */
21
- export default function foldMap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Nothing) => null;
22
12
  /**
23
13
  * Maps the value of the provided `monad` through the `transition` function
24
14
  * and returns the mapped value or `null`.
25
15
  */
26
16
  export default function foldMap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => NextValue | null;
27
- /**
28
- * Maps the value of the provided `monad` through the `transition` function
29
- * and returns the mapped value or `null`.
30
- */
31
- export default function foldMap<Value, NextValue = Value>(monad: Just<Value>, transition: Map<Value, NextValue>): NextValue;
32
- /**
33
- * Maps the value of the provided `monad` through the `transition` function
34
- * and returns the mapped value or `null`.
35
- */
36
- export default function foldMap<Value, NextValue = Value>(monad: Nothing, transition: Map<Value, NextValue>): null;
37
17
  /**
38
18
  * Maps the value of the provided `monad` through the `transition` function
39
19
  * and returns the mapped value or `null`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnts",
3
- "version": "1.3.2",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "author": "Dmytro Vasylkivskyi",
6
6
  "description": "TypeScript / JavaScript FP utilities",