goog.functions
Namespace.FALSE
{function
(...): boolean
}Always returns false.
.NULL
{function
(...): null
}Always returns NULL.
.TRUE
{function
(...): boolean
}Always returns true.
.and(var_args)
Creates a function that returns true if each of its components evaluates to true. The components are evaluated in order, and the evaluation will be short-circuited as soon as a function returns false. For example, (goog.functions.and(f, g))(x) is equivalent to f(x) && g(x).
var_args
{...Function
}
Function
}
.compose(var_args)
Creates the composition of the functions passed in. For example, (goog.functions.compose(f, g))(a) is equivalent to f(g(a)).
var_args
{...Function
}
Function
}
.constant(retValue)
Creates a function that always returns the same value.
retValue
{*}
Function
}
.create(constructor, var_args)
Generic factory function to construct an object given the constructor and the arguments. Intended to be bound to create object factories. Callers should cast the result to the appropriate type for proper type checking by the compiler.
constructor
{!Function
}
var_args
{...*}
Object
}
.error(message)
Creates a function that always throws an error with the given message.
message
{string
}
Function
}
.identity(opt_returnValue, var_args)
A simple function that returns the first argument of whatever is passed into it.
opt_returnValue
{*=}
var_args
{...*}
.lock(f, opt_numArgs)
Given a function, create a function that keeps opt_numArgs arguments and silently discards all additional arguments.
f
{Function
}
opt_numArgs
{number
=}
Function
}
.not(f)
Creates a function that returns the Boolean opposite of a provided function. For example, (goog.functions.not(f))(x) is equivalent to !f(x).
f
{!Function
}
Function
}
.or(var_args)
Creates a function that returns true if any of its components evaluates to true. The components are evaluated in order, and the evaluation will be short-circuited as soon as a function returns true. For example, (goog.functions.or(f, g))(x) is equivalent to f(x) || g(x).
var_args
{...Function
}
Function
}
.sequence(var_args)
Creates a function that calls the functions passed in in sequence, and returns the value of the last function. For example, (goog.functions.sequence(f, g))(x) is equivalent to f(x),g(x).
var_args
{...Function
}
Function
}
.withReturnValue(f, retValue)
Given a function, create a new function that swallows its return value and replaces it with a new one.
f
{Function
}
retValue
{*}
Function
}