class Function
Instance methods
-
argumentNames
Function#argumentNames() -> ArrayReads the argument names as stated in the function definition and returns the values as an array of strings (or an empty array if the function is defined without parameters).
-
bind
Function#bind(object[, args...]) -> Function-
object(Object) – The object to bind to.
Wraps the function in another, locking its execution scope to an object specified by
object. -
-
bindAsEventListener
Function#bindAsEventListener(object[, args...]) -> Function-
object(Object) – The object to bind to.
An event-specific variant of
Function#bindwhich ensures the function will recieve the current event object as the first argument when executing. -
-
curry
Function#curry(args...) -> FunctionPartially applies the function, returning a function with one or more arguments already “filled in.”
Function#curry works just like
Function#bindwithout the initial scope argument. Use the latter if you need to partially apply a function and modify its execution scope at the same time. -
defer
Function#defer(args...) -> NumberSchedules the function to run as soon as the interpreter is idle.
A “deferred” function will not run immediately; rather, it will run as soon as the interpreter’s call stack is empty.
Behaves much like
window.setTimeoutwith a delay set to0. Returns an ID that can be used to clear the timeout withwindow.clearTimeoutbefore it runs. -
delay
Function#delay(seconds[, args...]) -> Number-
seconds(Number) – How long to wait before calling the function.
Schedules the function to run after the specified amount of time, passing any arguments given.
Behaves much like
window.setTimeout. Returns an integer ID that can be used to clear the timeout withwindow.clearTimeoutbefore it runs.To schedule a function to run as soon as the interpreter is idle, use
Function#defer. -
-
methodize
Function#methodize() -> FunctionWraps the function inside another function that, at call time, pushes
thisto the original function as the first argument.Used to define both a generic method and an instance method.
-
wrap
Function#wrap(wrapperFunction) -> Function-
wrapperFunction(Function) – The function to act as a wrapper.
Returns a function “wrapped” around the original function.
Function#wrapdistills the essence of aspect-oriented programming into a single method, letting you easily build on existing functions by specifying before and after behavior, transforming the return value, or even preventing the original function from being called. -
