View source

class thx.Functions1

import thx.Functions;

Available on all platforms

Extension methods for functions with arity 1 (functions that take exactly 1 argument).

Class Fields

static inline function compose<TIn, TRet1, TRet2>(fa:TRet2 -> TRet1, fb:TIn -> TRet2):TIn -> TRet1

compose returns a function that calls the first argument function with the result of the following one.

static function fn<T, T2>(fn:T -> T2, restArgs:Dynamic):Dynamic

Lambda expressions

static inline function join<TIn>(fa:TIn -> Void, fb:TIn -> Void):TIn -> Void

join creates a function that calls the 2 functions passed as arguments in sequence and passes the same argument value to the both of them.

static function memoize<TIn, TOut>(callback:TIn -> TOut, ?resolver:TIn -> String):TIn -> TOut

memoize wraps callback and calls it only once storing the result for future needs.

Computed results are stored in an internal map. The keys to this map are generated by the resolver function that by default directly converts the first argument into a string.

static inline function negate<T1>(callback:T1 -> Bool):T1 -> Bool

Wraps callback in a function that negates its results.

static function noop<T>(_:T):Void

noop is a function that has no side effects and doesn't return any value.

static inline function swapArguments<T1, T2, TReturn>(callback:T1 -> T2 -> TReturn):T2 -> T1 -> TReturn

Returns a function that behaves the same as callback but has its arguments inverted.

static inline function times<TIn, TOut>(n:Int, callback:TIn -> TOut):TIn -> Array<TOut>

Creates a function that calls callback n times and returns an array of results.

static inline function timesi<TIn, TOut>(n:Int, callback:TIn -> Int -> TOut):TIn -> Array<TOut>

Creates a function that calls callback n times and returns an array of results.

Callback takes an additional argument index.

Toggle inherited fields