Source code


The Cerny JavaScript library is shipped with solutions for validating JavaScript objects against a schema, pretty printing JSON, logging facilities, dependency management, function call interception and a dictionary mechanism.

Some conventions used:

If a current function or member is overwritten in a script, e.g. 'insertBefore', but will be referred to later, the new name of the member is composed of an underscore followed by the old name, e.g. '_insertBefore'.

If a simple name is not possible due to keyword restrictions, the name is proceeded by an underscore, e.g. '_delete'.

If a function takes arbitrarily many arguments, the documentation for these parameters must be called 'arguments'.

If the documentation for a function does not specify a return value, the function returns undefined.



Used by

All, but CERNY.console.*



Prototypal inheritance [DCP].

obj : the object to be the prototype of the new object.
return : the new object

Attach a function as a method to an object. This allows to create arbitrarliy many functions around the actual function. It allows us to keep concerns separated. The interceptors are wrapped around the function starting with the last one. This allows a "natural order", when filling the array regarding dependency. So more basic interceptors (e.g. LogIndenter) are pushed first.

obj : the obj to attach the function to
name : the name under which the function will be known to the object
func : the function to attach

Dump a value for logging purposes. Returns the value of the variable followed by it's type in braces. If the variable is a string, the value is enclosed by a single quote.

value : the value to dump
return : a string useful for logging

Instrument methods of an object for interception. Can be called multiple times with the same effect, only depending on

This function does not work on the window object in IE.

obj : the object to intercept methods of
arguments : a list of either strings or regexps also alternating specifying which functions to intercept. If not present all functions are intercepted.
return : an array of the names of the intercepted functions

Create a namespace in CERNY. This function is inspired by the Yahoo! UI Library [YUI].

name : The name of the namespace to create

Check whether an expression is present during runtime.

exp : the expression to check, a string
return : false, if the string does not reference anything or the string references 'undefined'

Check for the presence of expressions.

script : the script that requires the expression
arguments : the exressions that are required for further execution
return : an array of missing expressions with 0 or more items

Load a script. This function is called in require. It has different implementations in various environments (browser, Rhino [RHI]).

location : the name of the script to load

Dictionary maker.

A dictionary is a mapping from terms to definitions. Definitions can contain nested terms. The process of evaluating a term is done by lookup.

obj : the obj this dictionary will inherit from
return : a Dictionary object

Lookup a term in this dictionary.

term : the term to lookup
return : the value of the term in the dictionary or undefined if the term is unknown


2007-02-08 : Fixed bug in intercept, which caused objects to be intercepted.
2006-12-31 : Added the interceptor concept.
2006-12-30 : Added the dumpVar method.
2006-11-10 : Created.

API Documentation for version