import { Function1, FunctionV, Predicate } from './helper-types'; /** * Takes a predicate, a function, and a value. If pred(a) is true then will run function over value otherwise returns value. * :: pred -> fn -> x -> x | fn(x) */ export declare function when(pred: Function1, whenTrueFn: Function1, input: A): A | B; export declare function when(pred: Function1, whenTrueFn: Function1): (input: A) => A | B; export declare function when(pred: Function1): (whenTrueFn: Function1) => (input: A2) => A2 | B; /** * Takes a callback and a repeat number n, iterates over that function n times. * :: ( fn -> a ) -> n -> a[] */ export declare function times(callback: Function1, repeat: number): A[]; export declare function times(callback: Function1): (repeat: number) => A[]; /** * Alias to for `times` * :: ( fn -> a ) -> n -> a[] */ export declare const loop: typeof times; /** * Takes failure callback f and test function t, runs t or f if t failes. * :: ( f -> e -> a ) -> ( f -> a) -> a */ export declare function tryCatch(failCallback: Function1, testCallback: FunctionV<(null | undefined), A>): A; export declare function tryCatch(failCallback: Function1): (testCallback: FunctionV<(null | undefined), A>) => A; /** * Like tryCatch only test function receives arguments in a seperate callback * :: ( f -> e -> a ) -> ( f -> a) -> a */ export declare function tryCatchWithParams(failCallback: Function1, testCallback: FunctionV): (...args: B[]) => A; export declare function tryCatchWithParams(failCallback: Function1): (testCallback: FunctionV) => (...args: B[]) => A; /** * Takes a value v, a glob of predicates, and a test a parameter "a", returns true if any predicate given "a" matches "v" * :: v -> ...((a) -> bool) -> a -> bool */ export declare const logical: (value: boolean) => (...fns: Predicate[]) => (x: A) => boolean; /** * Takes a glob of predicates "p" taking a value "a", then a value "a" and returns true if any of "p" given "a" is true * :: v -> ...((a) -> bool) -> a -> bool */ export declare const either: (...fns: Predicate[]) => (x: A) => boolean; /** * Takes a glob of predicates "p" taking a value "a", then a value "a" and returns true if all of "p" given "a" is true * :: v -> ...((a) -> bool) -> a -> bool */ export declare const and: (...fns: Predicate[]) => (...args: A[]) => boolean; /** * Functional If/Else branching * Given predicate(input), execute trueCondition(input) or falseCondition(input). * * @example * * // remove lines starting with comments * ifElse( test( /^\#/ ) , _ => '' , identity ) * * :: predicate ( input A -> boolean ) -> * trueCondition ( input A -> output1 B) -> * falseCondition ( input A -> output2 B)-> * input -> * output B */ export declare function ifElse(p: Function1, t: Function1, f: Function1, i: A): B; export declare function ifElse(p: Function1, t: Function1, f: Function1): (i: A) => B; export declare function ifElse(p: Function1): (t: Function1) => (f: Function1) => (i: A3) => B2; /** * Predicate, right associative greater-than. Check that the second parameter is greater-than the first * @param a number which `b` must be greater-than * @param b number which is checked to be greater-than `a` * @example * pipeline( * 10, * gt(11) * ) // false */ export declare function gt(a: number): (b: number) => boolean; export declare function gt(a: number, b: number): boolean; /** * Predicate, right associative greater-than or equal to. Check that the second parameter is greater-than or equal to the first * @param a number which `b` must be greater than * @param b number which is checked to be greater than `a` * @example * pipeline( * 10, * gt(11) * ) // false */ export declare function gte(a: number): (b: number) => boolean; export declare function gte(a: number, b: number): boolean; /** * Predicate, right associative less-than. Check that the second parameter is less-than the first * @param a number which `b` must be less-than * @param b number which is checked to be less-than `a` * @example * pipeline( * 10, * gt(11) * ) // false */ export declare function lt(a: number): (b: number) => boolean; export declare function lt(a: number, b: number): boolean; /** * Predicate, right associative less-than or equal to. Check that the second parameter is less-than or equal to the first * @param a number which `b` must be less-than * @param b number which is checked to be less-than `a` * @example * pipeline( * 10, * gt(11) * ) // false */ export declare function lte(a: number): (b: number) => boolean; export declare function lte(a: number, b: number): boolean; /** * Predicate checks that both given values `a` and `b` are the same. Strictly typed */ export declare function eq(a: T): (b: T) => boolean; export declare function eq(a: T, b: T): boolean; /** * Predicate checks that both given values `a` and `b` are the same. Untyped. */ export declare function untypedEq(a: any): (b: any) => boolean; export declare function untypedEq(a: any, b: any): boolean;