-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
669777e
commit 19302b8
Showing
21 changed files
with
1,305 additions
and
1,146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { Monad, FoldMonad } from '../monad'; | ||
export declare const fold: <T, U>(f: (acc: U, val: T) => U, seed: U) => <TMonad extends Monad<T>>(monad: TMonad) => FoldMonad<TMonad, U>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var operators_1 = require("rxjs/operators"); | ||
var rxjs_1 = require("rxjs"); | ||
var maybe_1 = require("../maybe"); | ||
var immutable_1 = require("immutable"); | ||
exports.fold = function (f, seed) { return function (monad) { | ||
var result; | ||
if (rxjs_1.isObservable(monad)) { | ||
result = operators_1.reduce(f, seed)(monad); | ||
} | ||
else if (maybe_1.isMaybe(monad)) { | ||
result = maybe_1.foldLeft(f, seed)(monad); | ||
} | ||
else if (immutable_1.Iterable.isIterable(monad)) { | ||
result = monad.reduce(f, seed); | ||
} | ||
else if (Array.isArray(monad)) { | ||
result = monad.reduce(f, seed); | ||
} | ||
else { | ||
throw new Error('Invalid type!'); | ||
} | ||
return result; | ||
}; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './fold'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./fold")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.