Created
March 1, 2019 20:09
-
-
Save beattyml1/550f338b4da6e892ab27a0cfc16a2f25 to your computer and use it in GitHub Desktop.
ts operators
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
import {and as bool_and} from 'boolean' | |
import {and as num_and} from 'number' | |
@operator | |
export const and = overload(bool_and, num_and) |
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
@operator | |
@overload((a, b) => typeof a === 'boolean' && typeof b === 'boolean')) | |
export function and (a: boolean, b: boolean) { | |
return a && b; | |
} | |
@operator('|>', '.') | |
export function pipe<X>(val: X, func: (x: X) => Y): Y { | |
return func(value) | |
} |
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
import { and, pipe } from './operators' | |
let f = (f1, f2) => (a, b) => (a |> f1 |> f2) and (b |> f1 |> f2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment