Class Util

A singleton utility class.

Constructor

class Util()

Methods

bind

Util#bind(f, scope)
Arguments:
  • f (Function) – the function to which scope and/or arguments are bound
  • scope (Object) – the scope to bind to the function
Throws Error:

: illegal argument exception if f is not a function

Returns Function:
 

the bound function

Binds scope and arguments to a function. All arguments passed after scope are considered bound. Arguments passed to the binder function at call-time are also passed through at the end of the parameter list, after the original bound parameters.

bindPrivate

Util#bindPrivate(f, scope)
Arguments:
  • f (Function) – the function to which scope and/or arguments are bound
  • scope (Object) – the scope to bind as the first parameter of the function
Returns Function:
 

the bound function

Helper bind function for working with private methods. Automatically binds the first parameter to be the scope too.

See also

#bind

decorate

Util#decorate(f, advice)
Arguments:
  • f (Function) – the function to be decorated
  • advice (Object) – holds advice functions
  • advice.before (Function) – An advice (function) to insert before the actual call
  • advice.after (Function) – An advice (function) to insert after the actual call
  • advice.exception (Function) – An advice (function) to call in case of an

exception being thrown from the original function

throws Error:: illegal argument exception if f is not a function
throws Error:: illegal argument exception if any of the possible advices is not a function

Decorate a function with advice. Use {@link #bind} to bind the advice functions to the desired scope.

See also

#bind

defer

Util#defer(f)
Arguments:
  • f (Function) – the function to defer

Defers the execution of a function until the first possible moment to run it. Use {@link #bind} to bind scope and arguments to the function.

format

Util#format(msg)
Arguments:
  • msg

(Too) simple sprintf implementation.

getSession

Util#getSession()
Returns String:the rain session id

Returns the rain session id.

inherits

Util#inherits(ctor, superCtor)
Arguments:
  • ctor (Object) – the derived constructor function
  • superCtor (Object) – the base constructor function

Makes a function inherit from another’s prototype.

In order to make it compatible with node’s implementation, it also makes superCtor accessible through ctor.super_.

inject

Util#inject(on, from)
Arguments:
  • on (Object) – the object which borrows the properties
  • from (Object) – the object which lends the properties

Inject the properties from one object into another. Useful for borrowing methods.

Table Of Contents

Previous topic

Class Stylesheet

Next topic

Intents