/** @module function/complementCurry.ts */ import { Complement, Curried2, Curried3, Curried4, Curried5, Curried6, Curried7, Curried8, Curried9, Function1, Function2, Function3, Function4, Function5, Function6, Function7, Function8, Function9, Function_21, Function_211, Function_2111, Function_31, Function_311, Function_41, Function_51, Function_61 } from '../helper-types' import { defineFunctionProperties } from './defineFunctionProperties' export function complementCurry( f: Function1 ): ( Function1> ) export function complementCurry( f: Function2 ): ( Curried2> & Function2> ) // tslint:disable-next-line:unified-signatures export function complementCurry( f: Function2 ): ( Curried2> & Function2> ) export function complementCurry( f: Function3 ): ( Curried3> & Function3> & Function_21> ) export function complementCurry( f: Function4 ): ( Curried4> & Function4> & Function_211> & Function_31> ) export function complementCurry( f: Function5 ): ( Curried5> & Function5> & Function_2111> & Function_311> & Function_41> ) export function complementCurry( f: Function6 ): ( Curried6> & Function6> & Function_51> ) export function complementCurry( f: Function7 ): ( Curried7> & Function7> & Function_61> ) export function complementCurry( f: Function8 ): Curried8> export function complementCurry( f: Function9 ): Curried9> /** * Take a function, then its arguements, then return the boolean opposite of said function. * Returns a curried function. * :: (...args) -> (fn) -> boolean */ export function complementCurry( fn, ...args: any[] ) { return args.length >= fn.length ? !fn( ...args ) : defineFunctionProperties( complementCurry.bind( null, fn, ...args ), { length: fn.length - args.length, name: fn.name, } ) } export default complementCurry