fnts 1.0.2 → 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.
- package/README.md +4 -50
- package/cjs/compose.js +25 -0
- package/cjs/curry.js +37 -0
- package/cjs/either/either-sync.js +21 -0
- package/cjs/either/either.js +18 -0
- package/cjs/either/index.js +11 -0
- package/cjs/either/left.js +22 -0
- package/cjs/either/operators/bifold/bifold.js +15 -0
- package/cjs/either/operators/bifold/bifoldl.js +17 -0
- package/cjs/either/operators/bifold/bifoldr.js +17 -0
- package/cjs/either/operators/bifold/index.js +9 -0
- package/cjs/either/operators/bifold-map.js +20 -0
- package/cjs/either/operators/bimap/bimap.js +20 -0
- package/cjs/either/operators/bimap/first.js +22 -0
- package/cjs/either/operators/bimap/index.js +9 -0
- package/cjs/either/operators/bimap/second.js +22 -0
- package/cjs/either/operators/guards.js +22 -0
- package/cjs/either/operators/index.js +24 -0
- package/cjs/either/right.js +22 -0
- package/cjs/guard.js +37 -0
- package/cjs/identity.js +12 -0
- package/cjs/index.js +21 -0
- package/cjs/inject.js +23 -0
- package/cjs/maybe/index.js +9 -0
- package/cjs/maybe/just.js +22 -0
- package/cjs/maybe/maybe.js +17 -0
- package/cjs/maybe/nothing.js +22 -0
- package/cjs/maybe/operators/bind.js +21 -0
- package/cjs/maybe/operators/fmap.js +22 -0
- package/cjs/maybe/operators/fold-map.js +20 -0
- package/cjs/maybe/operators/fold.js +17 -0
- package/cjs/maybe/operators/guards.js +22 -0
- package/cjs/maybe/operators/index.js +14 -0
- package/cjs/permutation/index.js +7 -0
- package/cjs/permutation/permutation-2.js +18 -0
- package/cjs/permutation/permutation-3.js +18 -0
- package/cjs/pipe.js +25 -0
- package/cjs/rethrow.js +16 -0
- package/cjs/tap.js +15 -0
- package/cjs/ternary.js +16 -0
- package/compose.d.ts +5 -3
- package/curry.d.ts +6 -4
- package/either/either-sync.d.ts +10 -0
- package/either/either.d.ts +8 -40
- package/either/index.d.ts +4 -1
- package/either/left.d.ts +21 -0
- package/either/operators/bifold/bifold.d.ts +15 -0
- package/either/operators/bifold/bifoldl.d.ts +15 -0
- package/either/operators/bifold/bifoldr.d.ts +15 -0
- package/either/operators/bifold/index.d.ts +3 -0
- package/either/operators/bifold-map.d.ts +10 -7
- package/either/operators/bimap/bimap.d.ts +13 -0
- package/either/operators/bimap/first.d.ts +15 -0
- package/either/operators/bimap/index.d.ts +3 -0
- package/either/operators/bimap/second.d.ts +15 -0
- package/either/operators/guards.d.ts +8 -3
- package/either/operators/index.d.ts +3 -3
- package/either/right.d.ts +21 -0
- package/esm/compose.js +18 -0
- package/esm/curry.js +23 -0
- package/esm/either/either-sync.js +18 -0
- package/esm/either/either.js +15 -0
- package/esm/either/index.js +4 -0
- package/esm/either/left.js +17 -0
- package/esm/either/operators/bifold/bifold.js +12 -0
- package/esm/either/operators/bifold/bifoldl.js +14 -0
- package/esm/either/operators/bifold/bifoldr.js +14 -0
- package/esm/either/operators/bifold/index.js +3 -0
- package/esm/either/operators/bifold-map.js +13 -0
- package/esm/either/operators/bimap/bimap.js +13 -0
- package/esm/either/operators/bimap/first.js +15 -0
- package/esm/either/operators/bimap/index.js +3 -0
- package/esm/either/operators/bimap/second.js +15 -0
- package/esm/either/operators/guards.js +17 -0
- package/esm/either/operators/index.js +4 -0
- package/esm/either/right.js +17 -0
- package/esm/guard.js +26 -0
- package/esm/identity.js +9 -0
- package/esm/index.js +9 -0
- package/esm/inject.js +12 -0
- package/esm/maybe/index.js +3 -0
- package/esm/maybe/just.js +17 -0
- package/esm/maybe/maybe.js +14 -0
- package/esm/maybe/nothing.js +17 -0
- package/esm/maybe/operators/bind.js +14 -0
- package/esm/maybe/operators/fmap.js +15 -0
- package/esm/maybe/operators/fold-map.js +13 -0
- package/esm/maybe/operators/fold.js +14 -0
- package/esm/maybe/operators/guards.js +17 -0
- package/esm/maybe/operators/index.js +5 -0
- package/esm/permutation/index.js +2 -0
- package/esm/permutation/permutation-2.js +11 -0
- package/esm/permutation/permutation-3.js +11 -0
- package/esm/pipe.js +18 -0
- package/esm/rethrow.js +13 -0
- package/esm/tap.js +12 -0
- package/esm/ternary.js +13 -0
- package/guard.d.ts +5 -3
- package/identity.d.ts +4 -2
- package/index.d.ts +9 -7
- package/inject.d.ts +14 -0
- package/maybe/index.d.ts +3 -1
- package/maybe/just.d.ts +21 -0
- package/maybe/maybe.d.ts +6 -38
- package/maybe/nothing.d.ts +21 -0
- package/maybe/operators/bind.d.ts +10 -7
- package/maybe/operators/fmap.d.ts +10 -7
- package/maybe/operators/fold-map.d.ts +37 -12
- package/maybe/operators/fold.d.ts +7 -3
- package/maybe/operators/guards.d.ts +8 -3
- package/maybe/operators/index.d.ts +5 -5
- package/package.json +12 -5
- package/permutation/index.d.ts +2 -0
- package/permutation/permutation-2.d.ts +7 -0
- package/permutation/permutation-3.d.ts +7 -0
- package/pipe.d.ts +5 -3
- package/rethrow.d.ts +9 -0
- package/tap.d.ts +11 -0
- package/ternary.d.ts +10 -0
- package/tsconfig.json +1 -1
- package/types/effect.d.ts +9 -0
- package/types/gradual.d.ts +17 -0
- package/{.internal → types}/last.d.ts +7 -0
- package/types/map.d.ts +8 -0
- package/{.internal → types}/slice.d.ts +7 -0
- package/{.internal → types}/tuple.d.ts +6 -0
- package/.internal/gradual.d.ts +0 -5
- package/.internal/map.d.ts +0 -1
- package/.internal/permutation-of-2.d.ts +0 -1
- package/.internal/permutation-of-2.js +0 -1
- package/.internal/permutation-of-3.d.ts +0 -1
- package/.internal/permutation-of-3.js +0 -1
- package/compose.js +0 -1
- package/curry.js +0 -1
- package/either/either.js +0 -1
- package/either/index.js +0 -1
- package/either/operators/bifold-map.js +0 -1
- package/either/operators/bifold.d.ts +0 -31
- package/either/operators/bifold.js +0 -1
- package/either/operators/bimap.d.ts +0 -29
- package/either/operators/bimap.js +0 -1
- package/either/operators/guards.js +0 -1
- package/either/operators/index.js +0 -1
- package/guard.js +0 -1
- package/identity.js +0 -1
- package/index.js +0 -1
- package/maybe/index.js +0 -1
- package/maybe/maybe.js +0 -1
- package/maybe/operators/bind.js +0 -1
- package/maybe/operators/fmap.js +0 -1
- package/maybe/operators/fold-map.js +0 -1
- package/maybe/operators/fold.js +0 -1
- package/maybe/operators/guards.js +0 -1
- package/maybe/operators/index.js +0 -1
- package/pipe.js +0 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
1
4
|
import { Maybe } from '../maybe';
|
|
2
|
-
import type { Map } from '
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type { Map } from '../../types/map';
|
|
6
|
+
/**
|
|
7
|
+
* Maps the value of the provided `monad` through the `transition` function
|
|
8
|
+
* and returns a new `Maybe` of the mapped value.
|
|
9
|
+
*/
|
|
10
|
+
export default function fmap<Value, NextValue = Value>(transition: Map<Value, NextValue>): (monad: Maybe<Value>) => Maybe<NextValue>;
|
|
7
11
|
/**
|
|
8
12
|
* Maps the value of the provided `monad` through the `transition` function
|
|
9
13
|
* and returns a new `Maybe` of the mapped value.
|
|
10
14
|
*/
|
|
11
|
-
export
|
|
12
|
-
export default fmap;
|
|
15
|
+
export default function fmap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): Maybe<NextValue>;
|
|
@@ -1,16 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
4
|
+
import type { Just } from '../just';
|
|
5
|
+
import type { Maybe } from '../maybe';
|
|
6
|
+
import type { Nothing } from '../nothing';
|
|
7
|
+
import type { Map } from '../../types/map';
|
|
8
|
+
/**
|
|
9
|
+
* A type to unwrap the provided `Monad` into the new value type.
|
|
10
|
+
*/
|
|
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
|
+
/**
|
|
23
|
+
* Maps the value of the provided `monad` through the `transition` function
|
|
24
|
+
* and returns the mapped value or `null`.
|
|
25
|
+
*/
|
|
26
|
+
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;
|
|
11
37
|
/**
|
|
12
38
|
* Maps the value of the provided `monad` through the `transition` function
|
|
13
39
|
* and returns the mapped value or `null`.
|
|
14
40
|
*/
|
|
15
|
-
export
|
|
16
|
-
export default foldMap;
|
|
41
|
+
export default function foldMap<Value, NextValue = Value>(monad: Maybe<Value>, transition: Map<Value, NextValue>): NextValue | null;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
4
|
+
import { Just } from '../just';
|
|
5
|
+
import type { Maybe } from '../maybe';
|
|
6
|
+
import { Nothing } from '../nothing';
|
|
2
7
|
/**
|
|
3
8
|
* A type to unwrap the value type of the provided `Monad`.
|
|
4
9
|
*/
|
|
@@ -6,5 +11,4 @@ export declare type Fold<Monad extends Maybe<any>> = Monad extends Just<infer Va
|
|
|
6
11
|
/**
|
|
7
12
|
* Returns the value of the provided `monad`.
|
|
8
13
|
*/
|
|
9
|
-
export
|
|
10
|
-
export default fold;
|
|
14
|
+
export default function fold<Monad extends Maybe<any>>(monad: Monad): Fold<Monad>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Maybe Operators
|
|
3
|
+
*/
|
|
4
|
+
import { Just } from '../just';
|
|
5
|
+
import type { Maybe } from '../maybe';
|
|
6
|
+
import { Nothing } from '../nothing';
|
|
2
7
|
/**
|
|
3
8
|
* Type guard function to tell if the provided `monad` is `Just`.
|
|
4
9
|
*/
|
|
5
|
-
export declare
|
|
10
|
+
export declare function isJust<Value>(monad: Maybe<Value>): monad is Just<Value>;
|
|
6
11
|
/**
|
|
7
12
|
* Type guard function to tell if the provided `monad` is `Nothing`.
|
|
8
13
|
*/
|
|
9
|
-
export declare
|
|
14
|
+
export declare function isNothing<Value>(monad: Maybe<Value>): monad is Nothing;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
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, FoldMap } from './fold-map';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fnts",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dmytro Vasylkivskyi",
|
|
6
6
|
"description": "TypeScript / JavaScript FP utilities",
|
|
@@ -12,9 +12,16 @@
|
|
|
12
12
|
"typescript",
|
|
13
13
|
"javascript"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.
|
|
16
|
-
"repository": "github
|
|
15
|
+
"homepage": "https://drizzer14.github.io/fnts",
|
|
16
|
+
"repository": "https://github.com/drizzer14/fnts",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"typescript": "4.2.2"
|
|
19
|
-
}
|
|
18
|
+
"typescript": ">=4.2.2"
|
|
19
|
+
},
|
|
20
|
+
"peerDependenciesMeta": {
|
|
21
|
+
"typescript": {
|
|
22
|
+
"optional": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"main": "cjs/index.js",
|
|
26
|
+
"module": "esm/index.js"
|
|
20
27
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Permutation
|
|
3
|
+
*/
|
|
4
|
+
export declare type BinaryFunction = (a: any, b: any) => any;
|
|
5
|
+
export declare type FirstParameter<Function extends (...args: any[]) => any> = Parameters<Function>[0];
|
|
6
|
+
export declare type SecondParameter<Function extends (...args: any[]) => any> = Parameters<Function>[1];
|
|
7
|
+
export default function permutation2<Function extends BinaryFunction>(fn: Function, shouldCurry?: (a: FirstParameter<Function> | SecondParameter<Function>, b: SecondParameter<Function> | undefined) => boolean): (...args: any[]) => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Permutation
|
|
3
|
+
*/
|
|
4
|
+
import type { FirstParameter, SecondParameter } from './permutation-2';
|
|
5
|
+
export declare type TernaryFunction = (a: any, b: any, c: any) => any;
|
|
6
|
+
export declare type ThirdParameter<Function extends (...args: any[]) => any> = Parameters<Function>[2];
|
|
7
|
+
export default function permutation3<Function extends TernaryFunction>(fn: Function, shouldCurry?: (a: FirstParameter<Function> | SecondParameter<Function>, b: SecondParameter<Function> | ThirdParameter<Function>, c: ThirdParameter<Function> | undefined) => boolean): (...args: any[]) => any;
|
package/pipe.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Composition
|
|
3
|
+
*/
|
|
4
|
+
import type { Last } from './types/last';
|
|
2
5
|
/**
|
|
3
6
|
* Creates a `Pipeline` type which parses all of the provided functions' types.
|
|
4
7
|
* Any function with either an incorrect argument or a return type will not fit
|
|
@@ -17,5 +20,4 @@ export declare type Pipeline<Functions extends Array<(...args: any[]) => any>, L
|
|
|
17
20
|
* Applies all of the provided `functions` one-by-one in left-to-right order
|
|
18
21
|
* starting from the `argument`.
|
|
19
22
|
*/
|
|
20
|
-
export
|
|
21
|
-
export default pipe;
|
|
23
|
+
export default function pipe<Functions extends Array<(arg: any) => any>>(...functions: Pipeline<Functions>): (arg: Parameters<Functions[0]>[0]) => ReturnType<Last<Functions>>;
|
package/rethrow.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Side Effects
|
|
3
|
+
*/
|
|
4
|
+
import type { Effect } from './types/effect';
|
|
5
|
+
/**
|
|
6
|
+
* Rethrows a received error
|
|
7
|
+
* performing an optional side effect.
|
|
8
|
+
*/
|
|
9
|
+
export default function rethrow<Error>(effect: Effect<(error: Error) => never>): (error: Error) => never;
|
package/tap.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Side Effects
|
|
3
|
+
*/
|
|
4
|
+
import type { Map } from './types/map';
|
|
5
|
+
import type { Identity } from './identity';
|
|
6
|
+
import type { Effect } from './types/effect';
|
|
7
|
+
/**
|
|
8
|
+
* Performs a side effect
|
|
9
|
+
* passing the received argument through itself.
|
|
10
|
+
*/
|
|
11
|
+
export default function tap<Value>(effect: Effect<Map<Value, any>>): Identity<Value>;
|
package/ternary.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Ternary
|
|
3
|
+
*/
|
|
4
|
+
import type { Map } from './types/map';
|
|
5
|
+
/**
|
|
6
|
+
* Functional alternative to the ternary operator.
|
|
7
|
+
* Enforces the same return type for both branches,
|
|
8
|
+
* the result is evaluated lazily.
|
|
9
|
+
*/
|
|
10
|
+
export default function ternary<Value, Return>(predicate: Map<Value, boolean>, left: Map<Value, Return>, right: Map<Value, Return>): Map<Value, Return>;
|
package/tsconfig.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gradual defines a tuple type which accepts any amount
|
|
7
|
+
* of entries from the original one.
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* Gradual<[1, 2, 3]> === [1] | [1, 2] | [1, 2, 3]
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type Gradual<T extends any[] | readonly any[]> = T extends [...infer R, any]
|
|
14
|
+
? R['length'] extends 0
|
|
15
|
+
? T
|
|
16
|
+
: T | Gradual<R>
|
|
17
|
+
: T
|
package/types/map.d.ts
ADDED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module Types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a tuple of specified length.
|
|
7
|
+
*
|
|
2
8
|
* {@link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f Gracefully borrowed from here}
|
|
3
9
|
*/
|
|
4
10
|
export type Tuple<L extends number, T extends any[] | readonly any[] = []> =
|
package/.internal/gradual.d.ts
DELETED
package/.internal/map.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Map<From, To> = (value: From) => To
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.permutationOf2=void 0;var permutationOf2=(a,c)=>function(){for(var d=arguments.length,e=Array(d),f=0;f<d;f++)e[f]=arguments[f];var[g,h]=e;return null!==c&&void 0!==c&&c(g,h)||e.length<a.length?b=>a(b,g):a(g,h)};exports.permutationOf2=permutationOf2;var _default=permutationOf2;exports.default=_default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.permutationOf3=void 0;var permutationOf3=a=>function(){for(var d=arguments.length,e=Array(d),f=0;f<d;f++)e[f]=arguments[f];var[g,h,b]=e;return e.length<a.length?b=>a(b,g,h):a(g,h,b)};exports.permutationOf3=permutationOf3;var _default=permutationOf3;exports.default=_default;
|
package/compose.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.compose=void 0;var compose=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return a=>{for(var c,d=b.length,e=a,f=d-1;0<=f;f-=1)c=b[f],e=c(e);return e}};exports.compose=compose;var _default=compose;exports.default=_default;
|
package/curry.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.curry=void 0;var curry=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:a.length;return function(){for(var c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];var f=d.length;return f===b?a.apply(void 0,d):f>b?a.apply(void 0,d.slice(0,b)):curry(a.bind(void 0,...d))}};exports.curry=curry;var _default=curry;exports.default=_default;
|
package/either/either.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.either=exports.right=exports.rid=exports.left=exports.lid=void 0;function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var lid=Symbol.for("@@functional/left");exports.lid=lid;var left=a=>({[lid]:a});exports.left=left;var rid=Symbol.for("@@functional/right");exports.rid=rid;var right=a=>({[rid]:a});exports.right=right;var either=function(){var a=_asyncToGenerator(function*(a){return a().then(right).catch(left)});return function(){return a.apply(this,arguments)}}();exports.either=either;var _default=either;exports.default=_default;
|
package/either/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _either=_interopRequireWildcard(require("./either"));Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function get(){return _either.default}}),Object.defineProperty(exports,"left",{enumerable:!0,get:function get(){return _either.left}}),Object.defineProperty(exports,"Left",{enumerable:!0,get:function get(){return _either.Left}}),Object.defineProperty(exports,"right",{enumerable:!0,get:function get(){return _either.right}}),Object.defineProperty(exports,"Right",{enumerable:!0,get:function get(){return _either.Right}}),Object.defineProperty(exports,"either",{enumerable:!0,get:function get(){return _either.either}}),Object.defineProperty(exports,"Either",{enumerable:!0,get:function get(){return _either.Either}});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 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.bifoldMap=void 0;var _compose=_interopRequireDefault(require("../../compose")),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-3")),_guards=require("./guards"),_bifold=require("./bifold");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var bifoldMap=(0,_permutationOf.default)((a,b,c)=>(0,_guards.isLeft)(a)?(0,_compose.default)(b,_bifold.bifoldl)(a):(0,_compose.default)(c,_bifold.bifoldr)(a));exports.bifoldMap=bifoldMap;var _default=bifoldMap;exports.default=_default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Either, Left, Right } from '../either';
|
|
2
|
-
/**
|
|
3
|
-
* A type to unwrap the left value type of the provided `Monad`.
|
|
4
|
-
* If the `Monad` is `Right`, returns `undefined`.
|
|
5
|
-
*/
|
|
6
|
-
export declare type Bifoldl<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the left value of the provided `monad`.
|
|
9
|
-
* If the `monad` is `Right`, returns `undefined`.
|
|
10
|
-
*/
|
|
11
|
-
export declare const bifoldl: <Monad extends Either<any, any>>(monad: Monad) => Bifoldl<Monad>;
|
|
12
|
-
/**
|
|
13
|
-
* A type to unwrap the right value type of the provided `Monad`.
|
|
14
|
-
* If the `Monad` is `Left`, returns `undefined`.
|
|
15
|
-
*/
|
|
16
|
-
export declare type Bifoldr<Monad extends Either<any, any>> = Monad extends Right<infer RightValue> ? RightValue : undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Returns the right value of the provided `monad`.
|
|
19
|
-
* If the `monad` is `Left`, returns `undefined`.
|
|
20
|
-
*/
|
|
21
|
-
export declare const bifoldr: <Monad extends Either<any, any>>(monad: Monad) => Bifoldr<Monad>;
|
|
22
|
-
/**
|
|
23
|
-
* A type to unwrap either the left or the right value type
|
|
24
|
-
* of the provided `Monad`.
|
|
25
|
-
*/
|
|
26
|
-
export declare type Bifold<Monad extends Either<any, any>> = Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Right<infer RightValue> ? RightValue : never;
|
|
27
|
-
/**
|
|
28
|
-
* Unwraps either the left or the right value of the provided `monad`.
|
|
29
|
-
*/
|
|
30
|
-
export declare const bifold: <Monad extends Either<any, any>>(monad: Monad) => Bifold<Monad>;
|
|
31
|
-
export default bifold;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.bifold=exports.bifoldr=exports.bifoldl=void 0;var _either=require("../either"),_guards=require("./guards"),bifoldl=a=>(0,_guards.isLeft)(a)?a[_either.lid]:void 0;exports.bifoldl=bifoldl;var bifoldr=a=>(0,_guards.isRight)(a)?a[_either.rid]:void 0;exports.bifoldr=bifoldr;var bifold=a=>{var b;return null!==(b=bifoldl(a))&&void 0!==b?b:bifoldr(a)};exports.bifold=bifold;var _default=bifold;exports.default=_default;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Map } from '../../.internal/map';
|
|
2
|
-
import { Either } from '../either';
|
|
3
|
-
interface First {
|
|
4
|
-
<LeftValue, RightValue, NextLeftValue>(mapLeft: Map<LeftValue, NextLeftValue>): (monad: Either<LeftValue, RightValue>) => Either<NextLeftValue, RightValue>;
|
|
5
|
-
<LeftValue, RightValue, NextLeftValue>(monad: Either<LeftValue, RightValue>, mapLeft: Map<LeftValue, NextLeftValue>): Either<NextLeftValue, RightValue>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Maps the left value of the provided `monad` to a new `Either` monad
|
|
9
|
-
* with the same right value.
|
|
10
|
-
*/
|
|
11
|
-
export declare const first: First;
|
|
12
|
-
interface Second {
|
|
13
|
-
<LeftValue, RightValue, NextRightValue>(mapRight: Map<RightValue, NextRightValue>): (monad: Either<LeftValue, RightValue>) => Either<LeftValue, NextRightValue>;
|
|
14
|
-
<LeftValue, RightValue, NextRightValue>(monad: Either<LeftValue, RightValue>, mapRight: Map<RightValue, NextRightValue>): Either<LeftValue, NextRightValue>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Maps the right value of the provided `monad` to a new `Either` monad
|
|
18
|
-
* with the same left value.
|
|
19
|
-
*/
|
|
20
|
-
export declare const second: Second;
|
|
21
|
-
interface Bimap {
|
|
22
|
-
<LeftValue, RightValue, NextLeftValue, NextRightValue>(mapLeft: Map<LeftValue, NextLeftValue>, mapRight: Map<RightValue, NextRightValue>): (monad: Either<LeftValue, RightValue>) => Either<NextLeftValue, NextRightValue>;
|
|
23
|
-
<LeftValue, RightValue, NextLeftValue, NextRightValue>(monad: Either<LeftValue, RightValue>, mapLeft: Map<LeftValue, NextLeftValue>, mapRight: Map<RightValue, NextRightValue>): Either<NextLeftValue, NextRightValue>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Maps left and right values of the provided `monad` to a new `Either` monad.
|
|
27
|
-
*/
|
|
28
|
-
export declare const bimap: Bimap;
|
|
29
|
-
export default bimap;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.bimap=exports.second=exports.first=void 0;var _compose=_interopRequireDefault(require("../../compose")),_either=require("../either"),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_permutationOf2=_interopRequireDefault(require("../../.internal/permutation-of-3")),_guards=require("./guards"),_bifold=require("./bifold");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var first=(0,_permutationOf.default)((a,b)=>(0,_guards.isLeft)(a)?(0,_compose.default)(_either.left,b,_bifold.bifoldl)(a):a);exports.first=first;var second=(0,_permutationOf.default)((a,b)=>(0,_guards.isRight)(a)?(0,_compose.default)(_either.right,b,_bifold.bifoldr)(a):a);exports.second=second;var bimap=(0,_permutationOf2.default)((a,b,c)=>(0,_guards.isLeft)(a)?first(a,b):second(a,c));exports.bimap=bimap;var _default=bimap;exports.default=_default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isRight=exports.isLeft=void 0;var _either=require("../either"),isLeft=a=>Object.prototype.hasOwnProperty.call(a,_either.lid);exports.isLeft=isLeft;var isRight=a=>Object.prototype.hasOwnProperty.call(a,_either.rid);exports.isRight=isRight;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _bimap=require("./bimap");var _bifold=require("./bifold");var _guards=require("./guards");var _bifoldMap=require("./bifold-map");Object.defineProperty(exports,"__esModule",{value:!0});Object.keys(_bimap).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_bimap[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _bimap[a]}})});Object.keys(_bifold).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_bifold[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _bifold[a]}})});Object.keys(_guards).forEach(function(a){"default"===a||"__esModule"===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||a in exports&&exports[a]===_bifoldMap[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _bifoldMap[a]}})});
|
package/guard.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.guard=void 0;var guard=function(){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)}};exports.guard=guard;var _default=guard;exports.default=_default;
|
package/identity.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.identity=void 0;var identity=a=>a;exports.identity=identity;var _default=identity;exports.default=_default;
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _pipe=require("./pipe");var _curry=require("./curry");var _guard=require("./guard");var _maybe=require("./maybe");var _either=require("./either");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(_maybe).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_maybe[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _maybe[a]}})});Object.keys(_either).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_either[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _either[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]}})});
|
package/maybe/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _maybe=_interopRequireWildcard(require("./maybe"));Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function get(){return _maybe.default}}),Object.defineProperty(exports,"just",{enumerable:!0,get:function get(){return _maybe.just}}),Object.defineProperty(exports,"Just",{enumerable:!0,get:function get(){return _maybe.Just}}),Object.defineProperty(exports,"nothing",{enumerable:!0,get:function get(){return _maybe.nothing}}),Object.defineProperty(exports,"Nothing",{enumerable:!0,get:function get(){return _maybe.Nothing}}),Object.defineProperty(exports,"maybe",{enumerable:!0,get:function get(){return _maybe.maybe}}),Object.defineProperty(exports,"Maybe",{enumerable:!0,get:function get(){return _maybe.Maybe}});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}
|
package/maybe/maybe.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.maybe=exports.nothing=exports.nid=exports.just=exports.jid=void 0;var jid=Symbol.for("@@functional/just");exports.jid=jid;var just=a=>({[jid]:a});exports.just=just;var nid=Symbol.for("@@functional/nothing");exports.nid=nid;var nothing=()=>({[nid]:null});exports.nothing=nothing;var maybe=a=>null===a||void 0===a?nothing():just(a);exports.maybe=maybe;var _default=maybe;exports.default=_default;
|
package/maybe/operators/bind.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.bind=void 0;var _compose=_interopRequireDefault(require("../../compose")),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_fold=require("./fold"),_guards=require("./guards");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var bind=(0,_permutationOf.default)((a,b)=>(0,_guards.isJust)(a)?(0,_compose.default)(b,_fold.fold)(a):a);exports.bind=bind;var _default=bind;exports.default=_default;
|
package/maybe/operators/fmap.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.fmap=void 0;var _compose=_interopRequireDefault(require("../../compose")),_maybe=require("../maybe"),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_fold=require("./fold"),_guards=require("./guards");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var fmap=(0,_permutationOf.default)((a,b)=>(0,_guards.isJust)(a)?(0,_compose.default)(_maybe.maybe,b,_fold.fold)(a):a);exports.fmap=fmap;var _default=fmap;exports.default=_default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.foldMap=void 0;var _compose=_interopRequireDefault(require("../../compose")),_permutationOf=_interopRequireDefault(require("../../.internal/permutation-of-2")),_fold=require("./fold"),_guards=require("./guards");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var foldMap=(0,_permutationOf.default)((a,b)=>(0,_guards.isJust)(a)?(0,_compose.default)(b,_fold.fold)(a):null);exports.foldMap=foldMap;var _default=foldMap;exports.default=_default;
|
package/maybe/operators/fold.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.fold=void 0;var _maybe=require("../maybe"),_guards=require("./guards"),fold=a=>(0,_guards.isJust)(a)?a[_maybe.jid]:a[_maybe.nid];exports.fold=fold;var _default=fold;exports.default=_default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isNothing=exports.isJust=void 0;var _maybe=require("../maybe"),isJust=a=>Object.prototype.hasOwnProperty.call(a,_maybe.jid);exports.isJust=isJust;var isNothing=a=>Object.prototype.hasOwnProperty.call(a,_maybe.nid);exports.isNothing=isNothing;
|
package/maybe/operators/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _fmap=require("./fmap");var _bind=require("./bind");var _fold=require("./fold");var _guards=require("./guards");var _foldMap=require("./fold-map");Object.defineProperty(exports,"__esModule",{value:!0});Object.keys(_fmap).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_fmap[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _fmap[a]}})});Object.keys(_bind).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_bind[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _bind[a]}})});Object.keys(_fold).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_fold[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _fold[a]}})});Object.keys(_guards).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_guards[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _guards[a]}})});Object.keys(_foldMap).forEach(function(a){"default"===a||"__esModule"===a||a in exports&&exports[a]===_foldMap[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _foldMap[a]}})});
|
package/pipe.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.pipe=void 0;var pipe=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return a=>{for(var c,d=b.length,e=a,f=0;f<d;f+=1)c=b[f],e=c(e);return e}};exports.pipe=pipe;var _default=pipe;exports.default=_default;
|