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.
Files changed (95) hide show
  1. package/README.md +4 -50
  2. package/compose.d.ts +9 -9
  3. package/compose.js +24 -1
  4. package/curry.d.ts +8 -5
  5. package/curry.js +37 -1
  6. package/either/either-sync.d.ts +4 -2
  7. package/either/either-sync.js +21 -1
  8. package/either/either.d.ts +4 -2
  9. package/either/either.js +18 -1
  10. package/either/index.d.ts +3 -3
  11. package/either/index.js +11 -1
  12. package/either/left.d.ts +4 -2
  13. package/either/left.js +22 -1
  14. package/either/operators/bifold/bifold.d.ts +4 -2
  15. package/either/operators/bifold/bifold.js +15 -1
  16. package/either/operators/bifold/bifoldl.d.ts +4 -2
  17. package/either/operators/bifold/bifoldl.js +17 -1
  18. package/either/operators/bifold/bifoldr.d.ts +4 -2
  19. package/either/operators/bifold/bifoldr.js +17 -1
  20. package/either/operators/bifold/index.d.ts +3 -3
  21. package/either/operators/bifold/index.js +9 -1
  22. package/either/operators/bifold-map.d.ts +6 -4
  23. package/either/operators/bifold-map.js +20 -1
  24. package/either/operators/bimap/bimap.d.ts +6 -4
  25. package/either/operators/bimap/bimap.js +20 -1
  26. package/either/operators/bimap/first.d.ts +6 -4
  27. package/either/operators/bimap/first.js +22 -1
  28. package/either/operators/bimap/index.d.ts +3 -3
  29. package/either/operators/bimap/index.js +9 -1
  30. package/either/operators/bimap/second.d.ts +6 -4
  31. package/either/operators/bimap/second.js +22 -1
  32. package/either/operators/guards.d.ts +3 -0
  33. package/either/operators/guards.js +22 -1
  34. package/either/operators/index.d.ts +3 -3
  35. package/either/operators/index.js +24 -1
  36. package/either/right.d.ts +4 -2
  37. package/either/right.js +22 -1
  38. package/guard.d.ts +6 -3
  39. package/guard.js +36 -1
  40. package/identity.d.ts +4 -2
  41. package/identity.js +12 -1
  42. package/index.d.ts +9 -5
  43. package/index.js +21 -1
  44. package/inject.d.ts +15 -0
  45. package/inject.js +23 -0
  46. package/maybe/index.d.ts +2 -2
  47. package/maybe/index.js +9 -1
  48. package/maybe/just.d.ts +4 -2
  49. package/maybe/just.js +22 -1
  50. package/maybe/maybe.d.ts +4 -2
  51. package/maybe/maybe.js +17 -1
  52. package/maybe/nothing.d.ts +4 -2
  53. package/maybe/nothing.js +22 -1
  54. package/maybe/operators/bind.d.ts +6 -4
  55. package/maybe/operators/bind.js +21 -1
  56. package/maybe/operators/fmap.d.ts +6 -4
  57. package/maybe/operators/fmap.js +22 -1
  58. package/maybe/operators/fold-map.d.ts +10 -8
  59. package/maybe/operators/fold-map.js +20 -1
  60. package/maybe/operators/fold.d.ts +4 -2
  61. package/maybe/operators/fold.js +17 -1
  62. package/maybe/operators/guards.d.ts +3 -0
  63. package/maybe/operators/guards.js +22 -1
  64. package/maybe/operators/index.d.ts +4 -4
  65. package/maybe/operators/index.js +14 -1
  66. package/package.json +10 -4
  67. package/permutation/index.d.ts +2 -0
  68. package/permutation/index.js +7 -0
  69. package/permutation/permutation-2.d.ts +8 -0
  70. package/permutation/permutation-2.js +18 -0
  71. package/permutation/permutation-3.d.ts +8 -0
  72. package/permutation/permutation-3.js +18 -0
  73. package/pipe.d.ts +9 -9
  74. package/pipe.js +24 -1
  75. package/rethrow.d.ts +9 -0
  76. package/rethrow.js +16 -0
  77. package/tap.d.ts +11 -0
  78. package/tap.js +15 -0
  79. package/ternary.d.ts +10 -0
  80. package/ternary.js +16 -0
  81. package/tsconfig.json +1 -1
  82. package/types/effect.d.ts +11 -0
  83. package/types/function.d.ts +13 -0
  84. package/types/gradual.d.ts +17 -0
  85. package/types/index.d.ts +7 -0
  86. package/{.internal → types}/last.d.ts +7 -0
  87. package/types/map.d.ts +8 -0
  88. package/{.internal → types}/slice.d.ts +7 -0
  89. package/{.internal → types}/tuple.d.ts +6 -0
  90. package/.internal/gradual.d.ts +0 -5
  91. package/.internal/map.d.ts +0 -1
  92. package/.internal/permutation-of-2.d.ts +0 -1
  93. package/.internal/permutation-of-2.js +0 -1
  94. package/.internal/permutation-of-3.d.ts +0 -1
  95. 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 '../../../.internal/map';
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 declare function second<LeftValue, RightValue, NextRightValue>(mapRight: Map<RightValue, NextRightValue>): (monad: Either<LeftValue, RightValue>) => Either<LeftValue, NextRightValue>;
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 declare function second<LeftValue, RightValue, NextRightValue>(monad: Either<LeftValue, RightValue>, mapRight: Map<RightValue, NextRightValue>): Either<LeftValue, NextRightValue>;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.second=second,exports.default=void 0;var _bifold=require("../bifold"),_guards=require("../guards"),_compose=_interopRequireDefault(require("../../../compose")),_right=_interopRequireWildcard(require("../../right")),_permutationOf=_interopRequireDefault(require("../../../.internal/permutation-of-2"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c.default=a,b&&b.set(a,c),c}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function second(){return(0,_permutationOf.default)((a,b)=>(0,_guards.isRight)(a)?(0,_compose.default)(_right.default,b,_bifold.bifoldr)(a):a)(...arguments)}var _default=second;exports.default=_default;
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,3 +1,6 @@
1
+ /**
2
+ * @module Either Operators
3
+ */
1
4
  import { Left } from '../left';
2
5
  import { Right } from '../right';
3
6
  import type { Either } from '../either';
@@ -1 +1,22 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isLeft=isLeft,exports.isRight=isRight;var _left=require("../left"),_right=require("../right");function isLeft(a){return Object.prototype.hasOwnProperty.call(a,_left.lid)}function isRight(a){return Object.prototype.hasOwnProperty.call(a,_right.rid)}
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 * from './bifold-map';
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";var _exportNames={bifoldl:!0,Bifoldl:!0,bifoldr:!0,Bifoldr:!0,bifold:!0,Bifold:!0,bimap:!0,first:!0,second:!0};var _bifoldMap=require("./bifold-map");var _bimap=require("./bimap");Object.defineProperty(exports,"__esModule",{value:!0});Object.defineProperty(exports,"bifoldl",{enumerable:!0,get:function get(){return _bifold.bifoldl}}),Object.defineProperty(exports,"Bifoldl",{enumerable:!0,get:function get(){return _bifold.Bifoldl}}),Object.defineProperty(exports,"bifoldr",{enumerable:!0,get:function get(){return _bifold.bifoldr}}),Object.defineProperty(exports,"Bifoldr",{enumerable:!0,get:function get(){return _bifold.Bifoldr}}),Object.defineProperty(exports,"bifold",{enumerable:!0,get:function get(){return _bifold.bifold}}),Object.defineProperty(exports,"Bifold",{enumerable:!0,get:function get(){return _bifold.Bifold}}),Object.defineProperty(exports,"bimap",{enumerable:!0,get:function get(){return _bimap.bimap}}),Object.defineProperty(exports,"first",{enumerable:!0,get:function get(){return _bimap.first}}),Object.defineProperty(exports,"second",{enumerable:!0,get:function get(){return _bimap.second}});var _bifold=require("./bifold"),_guards=require("./guards");Object.keys(_guards).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_guards[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _guards[a]}})});Object.keys(_bifoldMap).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_bifoldMap[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _bifoldMap[a]}})});
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 declare function right<Value>(value: Value): Right<Value>;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.right=right,exports.default=exports.rid=void 0;var rid=Symbol.for("@@functional/right");exports.rid=rid;function right(a){return{[rid]:a}}var _default=right;exports.default=_default;
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
- export declare type Guard<Function extends (...args: any[]) => any> = [
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 declare function guard<Function extends (...args: any[]) => any>(...guards: [...Guard<Function>[], Function]): (...args: Parameters<Function>) => ReturnType<Function>;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.guard=guard,exports.default=void 0;function guard(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return function(){for(var a=b.length-1,c=b[a],d=arguments.length,e=Array(d),f=0;f<d;f++)e[f]=arguments[f];for(var g=0;g<a;g+=1){var[h,i]=b[g];if(h.apply(void 0,e))return i.apply(void 0,e)}return c.apply(void 0,e)}}var _default=guard;exports.default=_default;
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 declare function identity<T>(x: T): T;
9
- export default identity;
11
+ export default function identity<T>(x: T): T;
package/identity.js CHANGED
@@ -1 +1,12 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.identity=identity,exports.default=void 0;function identity(a){return a}var _default=identity;exports.default=_default;
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 * from './pipe';
2
- export * from './curry';
3
- export * from './guard';
4
- export * from './compose';
5
- export * from './identity';
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";var _pipe=require("./pipe");var _curry=require("./curry");var _guard=require("./guard");var _compose=require("./compose");var _identity=require("./identity");Object.defineProperty(exports,"__esModule",{value:!0});Object.keys(_pipe).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_pipe[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _pipe[a]}})});Object.keys(_curry).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_curry[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _curry[a]}})});Object.keys(_guard).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_guard[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _guard[a]}})});Object.keys(_compose).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_compose[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _compose[a]}})});Object.keys(_identity).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_identity[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _identity[a]}})});
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
@@ -1,3 +1,3 @@
1
- export { just, Just } from './just';
2
1
  export { default, Maybe } from './maybe';
3
- export { nothing, Nothing } from './nothing';
2
+ export { default as just, Just } from './just';
3
+ export { default as nothing, Nothing } from './nothing';
package/maybe/index.js CHANGED
@@ -1 +1,9 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"just",{enumerable:!0,get:function get(){return _just.just}}),Object.defineProperty(exports,"Just",{enumerable:!0,get:function get(){return _just.Just}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function get(){return _maybe.default}}),Object.defineProperty(exports,"Maybe",{enumerable:!0,get:function get(){return _maybe.Maybe}}),Object.defineProperty(exports,"nothing",{enumerable:!0,get:function get(){return _nothing.nothing}}),Object.defineProperty(exports,"Nothing",{enumerable:!0,get:function get(){return _nothing.Nothing}});var _just=require("./just"),_maybe=_interopRequireWildcard(require("./maybe")),_nothing=require("./nothing");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c.default=a,b&&b.set(a,c),c}
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 declare function just<Value>(value: Value): Just<Value>;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.just=just,exports.default=exports.jid=void 0;var jid=Symbol.for("@@functional/just");exports.jid=jid;function just(a){return{[jid]:a}}var _default=just;exports.default=_default;
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 declare function maybe<Value>(value: Value | null | undefined): Maybe<Value>;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.maybe=maybe,exports.default=void 0;var _just=_interopRequireWildcard(require("./just")),_nothing=_interopRequireWildcard(require("./nothing"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c.default=a,b&&b.set(a,c),c}function maybe(a){return null===a||a===void 0?(0,_nothing.default)():(0,_just.default)(a)}var _default=maybe;exports.default=_default;
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;
@@ -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 declare function nothing(): Nothing;
19
- export default nothing;
21
+ export default function nothing(): Nothing;
package/maybe/nothing.js CHANGED
@@ -1 +1,22 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nothing=nothing,exports.default=exports.nid=void 0;var nid=Symbol.for("@@functional/nothing");exports.nid=nid;function nothing(){return{[nid]:null}}var _default=nothing;exports.default=_default;
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 '../../.internal/map';
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 declare 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<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 declare function bind<Value, NextValue>(monad: Maybe<Value>, transition: Map<Value, Maybe<NextValue>>): Maybe<NextValue>;
13
- export default bind;
15
+ export default function bind<Value, NextValue>(monad: Maybe<Value>, transition: Map<Value, Maybe<NextValue>>): Maybe<NextValue>;
@@ -1 +1,21 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bind=bind,exports.default=void 0;var _compose=_interopRequireDefault(require("../../compose")),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_fold=_interopRequireDefault(require("./fold")),_guards=require("./guards");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function bind(){return(0,_permutationOf.default)((a,b)=>(0,_guards.isJust)(a)?(0,_compose.default)(b,_fold.default)(a):a)(...arguments)}var _default=bind;exports.default=_default;
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 '../../.internal/map';
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 declare function fmap<Value, NextValue>(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<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 declare function fmap<Value, NextValue>(monad: Maybe<Value>, transition: Map<Value, NextValue>): Maybe<NextValue>;
13
- export default fmap;
15
+ export default function fmap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): Maybe<NextValue>;
@@ -1 +1,22 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.fmap=fmap,exports.default=void 0;var _compose=_interopRequireDefault(require("../../compose")),_maybe=_interopRequireWildcard(require("../maybe")),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_fold=_interopRequireDefault(require("./fold")),_guards=require("./guards");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c.default=a,b&&b.set(a,c),c}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function fmap(){return(0,_permutationOf.default)((a,b)=>(0,_guards.isJust)(a)?(0,_compose.default)(_maybe.default,b,_fold.default)(a):a)(...arguments)}var _default=fmap;exports.default=_default;
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 '../../.internal/map';
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 declare function foldMap<Value, NextValue>(transition: Map<Value, NextValue>): (monad: Just<Value>) => NextValue;
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 declare function foldMap<Value, NextValue>(transition: Map<Value, NextValue>): (monad: Nothing) => null;
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 declare function foldMap<Value, NextValue>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => NextValue | null;
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 declare function foldMap<Value, NextValue>(monad: Just<Value>, transition: Map<Value, NextValue>): NextValue;
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 declare function foldMap<Value, NextValue>(monad: Nothing, transition: Map<Value, NextValue>): null;
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 declare function foldMap<Value, NextValue>(monad: Maybe<Value>, transition: Map<Value, NextValue>): NextValue | null;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.foldMap=foldMap,exports.default=void 0;var _compose=_interopRequireDefault(require("../../compose")),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_fold=_interopRequireDefault(require("./fold")),_guards=require("./guards");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function foldMap(){return(0,_permutationOf.default)((a,b)=>(0,_guards.isJust)(a)?(0,_compose.default)(b,_fold.default)(a):null)(...arguments)}var _default=foldMap;exports.default=_default;
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;