fnts 1.2.0 → 1.3.0

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 (166) hide show
  1. package/README.md +4 -50
  2. package/cjs/compose.js +25 -0
  3. package/cjs/curry.js +37 -0
  4. package/cjs/either/either-sync.js +21 -0
  5. package/cjs/either/either.js +18 -0
  6. package/cjs/either/index.js +11 -0
  7. package/cjs/either/left.js +22 -0
  8. package/cjs/either/operators/bifold/bifold.js +15 -0
  9. package/cjs/either/operators/bifold/bifoldl.js +17 -0
  10. package/cjs/either/operators/bifold/bifoldr.js +17 -0
  11. package/cjs/either/operators/bifold/index.js +9 -0
  12. package/cjs/either/operators/bifold-map.js +20 -0
  13. package/cjs/either/operators/bimap/bimap.js +20 -0
  14. package/cjs/either/operators/bimap/first.js +22 -0
  15. package/cjs/either/operators/bimap/index.js +9 -0
  16. package/cjs/either/operators/bimap/second.js +22 -0
  17. package/cjs/either/operators/guards.js +22 -0
  18. package/cjs/either/operators/index.js +24 -0
  19. package/cjs/either/right.js +22 -0
  20. package/cjs/guard.js +37 -0
  21. package/cjs/identity.js +12 -0
  22. package/cjs/index.js +21 -0
  23. package/cjs/inject.js +23 -0
  24. package/cjs/maybe/index.js +9 -0
  25. package/cjs/maybe/just.js +22 -0
  26. package/cjs/maybe/maybe.js +17 -0
  27. package/cjs/maybe/nothing.js +22 -0
  28. package/cjs/maybe/operators/bind.js +21 -0
  29. package/cjs/maybe/operators/fmap.js +22 -0
  30. package/cjs/maybe/operators/fold-map.js +20 -0
  31. package/cjs/maybe/operators/fold.js +17 -0
  32. package/cjs/maybe/operators/guards.js +22 -0
  33. package/cjs/maybe/operators/index.js +14 -0
  34. package/cjs/permutation/index.js +7 -0
  35. package/cjs/permutation/permutation-2.js +18 -0
  36. package/cjs/permutation/permutation-3.js +18 -0
  37. package/cjs/pipe.js +25 -0
  38. package/cjs/rethrow.js +16 -0
  39. package/cjs/tap.js +15 -0
  40. package/cjs/ternary.js +16 -0
  41. package/compose.d.ts +5 -3
  42. package/curry.d.ts +6 -4
  43. package/either/either-sync.d.ts +4 -2
  44. package/either/either.d.ts +4 -2
  45. package/either/index.d.ts +3 -3
  46. package/either/left.d.ts +4 -2
  47. package/either/operators/bifold/bifold.d.ts +4 -2
  48. package/either/operators/bifold/bifoldl.d.ts +4 -2
  49. package/either/operators/bifold/bifoldr.d.ts +4 -2
  50. package/either/operators/bifold/index.d.ts +3 -3
  51. package/either/operators/bifold-map.d.ts +6 -4
  52. package/either/operators/bimap/bimap.d.ts +6 -4
  53. package/either/operators/bimap/first.d.ts +6 -4
  54. package/either/operators/bimap/index.d.ts +3 -3
  55. package/either/operators/bimap/second.d.ts +6 -4
  56. package/either/operators/guards.d.ts +3 -0
  57. package/either/operators/index.d.ts +3 -3
  58. package/either/right.d.ts +4 -2
  59. package/esm/compose.js +18 -0
  60. package/esm/curry.js +23 -0
  61. package/esm/either/either-sync.js +18 -0
  62. package/esm/either/either.js +15 -0
  63. package/esm/either/index.js +4 -0
  64. package/esm/either/left.js +17 -0
  65. package/esm/either/operators/bifold/bifold.js +12 -0
  66. package/esm/either/operators/bifold/bifoldl.js +14 -0
  67. package/esm/either/operators/bifold/bifoldr.js +14 -0
  68. package/esm/either/operators/bifold/index.js +3 -0
  69. package/esm/either/operators/bifold-map.js +13 -0
  70. package/esm/either/operators/bimap/bimap.js +13 -0
  71. package/esm/either/operators/bimap/first.js +15 -0
  72. package/esm/either/operators/bimap/index.js +3 -0
  73. package/esm/either/operators/bimap/second.js +15 -0
  74. package/esm/either/operators/guards.js +17 -0
  75. package/esm/either/operators/index.js +4 -0
  76. package/esm/either/right.js +17 -0
  77. package/esm/guard.js +26 -0
  78. package/esm/identity.js +9 -0
  79. package/esm/index.js +9 -0
  80. package/esm/inject.js +12 -0
  81. package/esm/maybe/index.js +3 -0
  82. package/esm/maybe/just.js +17 -0
  83. package/esm/maybe/maybe.js +14 -0
  84. package/esm/maybe/nothing.js +17 -0
  85. package/esm/maybe/operators/bind.js +14 -0
  86. package/esm/maybe/operators/fmap.js +15 -0
  87. package/esm/maybe/operators/fold-map.js +13 -0
  88. package/esm/maybe/operators/fold.js +14 -0
  89. package/esm/maybe/operators/guards.js +17 -0
  90. package/esm/maybe/operators/index.js +5 -0
  91. package/esm/permutation/index.js +2 -0
  92. package/esm/permutation/permutation-2.js +11 -0
  93. package/esm/permutation/permutation-3.js +11 -0
  94. package/esm/pipe.js +18 -0
  95. package/esm/rethrow.js +13 -0
  96. package/esm/tap.js +12 -0
  97. package/esm/ternary.js +13 -0
  98. package/guard.d.ts +5 -3
  99. package/identity.d.ts +4 -2
  100. package/index.d.ts +9 -5
  101. package/inject.d.ts +6 -4
  102. package/maybe/index.d.ts +2 -2
  103. package/maybe/just.d.ts +4 -2
  104. package/maybe/maybe.d.ts +4 -2
  105. package/maybe/nothing.d.ts +4 -2
  106. package/maybe/operators/bind.d.ts +6 -4
  107. package/maybe/operators/fmap.d.ts +6 -4
  108. package/maybe/operators/fold-map.d.ts +10 -8
  109. package/maybe/operators/fold.d.ts +4 -2
  110. package/maybe/operators/guards.d.ts +3 -0
  111. package/maybe/operators/index.d.ts +4 -4
  112. package/package.json +11 -4
  113. package/permutation/index.d.ts +2 -0
  114. package/permutation/permutation-2.d.ts +7 -0
  115. package/permutation/permutation-3.d.ts +7 -0
  116. package/pipe.d.ts +5 -3
  117. package/rethrow.d.ts +9 -0
  118. package/tap.d.ts +6 -3
  119. package/ternary.d.ts +10 -0
  120. package/tsconfig.json +1 -1
  121. package/{.internal → types}/effect.d.ts +7 -0
  122. package/types/gradual.d.ts +17 -0
  123. package/{.internal → types}/last.d.ts +7 -0
  124. package/types/map.d.ts +8 -0
  125. package/{.internal → types}/slice.d.ts +7 -0
  126. package/{.internal → types}/tuple.d.ts +6 -0
  127. package/.internal/gradual.d.ts +0 -5
  128. package/.internal/map.d.ts +0 -1
  129. package/.internal/permutation-of-2.d.ts +0 -1
  130. package/.internal/permutation-of-2.js +0 -1
  131. package/.internal/permutation-of-3.d.ts +0 -1
  132. package/.internal/permutation-of-3.js +0 -1
  133. package/compose.js +0 -1
  134. package/curry.js +0 -1
  135. package/either/either-sync.js +0 -1
  136. package/either/either.js +0 -1
  137. package/either/index.js +0 -1
  138. package/either/left.js +0 -1
  139. package/either/operators/bifold/bifold.js +0 -1
  140. package/either/operators/bifold/bifoldl.js +0 -1
  141. package/either/operators/bifold/bifoldr.js +0 -1
  142. package/either/operators/bifold/index.js +0 -1
  143. package/either/operators/bifold-map.js +0 -1
  144. package/either/operators/bimap/bimap.js +0 -1
  145. package/either/operators/bimap/first.js +0 -1
  146. package/either/operators/bimap/index.js +0 -1
  147. package/either/operators/bimap/second.js +0 -1
  148. package/either/operators/guards.js +0 -1
  149. package/either/operators/index.js +0 -1
  150. package/either/right.js +0 -1
  151. package/guard.js +0 -1
  152. package/identity.js +0 -1
  153. package/index.js +0 -1
  154. package/inject.js +0 -1
  155. package/maybe/index.js +0 -1
  156. package/maybe/just.js +0 -1
  157. package/maybe/maybe.js +0 -1
  158. package/maybe/nothing.js +0 -1
  159. package/maybe/operators/bind.js +0 -1
  160. package/maybe/operators/fmap.js +0 -1
  161. package/maybe/operators/fold-map.js +0 -1
  162. package/maybe/operators/fold.js +0 -1
  163. package/maybe/operators/guards.js +0 -1
  164. package/maybe/operators/index.js +0 -1
  165. package/pipe.js +0 -1
  166. package/tap.js +0 -1
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module Either Operators
3
+ */
4
+ import compose from '../../compose';
5
+ import ternary from '../../ternary';
6
+ import permutation3 from '../../permutation/permutation-3';
7
+ import { isLeft } from './guards';
8
+ import { bifoldl, bifoldr } from './bifold';
9
+ export default function bifoldMap(...args) {
10
+ return permutation3((monad, mapLeft, mapRight) => {
11
+ return ternary(isLeft, compose(mapLeft, bifoldl), compose(mapRight, bifoldr))(monad);
12
+ })(...args);
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module Either Operators
3
+ */
4
+ import { isLeft } from '../guards';
5
+ import ternary from '../../../ternary';
6
+ import permutation3 from '../../../permutation/permutation-3';
7
+ import first from './first';
8
+ import second from './second';
9
+ export default function bimap(...args) {
10
+ return permutation3((monad, mapLeft, mapRight) => {
11
+ return ternary(isLeft, first(mapLeft), second(mapRight))(monad);
12
+ })(...args);
13
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module Either Operators
3
+ */
4
+ import { isLeft } from '../guards';
5
+ import { bifoldl } from '../bifold';
6
+ import compose from '../../../compose';
7
+ import left from '../../left';
8
+ import identity from '../../../identity';
9
+ import ternary from '../../../ternary';
10
+ import permutation2 from '../../../permutation/permutation-2';
11
+ export default function first(...args) {
12
+ return permutation2((monad, mapLeft) => {
13
+ return ternary(isLeft, compose(left, mapLeft, bifoldl), identity)(monad);
14
+ })(...args);
15
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './bimap';
2
+ export { default as first } from './first';
3
+ export { default as second } from './second';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module Either Operators
3
+ */
4
+ import { bifoldr } from '../bifold';
5
+ import { isRight } from '../guards';
6
+ import compose from '../../../compose';
7
+ import identity from '../../../identity';
8
+ import right from '../../right';
9
+ import ternary from '../../../ternary';
10
+ import permutation2 from '../../../permutation/permutation-2';
11
+ export default function second(...args) {
12
+ return permutation2((monad, mapRight) => {
13
+ return ternary(isRight, compose(right, mapRight, bifoldr), identity)(monad);
14
+ })(...args);
15
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module Either Operators
3
+ */
4
+ import { lid } from '../left';
5
+ import { rid } from '../right';
6
+ /**
7
+ * Type guard function to tell if the provided `monad` is `Left`.
8
+ */
9
+ export function isLeft(monad) {
10
+ return Object.prototype.hasOwnProperty.call(monad, lid);
11
+ }
12
+ /**
13
+ * Type guard function to tell if the provided `monad` is `Right`.
14
+ */
15
+ export function isRight(monad) {
16
+ return Object.prototype.hasOwnProperty.call(monad, rid);
17
+ }
@@ -0,0 +1,4 @@
1
+ export { bifoldl, bifoldr, default as bifold, } from './bifold';
2
+ export * from './guards';
3
+ export { default as bifoldMap } from './bifold-map';
4
+ export { default as bimap, first, second } from './bimap';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module Either
3
+ */
4
+ /**
5
+ * Internal unique identifier for `Right`.
6
+ */
7
+ export const rid = Symbol.for('@@functional/right');
8
+ /**
9
+ * Constructor function for `Right`.
10
+ * Creates the special object with one property, represented as unique symbol
11
+ * key, holding the provided value.
12
+ */
13
+ export default function right(value) {
14
+ return {
15
+ [rid]: value
16
+ };
17
+ }
package/esm/guard.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @module Guard
3
+ */
4
+ /**
5
+ * A function which accepts the pairs of guards:
6
+ * the first one is the `validator`, expected to return a boolean value.
7
+ *
8
+ * If the value is `true`, it's `executor` should run with the provided `args`
9
+ * and return from the `guards` function.
10
+ * If the value is `false`, the process continues to the next `validator`.
11
+ *
12
+ * When no `validator` succeeds, the default executor is run.
13
+ */
14
+ export default function guard(...qualifiers) {
15
+ return (...args) => {
16
+ const length = qualifiers.length - 1;
17
+ const defaultExpression = qualifiers[length];
18
+ for (let index = 0; index < length; index += 1) {
19
+ const [validator, expression] = qualifiers[index];
20
+ if (validator(...args)) {
21
+ return expression(...args);
22
+ }
23
+ }
24
+ return defaultExpression(...args);
25
+ };
26
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module Identity
3
+ */
4
+ /**
5
+ * A function which returns the provided value.
6
+ */
7
+ export default function identity(x) {
8
+ return x;
9
+ }
package/esm/index.js ADDED
@@ -0,0 +1,9 @@
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/esm/inject.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module Side Effects
3
+ */
4
+ import permutation2 from './permutation/permutation-2';
5
+ export default function inject(...args) {
6
+ return permutation2((fn, effect) => {
7
+ return ((...args) => {
8
+ effect(...args);
9
+ return fn(...args);
10
+ });
11
+ })(...args);
12
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './maybe';
2
+ export { default as just } from './just';
3
+ export { default as nothing } from './nothing';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module Maybe
3
+ */
4
+ /**
5
+ * Internal unique identifier for `Just`.
6
+ */
7
+ export const jid = Symbol.for('@@functional/just');
8
+ /**
9
+ * Constructor function for `Just`.
10
+ * Creates the special object with one property, represented as unique symbol
11
+ * key, holding the provided value.
12
+ */
13
+ export default function just(value) {
14
+ return {
15
+ [jid]: value
16
+ };
17
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @module Maybe
3
+ */
4
+ import just from './just';
5
+ import nothing from './nothing';
6
+ /**
7
+ * Constructor function for `Maybe`.
8
+ * Creates either `just` of a provided value, or `nothing`.
9
+ */
10
+ export default function maybe(value) {
11
+ return value === null || value === undefined
12
+ ? nothing()
13
+ : just(value);
14
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module Maybe
3
+ */
4
+ /**
5
+ * Internal unique identifier for `Nothing`.
6
+ */
7
+ export const nid = Symbol.for('@@functional/nothing');
8
+ /**
9
+ * Constructor function for `Nothing`.
10
+ * Creates the special object with one property, represented as unique symbol
11
+ * key, holding the `null` value.
12
+ */
13
+ export default function nothing() {
14
+ return {
15
+ [nid]: null
16
+ };
17
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
4
+ import compose from '../../compose';
5
+ import ternary from '../../ternary';
6
+ import identity from '../../identity';
7
+ import permutation2 from '../../permutation/permutation-2';
8
+ import fold from './fold';
9
+ import { isJust } from './guards';
10
+ export default function bind(...args) {
11
+ return permutation2((monad, transition) => {
12
+ return ternary(isJust, compose(transition, fold), identity)(monad);
13
+ })(...args);
14
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
4
+ import compose from '../../compose';
5
+ import identity from '../../identity';
6
+ import maybe from '../maybe';
7
+ import permutation2 from '../../permutation/permutation-2';
8
+ import fold from './fold';
9
+ import { isJust } from './guards';
10
+ import ternary from '../../ternary';
11
+ export default function fmap(...args) {
12
+ return permutation2((monad, transition) => {
13
+ return ternary(isJust, compose(maybe, transition, fold), identity)(monad);
14
+ })(...args);
15
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
4
+ import compose from '../../compose';
5
+ import ternary from '../../ternary';
6
+ import permutation2 from '../../permutation/permutation-2';
7
+ import fold from './fold';
8
+ import { isJust } from './guards';
9
+ export default function foldMap(...args) {
10
+ return permutation2((monad, transition) => {
11
+ return ternary(isJust, compose(transition, fold), () => null)(monad);
12
+ })(...args);
13
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
4
+ import { jid } from '../just';
5
+ import { nid } from '../nothing';
6
+ import { isJust } from './guards';
7
+ /**
8
+ * Returns the value of the provided `monad`.
9
+ */
10
+ export default function fold(monad) {
11
+ return isJust(monad)
12
+ ? monad[jid]
13
+ : monad[nid];
14
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
4
+ import { jid } from '../just';
5
+ import { nid } from '../nothing';
6
+ /**
7
+ * Type guard function to tell if the provided `monad` is `Just`.
8
+ */
9
+ export function isJust(monad) {
10
+ return Object.prototype.hasOwnProperty.call(monad, jid);
11
+ }
12
+ /**
13
+ * Type guard function to tell if the provided `monad` is `Nothing`.
14
+ */
15
+ export function isNothing(monad) {
16
+ return Object.prototype.hasOwnProperty.call(monad, nid);
17
+ }
@@ -0,0 +1,5 @@
1
+ export { default as fmap } from './fmap';
2
+ export { default as bind } from './bind';
3
+ export { default as fold } from './fold';
4
+ export { isJust, isNothing } from './guards';
5
+ export { default as foldMap } from './fold-map';
@@ -0,0 +1,2 @@
1
+ export { default as permutation2 } from './permutation-2';
2
+ export { default as permutation3 } from './permutation-3';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module Permutation
3
+ */
4
+ export default function permutation2(fn, shouldCurry) {
5
+ return (...args) => {
6
+ const [a1, b] = args;
7
+ return (shouldCurry === null || shouldCurry === void 0 ? void 0 : shouldCurry(a1, b)) || args.length < fn.length
8
+ ? (a2) => fn(a2, a1)
9
+ : fn(a1, b);
10
+ };
11
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module Permutation
3
+ */
4
+ export default function permutation3(fn, shouldCurry) {
5
+ return (...args) => {
6
+ const [a1, b, c] = args;
7
+ return (shouldCurry === null || shouldCurry === void 0 ? void 0 : shouldCurry(a1, b, c)) || args.length < fn.length
8
+ ? (a2) => fn(a2, a1, b)
9
+ : fn(a1, b, c);
10
+ };
11
+ }
package/esm/pipe.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module Composition
3
+ */
4
+ /**
5
+ * Applies all of the provided `functions` one-by-one in left-to-right order
6
+ * starting from the `argument`.
7
+ */
8
+ export default function pipe(...functions) {
9
+ return (arg) => {
10
+ const length = functions.length;
11
+ let pipeline = arg;
12
+ for (let index = 0; index < length; index += 1) {
13
+ const current = functions[index];
14
+ pipeline = current(pipeline);
15
+ }
16
+ return pipeline;
17
+ };
18
+ }
package/esm/rethrow.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module Side Effects
3
+ */
4
+ import inject from './inject';
5
+ /**
6
+ * Rethrows a received error
7
+ * performing an optional side effect.
8
+ */
9
+ export default function rethrow(effect) {
10
+ return inject((error) => {
11
+ throw error;
12
+ }, effect);
13
+ }
package/esm/tap.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module Side Effects
3
+ */
4
+ import inject from './inject';
5
+ import identity from './identity';
6
+ /**
7
+ * Performs a side effect
8
+ * passing the received argument through itself.
9
+ */
10
+ export default function tap(effect) {
11
+ return inject(identity, effect);
12
+ }
package/esm/ternary.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module Ternary
3
+ */
4
+ /**
5
+ * Functional alternative to the ternary operator.
6
+ * Enforces the same return type for both branches,
7
+ * the result is evaluated lazily.
8
+ */
9
+ export default function ternary(predicate, left, right) {
10
+ return (value) => {
11
+ return predicate(value) ? left(value) : right(value);
12
+ };
13
+ }
package/guard.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- export declare type Guard<Function extends (...args: any[]) => any> = [
1
+ /**
2
+ * @module Guard
3
+ */
4
+ export declare type GuardQualifier<Function extends (...args: any[]) => any> = [
2
5
  validator: <Result extends boolean>(...args: Parameters<Function>) => Result,
3
6
  executor: Function
4
7
  ];
@@ -12,5 +15,4 @@ export declare type Guard<Function extends (...args: any[]) => any> = [
12
15
  *
13
16
  * When no `validator` succeeds, the default executor is run.
14
17
  */
15
- export declare function guard<Function extends (...args: any[]) => any>(...guards: [...Guard<Function>[], Function]): (...args: Parameters<Function>) => ReturnType<Function>;
16
- export default guard;
18
+ export default function guard<Function extends (...args: any[]) => any>(...qualifiers: [...GuardQualifier<Function>[], Function]): (...args: Parameters<Function>) => ReturnType<Function>;
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/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/inject.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import type { Effect } from './.internal/effect';
1
+ /**
2
+ * @module Side Effects
3
+ */
4
+ import type { Effect } from './types/effect';
2
5
  /**
3
6
  * Injects a function with a side effect.
4
7
  * Returns the copy of the original function.
5
8
  */
6
- export declare function inject<Function extends (...args: any[]) => any>(effect: Effect<Function>): (fn: Function) => Function;
9
+ export default function inject<Function extends (...args: any[]) => any>(effect: Effect<Function>): (fn: Function) => Function;
7
10
  /**
8
11
  * Injects a function with a side effect.
9
12
  * Returns the copy of the original function.
10
13
  */
11
- export declare function inject<Function extends (...args: any[]) => any>(fn: Function, effect: Effect<Function>): Function;
12
- export default inject;
14
+ export default function inject<Function extends (...args: any[]) => any>(fn: Function, effect: Effect<Function>): Function;
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/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/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>;
@@ -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;
@@ -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,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,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,3 +1,6 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
1
4
  import { Just } from '../just';
2
5
  import type { Maybe } from '../maybe';
3
6
  import { Nothing } from '../nothing';
@@ -8,5 +11,4 @@ export declare type Fold<Monad extends Maybe<any>> = Monad extends Just<infer Va
8
11
  /**
9
12
  * Returns the value of the provided `monad`.
10
13
  */
11
- export declare function fold<Monad extends Maybe<any>>(monad: Monad): Fold<Monad>;
12
- export default fold;
14
+ export default function fold<Monad extends Maybe<any>>(monad: Monad): Fold<Monad>;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @module Maybe Operators
3
+ */
1
4
  import { Just } from '../just';
2
5
  import type { Maybe } from '../maybe';
3
6
  import { Nothing } from '../nothing';