Generic helper for functions.

Static methods

staticequality<T> (a:T, b:T):Bool

It provides strict equality between the two arguments a and b.

staticfn<T> (fn:Void ‑> T, restArgs:Dynamic):Dynamic

Lambda expressions

staticidentity<T> (value:T):T

The identity function returns the value of its argument.

staticinline lift<T, U> (t:T, f:T ‑> U):U

Converts an instance of type T to an instance of type U.

Useful as an extension methods for converting a value to another type inside a chain of function calls.

E.g.

using thx.Functions;
import thx.Options;

var arr: Array<Int> = [1, 2, 3];
var opt : Option<Array<Int>> = myArray.lift(Options.ofValue);
Assert.same(Some(arr), opt); // true

staticnoop ():Void

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

staticwith (context:Dynamic, body:Dynamic):Dynamic