Global Functions and Variables

Global object containing all global functions and variables.


Properties

QualifiersPropertyTypeDescription
  
EJSCRIPTBooleanConstant set to true in all Ejscript interpreters.
const InfinityNumberInfinity value.
const NaNNumberInvalid numeric value. If the numeric type is set to an integral type, the value is zero.
const NegativeInfinityNumberNegative infinity value.
ejs.web _initRequestRequestRequest for which a controller is being constructed.
ejs.web actionNamespaceNamespace for all action methods.
const booleanTypeAlias for the Boolean type.
const doubleTypeAlias for the Number type.
ejs Product singleton object.
const emptyStringEmpty string value.
const falseBooleanBoolean false value.
globalObjectGlobal variable space reference. The global variable references an object which is the global variable space. This is useful when guaranteed access to a global variable is required. e.g. global.someName.
internalNamespaceThe internal namespace used to make entities visible within a single module only.
iteratorNamespaceThe iterator namespace used to define iterators.
const nullNullNull value. The null value is returned when testing a nullable variable that has not yet had a value assigned or one that has had null explicitly assigned.
const numTypeAlias for the Number type.
ejs.worker get set onerrorFunctionThe error callback function. This is the callback function to receive incoming data from postMessage() calls. This is only present inside Worker scripts.
ejs.worker get set onmessageFunctionThe callback function configured to receive incoming messages. This is the callback function to receive incoming data from postMessage() calls. This is only present inside Worker scripts.
ejs.worker selfWorkerReference to the Worker object for use inside a worker script This is only present inside Worker scripts.
stderrTextStreamStandard error text stream. Use write(), writeLine() and other TextStream methods.
stdinTextStreamStandard input text stream. Use read(), readLine() and other TextStream methods.
stdoutTextStreamStandard output text stream. Use write(), writeLine() and other TextStream methods.
const stringTypeAlias for the String type.
const trueBooleanTrue value.
const undefinedVoidUndefined variable value. The undefined value is returned when testing for a property that has not been defined.
const voidTypeVoid type value. This is an alias for Void.

Global Class Methods

(No own class methods defined)

QualifiersMethod

Global Instance Methods

QualifiersMethod
ArgError(message: String = null)
 ArgError constructor.
Args(template: Object, argv: Array = expression)
 The Args constructor creates a new instance of the Args.
ArithmeticError(message: String = null)
 ArithmeticError constructor.
Array(values: Array)
 Create a new array.
AssertError(message: String = null)
 AssertError constructor.
BinaryStream(stream: Stream)
 Create a new BinaryStream.
Boolean(value: Boolean = false)
 Boolean constructor.
ByteArray(size: Number = -1, resizable: Boolean = true)
 Create a new array.
Cache(adapter: String = null, options: Object = expression)
 Cache constructor.
ejs.web Cascade(apps: Array): Object
 Cascade middleware script for web apps.
Cmd(command: Object = null, options: Object = null)
 Create an Cmd object.
ejs.web CommonLog(app, logger: Stream = expression): Object
 Common Log web server logging.
ejs.web CommonLogClass(app, logger: Stream = expression)
 Constructor for the CommonLogClass.
ejs.web ContentType(app, options)
 ContentType wrapper middleware.
ejs.web Controller(req: Request = null)
 Create and initialize a controller.
ejs.db Database(adapter: String, options: Object)
 Initialize a database connection using the supplied database connection string.
Date(args: Array)
 Construct a new date object.
ejs.web DirApp(request: Request): Object
 Directory redirection handler.
Emitter()
 Construct a new event Emitter object.
Error(message: String = null)
 Construct a new Error object.
ErrorEvent()
Event()
File(path: Object, options: Object = null)
 Create a File object and open the requested path.
FileSystem(path: Path = null)
 Create a new FileSystem object for the file system that contains the given path.
Frame()
Function(args: Array)
 Create a function from the supplied formal parameter names and function body expression.
ejs.web Head(app: Function)
 Head wrapper middleware.
Http(uri: Uri = null)
 Create an Http object.
ejs.web HttpServer(options: Object = expression)
 Create a HttpServer object.
IOError(message: String = null)
 IOError constructor.
InstructionError(message: String = null)
 InstructionError constructor.
LocalCache(options: Object = null)
 Create and connect to the local cache.
Logger(name: String, location, level: Number = 0)
 Logger constructor.
MemoryError(message: String = null)
 MemoryError constructor.
ejs.web MethodOverride(app: Function): Function
 Method override wrapper middleware.
ejs.web Middleware(app: Function, middleware: Array = null): Function
 Define middleware for a web app.
ejs.web Mvc(home: Path, config = expression)
 Load an MVC application and the optional application specific ejsrc file.
ejs.web MvcApp(request: Request): Object
 MVC request handler.
ejs.web MvcBuilder(request: Request): Function
 MVC builder for use in routing tables.
Number(value: Object = null)
 Number constructor.
Path(path: String = .)
 Create a new Path object and set the path's location.
Record(fields: Object = null)
 Constructor for use when instantiating directly from Record.
ReferenceError(message: String = null)
 ReferenceError constructor.
RegExp(pattern: String, flags: String = null)
 Create a regular expression object that can be used to process strings.
ejs.web Request(uri: Uri, dir: Path = .)
 Construct the a Request object.
ResourceError(message: String = null)
 ResourceError constructor.
ejs.web Route(template: Object, options: Object, router: Router)
 Create a new Route instance.
ejs.web Router(routeSet: String = Restful, options: Object = expression)
 Create a Router instance and initialize routes.
ejs.web ScriptApp(request: Request)
 Run a script app.
ejs.web ScriptBuilder(request: Request): Object
 Script builder to create a function to serve a script request (*..es).
ejs.web Session(key, options: Object = null)
 Create a new session state object.
ejs.web ShowExceptions(app: Function): Function
 ShowExceptions middleware wrapper.
Socket()
 Create a socket object (.
StateError(message: String = null)
 StateError constructor.
ejs.web StaticApp(request: Request): Object
 Static content handler.
ejs.web StaticBuilder(request: Request): Function
 Static builder for use in routing tables to serve static file content.
String(str: Array)
 String constructor.
SyntaxError(message: String = null)
 SyntaxError constructor.
ejs.web TemplateApp(request: Request): Object
 Template web page handler.
ejs.web TemplateBuilder(request: Request, options: Object = expression): Function
 Template builder.
ejs.web TemplateFilter(app: Function): Object
 Template middleware filter.
TemplateParser()
TextStream(stream: Stream)
 Create a text filter stream.
Timer(period: Number, callback: Function, args: Array)
 Constructor for Timer.
TypeError(message: String = null)
 TypeError constructor.
ejs.web UploadFile()
Uri(uri: Object)
 Create and parse a Uri object.
ejs.web UrlMap(map, options): Object
 Directory content handler.
ejs.web View(request: Object)
 Constructor method to initialize a new View.
WebSocket(uri: Uri, protocols = null, options = null)
 Create a new WebSocket and connect to the server using the supplied URI.
Worker(script: Path = null, options: Object = null)
 Create a new Worker instance.
XML(value: Object = null)
 XML Constructor.
XMLList()
 XML Constructor.
assert(condition: Boolean): Void
 Assert a condition is true.
ejs.unix basename(path: String): Path
 Get the base name of a file.
blend(dest: Object, src: Object, options = null): Object
 Blend the contents of one object into another.
breakpoint(): Void
 Convenient way to trap to the debugger 0.
ejs.unix chdir(dir: Object): Void
 Change the current working directory.
ejs.unix chmod(path: String, perms: Number): Void
 Set the permissions of a file or directory.
clearInterval(timer: Timer): Void
 Clear and dispose of an interval timer.
clearTimeout(timer: Timer): Void
 Clear and dispose of a timeout.
ejs.unix cp(src, dest: Path, options = expression): Number
 Copy files Copy files from source patterns to a destination.
decodeURI(str: String): String
 Decode an encoded URI using www-url encoding.
decodeURIComponent(str: String): String
 Decode an encoded URI component.
deserialize(str: String): Object
 Convert a string into an object.
ejs.unix dirname(path: String): Path
 Get the directory name portion of a file.
encodeObjects(items: Array)
 Encode objects using using www-url encoding.
encodeURI(str: String): String
 Encode a URI using www-url encoding.
encodeURIComponent(str: String): String
 Encode a URI component using www-url encoding.
ejs.web escapeHtml(str: String): String
 Transform a string to be safe for output into an HTML web page.
eval(script: String, cache: String = null): Object
 Evaluate a script.
ejs.unix exists(path: String): Boolean
 Does a file exist.
ejs.worker exit(): Void
 Exit the worker.
ejs.unix extension(path: String): String
 Get the file extension portion of the file name.
ejs.unix find(path: Object, patterns: Object = *, options = expression): Array
 Find files under a directory.
ejs.unix freeSpace(path: String = null): Number
 Return the free space in the file system.
hashcode(o: Object): Number
 Get the object's Unique hash id.
ejs.web html(args: Array): String
 HTML encode the arguments.
ejs.unix isDir(path: String): Boolean
 Is a file a directory.
isFinite(arg: Number): Boolean
 Evaluate an argument to determine if it is a finite number.
isNaN(arg: Number): Boolean
 Evaluate an argument to determine if it is a number.
load(file: String, options: Object = null): Object
 Load a script or module.
ejs.unix ls(patterns = *, options: Object = null): Array
 Get a list of files in a directory.
md5(str: String): String
 Computed an MD5 sum of a string This function is prototype and may be renamed in a future release.
ejs.unix mkdir(path: String, permissions: Number = 493): Void
 Make a new directory.
ejs.unix mv(fromFile: String, toFile: String): Void
 Rename a file.
parse(str: String, preferredType: Type = null): Object
 Parse a string and convert to a primitive type.
ejs.web parseCookies(cookieHeader: String): Object
 Return the parsed cookie headers.
parseFloat(str: String): Number
 Parse a string as a floating point number.
parseInt(str: String, radix: Number = 10): Number
 Parse a string and convert to an integral number using the specified radix.
ejs.worker postMessage(data: Object, ports: Array = null): Void
 Post a message to the Worker's parent.
print(args: Array): Void
 Print the arguments to the standard output with a new line appended.
printf(fmt: String, args: Array): Void
 Print the arguments to the standard output using the supplied format template.
prints(args: Array): Void
 Print the arguments to the standard output without a new line appended.
ejs.unix pwd(): Path
 Get the current working directory.
ejs.unix rm(patterns, options = expression): Boolean
 Remove files from the file system.
ejs.unix rmdir(patterns, options = expression): Boolean
 Removes a directory and contents.
serialize(obj: Object, options: Object = null): String
 Encode an object as a string.
setInterval(callback: Function, delay: Number, args: Array): Timer
 Create an interval timer.
setTimeout(callback: Function, delay: Number, args: Array): Number
 Run a function after a delay.
ejs.unix sleep(delay: Number): Void
 Sleep the application for the given number of milliseconds.
ejs.unix tempname(directory: String = null): File
 Create a temporary file.
toOrdinal(number: Number): String
 Convert a number to an ordinal string.
toPlural(word: String, count: Number = null): String
 Convert a singular word to its plural form.
toSingular(word: String): String
 Convert a singular word to its plural form.
typeOf(o): String
 Return the name of a type.
ejs.web unescapeHtml(s: String): String
 Transform an escaped string into its original contents.

Method Detail

ArgError(message: String = null)
Description
ArgError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

Args(template: Object, argv: Array = expression)
Description
The Args constructor creates a new instance of the Args. It parses the command line and stores the parsed options in the options and args properties. Args supports command options that begin with "-" or "--" and parses option arguments of the forms: "-flag x" and "-flag=x".
Parameters
template: Object Command argument template. The template is an object with option properties for: options, usage, onerror ad silent.
argv: Array Array of command arguments to parse. Defaults to App.args. [default: expression]
Options
optionsThis is an object with properties for each command line option. The value of each property is an object with properties: 'alias', 'range', 'value' and 'separator'. The 'alias' property defines a String alias for the option. This is typically used to define a single character alias for the full command line option name. The 'range' property defines what permissible values an option parameter may take. It may be set to either an Ejscript type, a Regular Expression or it may be set to an array of values. The 'value' property may define a default value for the option if it is not defined. This is the value that args.options[OPTION] will be set to when the command line option is absent. If an option without an argument is specified by the user, its value in options[NAME] will be set to true. If the 'separator' property is defined, multiple command line options of this name are permitted. If 'separator' is set to a string, then the multiple command line option values are catenated using the 'separator'. If set to array, the option values are stored in an array.
usageFunction to invoke for argument parse errors.
onerrorIf set to 'throw', an exception will be thrown for argument parse errors. The usage function will not be called and no message will be written to the application log. If set to 'exit', a message will be written to the console for argument parse errors and any usage function will be invoked before exiting the application with a non-zero exit status.
silentDon't emit any message on argument parse errors.
unknownCallback to invoke for unknown arguments.
Example
let args = Args({
    options: {
        depth: { range: Number },
        quiet: { },
        verbose: { alias: 'v', value: true, },
        log: { range: /\w+(:\d)/, value: 'stderr:4' },
        mode: { range: ['low', 'medium', 'high'], value: 'high' },
        with: { range: String, separator: ',' },
    },
    usage: usage,
    onerror: 'exit|throw',
}, [])

let options = args.options
if (options.verbose) { }
for each (file in args.rest) {
    ...
}

ArithmeticError(message: String = null)
Description
ArithmeticError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

Array(values: Array)
Description
Create a new array.
Parameters
values: Array Initialization values. The constructor allows three forms:
  • Array()
  • Array(size: Number)
  • Array(elt: Object, ...args)

AssertError(message: String = null)
Description
AssertError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

BinaryStream(stream: Stream)
Description
Create a new BinaryStream.
Parameters
stream: Stream Stream to stack upon.

Boolean(value: Boolean = false)
Description
Boolean constructor. Construct a Boolean object and initialize its value. Since Boolean values are immutable, this constructor will return a reference to either the "true" or "false" values.
Parameters
value: Boolean Optional value to use in creating the Boolean object. If the value is omitted or 0, -1, NaN, false, null, undefined or the empty string, then the object will be created and set to false. [default: false]

ByteArray(size: Number = -1, resizable: Boolean = true)
Description
Create a new array.
Parameters
size: Number The initial size of the byte array. If not supplied a default buffer size will be used which is typically 4K or larger. [default: -1]
resizable: Boolean Set to true to automatically grow the array as required to fit written data. [default: true]

Cache(adapter: String = null, options: Object = expression)
Description
Cache constructor.
Parameters
adapter: String Adapter for the cache cache. E.g. "local". The Local cache is the only currently supported cache backend. [default: null]
options: Object Adapter options. The common options are described below, other options are passed through to the relevant caching backend. [default: expression]
Options
lifespanDefault lifespan for key values in seconds.
resolutionTime in milliseconds to check for expired expired keys.
timeoutTimeout on cache I/O operations.
traceTrace I/O operations for debug.
moduleModule name containing the cache connector class. This is a bare module name without ".mod" or any leading path. If module is not present, a module name is derrived using "ejs.cache" + adapter.
classClass name containing the cache backend. If the class property is not present, the class is derived from the adapter name with "Cache" appended. The first letter of the adapter is converted to uppercase. For example, if the adapter was "mem", the class would be inferred to be "MemCache". H.

ejs.web Cascade(apps: Array): Object
Description
Cascade middleware script for web apps.
Parameters
apps: Array Array of applications to try in turn. The first app to return a valid status (!= Http.NotFound) will conclude the request.
Returns
A web application function that services a web request and when invoked with the request object will yield a response object.
Example
export.app = Cascade(app1, app2, app3)

Cmd(command: Object = null, options: Object = null)
Description
Create an Cmd object. If a command line is provided, the command is immediately started.
Parameters
command: Object The (optional) command line to initialize with. If a command line is provided, the start method is automatically invoked after the command is constructed. The command may be either a string or an array of arguments. Using an array of args can simplify quoting if the args have embedded spaces or quotes. Use response to read the response. [default: null]
options: Object Command options hash. Supported options are:. [default: null]
options: Object null [default: null]
Options
detachBoolean If true, run the command and return immediately. If detached, finalize must be called to signify the end of data being written to the command's stdin. Detach must be used if using write.
dirPath or String. Directory to set as the current working directory for the command.
exceptionsBoolean If true, throw exceptions if the command returns a non-zero status code. Defaults to false.
timeoutNumber This is the default number of milliseconds for the command to complete. P.

ejs.web CommonLog(app, logger: Stream = expression): Object
Description
Common Log web server logging. This function is a middleware constructor that returns a web application function.
Parameters
app Application servicing the request and generating the response.
logger: Stream Stream to use for writing access log information. [default: expression]
Returns
A web application function that services a web request and when invoked with the request object will yield a response object.
Specified
ejscript-2.7
Stability
Prototype.
Example
export.app = CommonLog(app)
@spec ejs

ejs.web CommonLogClass(app, logger: Stream = expression)
Description
Constructor for the CommonLogClass.
Parameters
app Application function.
logger: Stream Optional logger. Defaults to App.log. [default: expression]

ejs.web ContentType(app, options)
Description
ContentType wrapper middleware. This defines a Content-Type Http header for the content based on an inferred mime type from the Request.pathInfo extension.
Parameters
app Application generating the response.
options Options providing an optional mimeTypes lookup table and default mime type value.
Options
mimeTypesHash table of extension keys with mime type values. If not provided, the Uri.mimeType lookup table is used.
defaultTypeDefault mime type to use if no matching type is found.
Returns
A web application function that services a web request and when invoked with the request object will yield a response object.
Example
export.app = ContentType(app, { mimeTypes: { "md": "text/x-markdown" }})
0

ejs.web Controller(req: Request = null)
Description
Create and initialize a controller. This may be called directly or via the Controller.create factory method.
Parameters
req: Request Web request object 8. [default: null]

ejs.db Database(adapter: String, options: Object)
Description
Initialize a database connection using the supplied database connection string. The first opened database will also be defined as the default database.
Parameters
adapter: String Database adapter to use. E.g. "sqlite". Sqlite is currently the only supported adapter.
options: Object Connection options. This may be filename or an object hash of properties. If set to a filename, it should contain the filename of the database on the local system. If options is an object hash, it should contain adapter specific properties that specify how to attach to the database.
Options
nameDatabase name.
usernameDatabase username.
passwordDatabase password.
traceTrace database commands to the log.
socketDatabase communications socket.
moduleModule name containing the database connector class. This is a bare module name without ".mod" or any leading path.
classClass name containing the database backend.

Date(args: Array)
Description
Construct a new date object. Permissible constructor forms:
  • Date() This is the default and it constructs a date instance for the current time.
  • Date(milliseconds) where (seconds sincde 1 Jan 1970 00:00:00 UTC))
  • Date(dateString) where (In a format recognized by parse())
  • Date(year, month, date) where (Four digit year, month: 0-11, date: 1-31)
  • Date(year, month, date [, hour, minute, second, msec]) where (hour: 0-23, minute: 0-59, second: 0-59, msec: 0-999)

ejs.web DirApp(request: Request): Object
Description
Directory redirection handler. This redirects requests for directories and serves directory index files. If the request pathInfo ends with "/", the request is transparently redirected to an index file if one is present. The set of index files is defined by HttpServer.indicies. If the request is a directory but does not end in "/", the client is redirected to a URL equal to the pathInfo with a "/" appended.
Parameters
request: Request Request object.
Returns
A response hash object.
Specified
ejscript-2.7
Stability
Prototype 8.

Emitter()
Description
Construct a new event Emitter object.

Error(message: String = null)
Description
Construct a new Error object.
Parameters
message: String Message to use when defining the Error.message property. Typically a string but can be an object of any type. 8. [default: null]

File(path: Object, options: Object = null)
Description
Create a File object and open the requested path.
Parameters
path: Object The name of the file to associate with this file object. Can be either a String or a Path.
options: Object If the open options are provided, the file is opened. See open for the available options. [default: null]

FileSystem(path: Path = null)
Description
Create a new FileSystem object for the file system that contains the given path.
Parameters
path: Path String or Path of a file that would reside in the file system. [default: null]

Function(args: Array)
Description
Create a function from the supplied formal parameter names and function body expression.
Parameters
args: Array The parameters and body are suplied as discrete parameters to Function(), i.e. not as an array of args. Function ([args, ...], body).

ejs.web Head(app: Function)
Description
Head wrapper middleware. Return the headers and omit the body for HTTP HEAD requests. HEAD requests should still preserve the original Content-Length header value even though they transmit no body content. This version is limited, in that it will only define a Content-Length if the response body is a string.
Parameters
app: Function Application servicing the request and generating the response.
Returns
A web application function that when invoked with the request will yield a response object.
Example
export.app = Head(app)

Http(uri: Uri = null)
Description
Create an Http object. The object is initialized with the Uri.
Parameters
uri: Uri The (optional) Uri to initialize with. [default: null]
Throws
IOError: if the Uri is malformed.

ejs.web HttpServer(options: Object = expression)
Description
Create a HttpServer object. The server is set to async mode by default. If an "ejsrc" file exists in the server root, it will be loaded.
Parameters
options: Object Set of options to configure the server. [default: expression]
options: Object null [default: expression]
Options
documentsDirectory containing web documents to serve. If unset and the HttpServer is hosted, the documents property will be defined by the web server.
homeBase directory for the server and the "ejsrc" configuration file. If unset and the HttpServer is hosted, the home property will be defined by the web server.
ejsrcAlternate path to the "ejsrc" configuration file.
configAlternate App.config settings.
unhostedIf hosted inside a web server, set to true to bypass any web server listening endpoints and create a new stand-alone (unhosted) listening connection.
Specified
ejscript-2.7
Stability
Prototype.
Example
let server: HttpServer = new HttpServer({documents: "web"})
let router = Router(Router.Restful)
server.on("readable", function (event: String, request: Request) {
    // "this" object is also set to request
    request.status = 200
    request.setHeaders({"Content-Type": "text/plain"})
    request.on("readable", function (event, request) {
        let data = new ByteArray
        if (request.read(data) == null) {
            print("EOF")
        }
    })
    request.on("writable", function (event) {
        request.write("Hello World")
        request.finalize()
    })
}
server.listen("127.0.0.1:7777")

IOError(message: String = null)
Description
IOError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

InstructionError(message: String = null)
Description
InstructionError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

LocalCache(options: Object = null)
Description
Create and connect to the local cache. An application has only one cache regardless of how many LocalCache instances are created. All LocalCache instances connect to the same underlying cache. Multiple interpreters can use the local cache to reliably share information.
Parameters
options: Object Configuration options. [default: null]
Options
sharedCreate or connect to a single, shared cache. If multiple interpreters in a single process create shared LocalCache instances they will be able to share key/value data.
lifespanDefault lifespan for key values in seconds. Set to zero for a default unlimited timeout.
resolutionTime in milliseconds to check for expired expired keys.
memoryMaximum memory to use for keys and data.
traceTrace I/O operations for debug.

Logger(name: String, location, level: Number = 0)
Description
Logger constructor. The Logger constructor can create different types of loggers based on the three (optional) arguments.
Parameters
name: String Unique name of the logger. Loggers are typically named after the module, class or subsystem they are associated with.
location Optional output stream or Logger to send messages to. If a parent Logger instance is provided for the output parameter, messages are sent to the parent for rendering.
level: Number Optional integer verbosity level. Messages with a message level less than or equal to the defined logger level will be emitted. Range is 0 (least verbose) to 9. [default: 0]
Example
var file = File("progress.log", "w")
var log = new Logger("name", file, 5)
log.debug(2, "message")

MemoryError(message: String = null)
Description
MemoryError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

ejs.web MethodOverride(app: Function): Function
Description
Method override wrapper middleware. Provides HTTP method overriding via a "-ejs-method-" POST parameter or via a X-HTTP-METHOD-OVERRIDE Http header.
Parameters
app: Function Application generating the response.
Returns
A web application function that services a web request and when invoked with the request object will yield a response object.
Example
export.app = MethodOverride(app)

ejs.web Middleware(app: Function, middleware: Array = null): Function
Description
Define middleware for a web app. This wrapps the web application function with defined middleware filters.
Parameters
app: Function Base web app function object.
middleware: Array Array of middleware wrapper applications. [default: null]
Returns
A top level web application function object.
Specified
ejscript-2.7
Stability
Prototype.

ejs.web Mvc(home: Path, config = expression)
Description
Load an MVC application and the optional application specific ejsrc file.
Parameters
home: Path Base directory for the MVC app.
config Configuration object 8. [default: expression]

ejs.web MvcApp(request: Request): Object
Description
MVC request handler.
Parameters
request: Request Request object.
Returns
A response hash (empty). MVC apps use Request methods directly to set status, headers and response body.
Specified
ejscript-2.7
Stability
Prototype.

ejs.web MvcBuilder(request: Request): Function
Description
MVC builder for use in routing tables. The MVC builder function can be included directly in Route table entries.
Parameters
request: Request Request object.
Returns
A web script function that services a web request.
Specified
ejscript-2.7
Stability
Prototype.

Number(value: Object = null)
Description
Number constructor.
Parameters
value: Object Value to use in creating the Number object. If the value cannot be converted to a number, the value will ba NaN (or 0 if using integer numerics). 8. [default: null]

Path(path: String = .)
Description
Create a new Path object and set the path's location.
Parameters
path: String Name of the path to associate with this path object. [default: .]

Record(fields: Object = null)
Description
Constructor for use when instantiating directly from Record. Typically, use models will implement this class and will provdie their own constructor which calls initialize().
Parameters
fields: Object null [default: null]

ReferenceError(message: String = null)
Description
ReferenceError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

RegExp(pattern: String, flags: String = null)
Description
Create a regular expression object that can be used to process strings.
Parameters
pattern: String The pattern to associated with this regular expression.
flags: String "g" for global match, "i" to ignore case, "m" match over multiple lines (may also need to use "s"), "y" for sticky match, "s" so that "." will match all characters. [default: null]

ejs.web Request(uri: Uri, dir: Path = .)
Description
Construct the a Request object. Request objects are typically created by HttpServers and not constructed manually.
Parameters
uri: Uri Request URI.
dir: Path Default directory containing web documents. [default: .]

ResourceError(message: String = null)
Description
ResourceError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

ejs.web Route(template: Object, options: Object, router: Router)
Description
Create a new Route instance. This is normally not invoked directly. Rather Router.add() is used to create and install routes into the Router.
Parameters
template: Object String or Regular Expression defining the form of a matching URI (Request.pathInfo).
options: Object Route options representing the URI and options to use when servicing the request. If it is a string, it may begin with an " @" and be of the form " @[controller/]action". In this case, if there is a "/" delimiter, the first portion is a controller and the second is the controller action to invoke. The controller or action may be absent. For example: " @Controller/", " @action", " @controller/action". If the string does not begin with an " @", it is interpreted as a literal URI. For example: "/web/index.html". If the options is an object hash, it may contain the options below:.
router: Router Owning router object.
Options
actionAction method to service the request. This may be of the form "action", "controller/action" or "controller/". If the action portion omitted, the default action (index) will be used.
controllerController to service the request.
methodHTTP Method for which the route is valid. Set to "*"" for all methods.
nameName to give to the route. If absent, the name is created from the controller and action names.
outerParent route. The parent's template and parameters are appended to this route.
paramsOverride parameter to provide to the request in the Request.params.
Example
Route("/{controller}(/{action}(/{id}))/", { method: "POST" })
Route("/User/login", {name: "login" })

ejs.web Router(routeSet: String = Restful, options: Object = expression)
Description
Create a Router instance and initialize routes.
Parameters
routeSet: String Optional name of the route set to add. Supports sets include: Router.Top and Router.Restful. The Top routes provide top level routes for pages with extensions ".ejs", and ".es" as well as for static content (see addHandlers addCatchall). The Restful routes provide default Controller/Action routes according to a RESTful paradigm (see addRestful). The routeSet can also be set to null to add not routes. This is useful for creating a bare Router instance. Defaults to Top. [default: Restful]
options: Object Options to apply to all routes. [default: expression]
Options
workersBoolean If true, requests should be execute in a worker thread if possible. The worker thread will be pooled when the request completes and will be available for subsequent requests.
Throws
Error: for an unknown route set.

ejs.web ScriptApp(request: Request)
Description
Run a script app. Run the script specified by request.filename.
Parameters
request: Request Request object.
Returns
A response object.
Specified
ejscript-2.7
Stability
Prototype.
Example
{ name: "index", builder: ScriptBuilder, match: "\.es$" }
@spec ejs

ejs.web ScriptBuilder(request: Request): Object
Description
Script builder to create a function to serve a script request (*..es).
Parameters
request: Request Request object.
Returns
A request response.
Specified
ejscript-2.7
Stability
Prototype.

ejs.web Session(key, options: Object = null)
Description
Create a new session state object. This uses the Store in-memory caching service.
Parameters
key Optional key to provide. If omitted or null, a new key will be generated. If the given key has expired, a new key will be generated.
options: Object null [default: null]
options: Object null [default: null]
Options
lifespanLifespan in seconds for the session.

ejs.web ShowExceptions(app: Function): Function
Description
ShowExceptions middleware wrapper. This catches exceptions and formats the result back to the client.
Parameters
app: Function Application servicing the request and generating the response.
Returns
A web application function that services a web request and when invoked with the request object will yield a response object.

Socket()
Description
Create a socket object (.

StateError(message: String = null)
Description
StateError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

ejs.web StaticApp(request: Request): Object
Description
Static content handler. This supports DELETE, GET, POST and PUT methods. It handles directory redirection and will use X-SendFile for efficient transmission of static content. The If-Match, If-None-Match, If-Modified-Since and If-Unmodified-Since headers are supported.
Parameters
request: Request Request objects.
Returns
A response hash object.
Specified
ejscript-2.7
Stability
Prototype.
Example
{ name: "index", builder: StaticApp }
@spec ejs

ejs.web StaticBuilder(request: Request): Function
Description
Static builder for use in routing tables to serve static file content.
Parameters
request: Request Request object.
Returns
A web script function that services a web request for static content.
Specified
ejscript-2.7
Stability
Prototype.

String(str: Array)
Description
String constructor. This can take two forms:
  • String()
  • String(str: String)
Parameters
str: Array The args can be either empty or a string. If a non-string arg is supplied, the VM will automatically cast to a string.

SyntaxError(message: String = null)
Description
SyntaxError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

ejs.web TemplateApp(request: Request): Object
Description
Template web page handler. The template web page at request.filename will be processed and run.
Parameters
request: Request Request objects.
Returns
A response hash object.
Specified
ejscript-2.7
Stability
Prototype.
Example
{ name: "index", builder: TemplateApp, match: "\.ejs$" }
@stability prototype

ejs.web TemplateBuilder(request: Request, options: Object = expression): Function
Description
Template builder. This routine creates a template function to serve requests for template files. The template path can be supplied via the request.filename or a literal template can be provided via options.literal.
Parameters
request: Request Request object.
options: Object Object hash of options. [default: expression]
Options
layoutPath Layout file.
literalString containing the template to render. In this case request.filename is ignored.
dirPath Base directory to use for including files and for resolving layout directives.
Returns
A web script function that services a web request.
Specified
ejscript-2.7
Stability
Prototype.

ejs.web TemplateFilter(app: Function): Object
Description
Template middleware filter. This interprets the output of an inner web app as a template page which is processed.
Parameters
app: Function Application function object.
Returns
A response object hash.
Specified
ejscript-2.7
Stability
Prototype.

TextStream(stream: Stream)
Description
Create a text filter stream. A Text filter stream must be stacked upon a stream source such as a File.
Parameters
stream: Stream Stream data source/sink to stack upon.

Timer(period: Number, callback: Function, args: Array)
Description
Constructor for Timer. The timer is will not be called until start is called.
Parameters
period: Number Delay in milliseconds before the timer will run.
callback: Function Function to invoke when the timer is due. The callback is invoked with the following signature: function callback(error: Error): Void.
args: Array Callback arguments.

TypeError(message: String = null)
Description
TypeError constructor.
Parameters
message: String Message to use when defining the Error.message property. [default: null]

Uri(uri: Object)
Description
Create and parse a Uri object.
Parameters
uri: Object A string or object hash that describes the URI. The uri may specify a complete absolute URI string or it may specify a partial URI where missing elements take the normal defaults. The uri argument may also be an object hash with the following properties.
Options
schemeString URI protocol scheme (http or https).
hostString URI host name or IP address.
portNumber TCP/IP port number for communications.
pathString URI path.
queryString URI query parameters. Does not include "?".
referenceString URI path reference. Does not include "#".

ejs.web UrlMap(map, options): Object
Description
Directory content handler. This redirects requests for directories and serves directory index files. If the request pathInfo ends with "/", the request is transparently redirected to an index file if one is present. The set of index files is defined by HttpServer.indicies. If the request is a directory but does not end in "/", the client is redirected to a URL equal to the pathInfo with a "/" appended.
Parameters
map Map of URLs to use for routing. TODO.
options TODO.
Returns
A response hash object.
Specified
ejscript-2.7
Stability
Prototype.

ejs.web View(request: Object)
Description
Constructor method to initialize a new View.
Parameters
request: Object Request object.

WebSocket(uri: Uri, protocols = null, options = null)
Description
Create a new WebSocket and connect to the server using the supplied URI.
Parameters
uri: Uri URL to connect to.
protocols Optional set of protocols supported by the application. These are application-level protocols. This argument may be an array or a string of comma separated values. [default: null]
options null [default: null]
options null [default: null]
Options
certificatePath|String Optional path to file containing certificates to validate the server certificate.
verifyBoolean Set to true to verify the server certificate. The certificate is verified and the issuer chain is verified. Defaults to true. Set to false to accept a self-signed certificate.
framesPreserve individual message frames to onmessage. P.

Worker(script: Path = null, options: Object = null)
Description
Create a new Worker instance. This call returns an outside worker object for using in the calling interpreter. Inside the worker interpreter, a corresponding "inside" worker object is created that is paired to the outside worker.
Parameters
script: Path Optional path to a script or module to execute. If supplied, then a new Worker instance will invoke load() to execute the script. [default: null]
options: Object Options hash. [default: null]
Options
searchSearch path.
nameName of the Worker instance.
Specified
WebWorker and ejs

XML(value: Object = null)
Description
XML Constructor. Create an empty XML object.
Parameters
value: Object An optional XML or XMLList object to clone. [default: null]

XMLList()
Description
XML Constructor. Create an empty XML object.

assert(condition: Boolean): Void
Description
Assert a condition is true. This call tests if a condition is true by testing to see if the supplied expression is true. If the expression is false, the interpreter will throw an exception.
Parameters
condition: Boolean JavaScript expression evaluating or castable to a Boolean result.
Throws
AssertError: if the condition is false.
Specified
ejscript-2.7

ejs.unix basename(path: String): Path
Description
Get the base name of a file. Returns the base name portion of a file name. The base name portion is the trailing portion without any directory elements.
Returns
A string containing the base name portion of the file name.

blend(dest: Object, src: Object, options = null): Object
Description
Blend the contents of one object into another. This routine copies the properites of one object into another.

If the "deep" option is set, object properties have their contents are cloned. Otherwise, the object reference is copied. Arrays are never deep copied.

If the "combine" property is set, then property prefixes: +, =, - and ? are used as modifiers describing how to combine source and destination property values.

If the "overwrite" option is false, properties will only be copied if they do not already exist in the destination.
Parameters
dest: Object Destination object.
src: Object Source object.
options Control options. [default: null]
Options
combineBoolean. If true, then support key prefixes "+", "=", "-", "?" to add, assign and subtract and conditionally assign key values. When adding string properties, values will be appended using a space separator. Extra spaces will not be removed on subtraction. Arrays with string values may also be combined using these key prefixes.
deepBoolean. If true, then recursively copy the properties of any objects referenced in the source object. Otherwise, the copy is only one level deep. Defaults to true.
functionsBoolean. If true, then copy functions. Defaults to false.
overwriteBoolean. If true, then overwrite existing properties in the destination object. Defaults to true.
publicBoolean. If true, then permit blending into public instance properties.
subclassesBoolean. If true, then copy subclass properties. Defaults to true.
traceBoolean. If true, then trace to the App.log the copied property names.
Returns
The destination object.
Specified
ejscript-2.7
Example
X

breakpoint(): Void
Description
Convenient way to trap to the debugger 0.

ejs.unix chdir(dir: Object): Void
Description
Change the current working directory.
Parameters
dir: Object Directory String or path to change to.

ejs.unix chmod(path: String, perms: Number): Void
Description
Set the permissions of a file or directory.
Parameters
path: String File or directory to modify.
perms: Number Posix style permission mask.

clearInterval(timer: Timer): Void
Description
Clear and dispose of an interval timer.
Parameters
timer: Timer Interval timer returned from setInterval.

clearTimeout(timer: Timer): Void
Description
Clear and dispose of a timeout.
Parameters
timer: Timer Timeout timer returned from setTimeout.

ejs.unix cp(src, dest: Path, options = expression): Number
Description
Copy files Copy files from source patterns to a destination. This is a wrapper over Path.operate() and it supports all of its options.

The 'src' argument can be a Path or String or an array of Strings/Paths representing files/directories to copy and may include wildcards. If a src element is a directory, then it all files and subdirectories underneath will be copied.

By default, this method operates in 'flatten' mode where the source directory structure is not copied. To copy an entire directory tree, set 'flatten' to false in the options. In this case, the entire source path is created under the destination.

If the 'relative' or 'trim' options are defined, it is assumed that flatten mode is disabled.
Parameters
src Path | String | Array This may be a String or Path containing the source paths to copy. It may also be an array of Paths or Strings. The 'src' patterns may contain: ? {} Comma separated patterns ! Negates pattern. This removes matching patterns from the set. These are applied after all source patterns have been processed. Use !! to escape. If item is a directory, then '***'' is automatically appended.
dest: Path Destination file or directory. If multiple files are copied, dest is assumed to be a directory and will be created if required. If dest has a trailing '/', it is assumed to be a directory.
options Additional processing instructions. All the options provided by #Path.operate are supported. [default: expression]
Returns
Number of files copied.

decodeURI(str: String): String
Description
Decode an encoded URI using www-url encoding.
Parameters
str: String Encoded string.
Returns
A decoded string.

decodeURIComponent(str: String): String
Description
Decode an encoded URI component.
Parameters
str: String Encoded string.
Returns
A decoded string.

deserialize(str: String): Object
Description
Convert a string into an object. This will parse a string that has been encoded via serialize. It may contain nested objects and arrays. This is a static method.
Parameters
str: String The string containing the object encoding.
Returns
The fully constructed object or undefined if it could not be reconstructed.
Throws
IOError: If the object could not be reconstructed from the string.
Specified
ejscript-2.7

ejs.unix dirname(path: String): Path
Description
Get the directory name portion of a file. The dirname name portion is the leading portion including all directory elements and excluding the base name. On some systems, it will include a drive specifier.
Returns
A string containing the directory name portion of the file name.

encodeObjects(items: Array)
Description
Encode objects using using www-url encoding. Each object is encoded as a "key=value" pair. Each pair is separated by a "&" character.
Parameters
items: Array Strings to encode.
Returns
An encoded string.

encodeURI(str: String): String
Description
Encode a URI using www-url encoding. This replaces special characters with encoded alternative sequence. The encode call replaces all characters except: alphabetic, decimal digits, "-", "_", ".", "!", "~", "*"", "'", "(", ")", "#",";", ",", "/", "?", ":", ".
Parameters
str: String String to encode.
Returns
An encoded string.

encodeURIComponent(str: String): String
Description
Encode a URI component using www-url encoding. This replaces special characters with encoded alternative sequence. The encode call replaces all characters except: alphabetic, decimal digits, "-", "_", ".", "!", "~", "*"", "'", "(", ")". Note that this call encodes "=" and "&" which are often used in URL query name/key pairs.
Parameters
str: String String to encode.
Returns
An encoded string.

ejs.web escapeHtml(str: String): String
Description
Transform a string to be safe for output into an HTML web page. It does this by changing the & > < " ' characters into their ampersand HTML equivalents. This is equivalent to:

str.replace(/&/g,'&').replace(/\>/g,'>').replace(/
Parameters
str: String Input string.
Returns
An new escaped HTML string.
Specified
ejscript-2.7
Stability
Prototype.

eval(script: String, cache: String = null): Object
Description
Evaluate a script. Not present in ejsvm.
Parameters
script: String Script string to evaluate.
cache: String Path to cache file to save compiled script. [default: null]
Returns
The the script expression value.

ejs.unix exists(path: String): Boolean
Description
Does a file exist. Return true if the specified file exists and can be accessed.
Parameters
path: String Filename path to examine.
Returns
True if the file can be accessed 0.

ejs.worker exit(): Void
Description
Exit the worker. This is only valid inside Worker scripts.
Specified
ejscript-2.7

ejs.unix extension(path: String): String
Description
Get the file extension portion of the file name. The file extension is the portion after the last "." in the path.
Parameters
path: String Filename path to examine.
Returns
String containing the file extension. It excludes "." as the first character.

ejs.unix find(path: Object, patterns: Object = *, options = expression): Array
Description
Find files under a directory. This uses Path.files to implement the functionality.
Parameters
path: Object Path or array of paths from which to search.
patterns: Object Pattern to match files. This can be a String, Path or array of String/Paths. The wildcard '?' matches any single character, '*'' matches zero or more characters in a filename or directory, '*** /' matches zero or more files or directories and matches recursively in a directory tree. If a pattern terminates with "/" it will only match directories. The pattern '***'' is equivalent to '*** / *'' (ignore spaces). The Posix "[]" and "{a,b}" style expressions are not supported. [default: *]
options Optional properties to control the matching. [default: expression]
Options
depthFirstDo a depth first traversal of directories. If true, then the directories will be shown after the files in the directory. Otherwise, directories will be listed first.
excludeString|Regular RegExp pattern of files to exclude from the results. Matches the entire path. Only for the purpose of this match, directories will have "/" appended. May be set to the string "directories" to exclude directories from the results which are by default included.
hiddenInclude hidden files starting with ".".
includeRegular expression pattern of files to include in the results. Matches the entire returned path. Only for the purpose of this match, directories will have "/" appended. To include only directories in the results, use {include: /\//}.
missingSet to undefined to report patterns that don't resolve into any files or directories by throwing an exception. Set to any non-null value to be used in the results when there are no matching files or directories. Set to the empty string to use the patterns in the results and set to null to do nothing.
relativeReturn paths relative to the Path, otherwise result entries include the Path. Defaults to false.
Returns
An Array of Path objects for each file in the directory.

ejs.unix freeSpace(path: String = null): Number
Description
Return the free space in the file system.
Parameters
path: String null [default: null]
Returns
The number of 1M blocks (1024 * 1024 bytes) of free space in the file system.

hashcode(o: Object): Number
Description
Get the object's Unique hash id. All objects have a unique object hash.
Returns
This property accessor returns a long containing the object's unique hash identifier.

ejs.web html(args: Array): String
Description
HTML encode the arguments. This escapes HTML directives to be safe for inclusion in a web page.
Parameters
args: Array Variable arguments that will be converted to safe html.
Returns
A string containing the encoded arguments catenated together.
Specified
ejscript-2.7
Stability
Prototype 0.

ejs.unix isDir(path: String): Boolean
Description
Is a file a directory. Return true if the specified path exists and is a directory.
Parameters
path: String Directory path to examine.
Returns
True if the file can be accessed.

isFinite(arg: Number): Boolean
Description
Evaluate an argument to determine if it is a finite number.
Parameters
arg: Number To evaluate.
Returns
True if the argument is a finite number.

isNaN(arg: Number): Boolean
Description
Evaluate an argument to determine if it is a number.
Parameters
arg: Number To evaluate.
Returns
True if the argument is a number.

load(file: String, options: Object = null): Object
Description
Load a script or module.
Parameters
file: String Path name to load. File will be interpreted relative to EJSPATH if it is not found as an absolute or relative file name.
options: Object Option parameters. [default: null]
Options
cacheString or Path name to save the compiled script as.
reloadBoolean If true, reload the module if already loaded. Defaults to true.
Returns
The value of the last expression in the loaded module.

ejs.unix ls(patterns = *, options: Object = null): Array
Description
Get a list of files in a directory.
Parameters
patterns Pattern to match files. This can be a String, Path or array of String/Paths. The wildcards "*"", "***"" and "?" are the only wild card patterns supported. The "***"" pattern matches every directory. The Posix "[]" and "{a,b}" style expressions are not supported. [default: *]
options: Object If set to true, then files will include sub-directories in the returned list of files. [default: null]
Options
depthFirstDo a depth first traversal of directories. If true, then the directories will be shown after the files in the directory. Otherwise, directories will be listed first.
excludeString|Regular RegExp pattern of files to exclude from the results. Matches the entire path. Only for the purpose of this match, directories will have "/" appended. May be set to the string "directories" to exclude directories from the results which are by default included.
hiddenShow hidden files starting with ".".
includeRegular expression pattern of files to include in the results. Matches the entire returned path.
missingSet to undefined to report patterns that don't resolve into any files or directories by throwing an exception. Set to any non-null value to be used in the results when there are no matching files or directories. Set to the empty string to use the patterns in the results and set to null to do nothing.
Returns
An Array of Path objects for each matching file.

md5(str: String): String
Description
Computed an MD5 sum of a string This function is prototype and may be renamed in a future release.
Parameters
str: String String on which to compute a checksum.
Returns
An MD5 checksum.
Specified
ejs 8

ejs.unix mkdir(path: String, permissions: Number = 493): Void
Description
Make a new directory. Makes a new directory and all required intervening directories. If the directory already exists, the function returns without throwing an exception.
Parameters
path: String Filename path to use.
permissions: Number Optional posix permissions mask number. e.g. 0664. [default: 493]
Throws
IOError: if the directory cannot be created. H

ejs.unix mv(fromFile: String, toFile: String): Void
Description
Rename a file. If the new file name exists it is removed before the rename.
Parameters
fromFile: String Original file name.
toFile: String New file name.
Throws
IOError: if the original file does not exist or cannot be renamed.

parse(str: String, preferredType: Type = null): Object
Description
Parse a string and convert to a primitive type.
Parameters
str: String String to parse.
preferredType: Type Preferred type to use if the input can be parsed multiple ways. [default: null]
Returns
Parsed object.

ejs.web parseCookies(cookieHeader: String): Object
Description
Return the parsed cookie headers. Cookies are used to specify the session state. If sessions are being used, a session cookie will be sent to and from the browser with each request.
Specified
ejscript-2.7
Stability
Prototype.

parseFloat(str: String): Number
Description
Parse a string as a floating point number.
Parameters
str: String String to parse.
Returns
A parsed number.

parseInt(str: String, radix: Number = 10): Number
Description
Parse a string and convert to an integral number using the specified radix.
Parameters
str: String String to parse.
radix: Number Base radix to use when parsing the number. [default: 10]
Returns
A parsed number P.

ejs.worker postMessage(data: Object, ports: Array = null): Void
Description
Post a message to the Worker's parent. This is only valid inside Worker scripts.
Parameters
data: Object Data to pass to the worker's onmessage callback.
ports: Array Not implemented.

print(args: Array): Void
Description
Print the arguments to the standard output with a new line appended. This call evaluates the arguments, converts the result to strings and prints the result to the standard output. Arguments are converted to strings by calling their toString method.
Parameters
args: Array Variables to print.
Specified
ejscript-2.7

printf(fmt: String, args: Array): Void
Description
Print the arguments to the standard output using the supplied format template. This call evaluates the arguments, converts the result to strings and invokes String.format to format the args. The result is then printed to the standard output. Arguments are converted to strings by calling their toString method.
Parameters
fmt: String Format specifier.
args: Array Variables to print.
Specified
ejscript-2.7

prints(args: Array): Void
Description
Print the arguments to the standard output without a new line appended. This call evaluates the arguments, converts the result to strings and prints the result to the standard output. Arguments are converted to strings by calling their toString method.
Parameters
args: Array Variables to print.
Specified
ejscript-2.7

ejs.unix pwd(): Path
Description
Get the current working directory.
Returns
A Path containing the current working directory.

ejs.unix rm(patterns, options = expression): Boolean
Description
Remove files from the file system.
Parameters
patterns Pattern to match files to remove. This can be a String, Path or array of String/Paths. The wildcards "*"", "***"" and "?" are the only wild card patterns supported. The "***"" pattern matches every directory. The Posix "[]" and "{a,b}" style expressions are not supported.
options Options to modify the removal. [default: expression]
Options
excludeRegular expression pattern of files to exclude from removal. Matches the entire path.
hiddenRemove hidden files starting with "." Defaults to true.
includeRegular expression pattern of files to remove. Matches the entire returned path.
nodirsExclude directories from removal. The default is to include directories.
Returns
True if all the contents are sucessfully deleted. Otherwise return false.

ejs.unix rmdir(patterns, options = expression): Boolean
Description
Removes a directory and contents.
Parameters
patterns Pattern to match files to delete. This can be a String, Path or array of String/Paths. The wildcards "*"", "***"" and "?" are the only wild card patterns supported. The "***"" pattern matches every directory. The Posix "[]" and "{a,b}" style expressions are not supported.
options Options to modify the removal. [default: expression]
Options
excludeRegular expression pattern of files to exclude from removal. Matches the entire path.
hiddenRemove hidden files starting with ".".
includeRegular expression pattern of files to remove. Matches the entire returned path.
Returns
True if all the contents are sucessfully deleted or if the directory does not exist. Otherwise return false.

serialize(obj: Object, options: Object = null): String
Description
Encode an object as a string. This function returns a literal string for the object and all its properties. If maxDepth is sufficiently large (or zero for infinite depth), each property will be processed recursively until all properties are rendered. NOTE: the maxDepth, all and base properties are not yet supported.
Parameters
obj: Object Object to serialize. If options is null, each option takes the defaults described.
options: Object Serialization options. [default: null]
Options
baseClassesBoolean determining if base class properties will be serialized. Defaults to false.
commasBoolean Always put commas after the last property in an object. Defaults to false.
depthNumber indiciating the depth to recurse when converting properties to literals. If set to zero, the depth is infinite. Defaults to zero.
indentNumber|String Indentation of nested structures. If omitted, the result is packed without any whitespace. If a number, it represents the number of spaces to indent at each level. If a string, it is contains the characters to indent. If the pretty argument is true, it overrides indent.
hiddenBooean determining if hidden properties are serialized. If true, hidden properties will be serialized. Defaults to false.
namespacesBoolean determining if properties will also display their namespace attributes. Default is false.
prettyBoolean determining if a human readable output is used with new lines after each property. Default is false.
quotesBoolean If false, emit property names without quotes if they do not contain spaces. Defaults to true.
multilineBoolean If false, do not emit multiline strings. Defaults to false.
replacerAn optional parameter that determines how object values are stringified for objects without a toJSON method. The replace has the following signature: function replacer(key: String, value: String): String.
Returns
This function returns a string containing an object literal that can be used to reinstantiate an object.
Throws
TypeError: If the object could not be converted to a string.
Specified
ejscript-2.7

setInterval(callback: Function, delay: Number, args: Array): Timer
Description
Create an interval timer. This will invoke the callback every delay milliseconds.
Parameters
callback: Function Function to invoke when the timer is due.
delay: Number Time period in milliseconds between invocations of the callback.
args: Array Function arguments to provide to the callback.
Returns
Timer ID that can be used with clearInterval.

setTimeout(callback: Function, delay: Number, args: Array): Number
Description
Run a function after a delay.
Parameters
callback: Function Function to invoke when the timer expires.
delay: Number Time in milliseconds until the timer expires and the callback is invoked.
args: Array Function arguments.
Returns
Timer that can be used with clearTimeout.

ejs.unix sleep(delay: Number): Void
Description
Sleep the application for the given number of milliseconds. Events will be serviced while asleep.
Parameters
delay: Number Time in milliseconds to sleep. Set to -1 to sleep forever.

ejs.unix tempname(directory: String = null): File
Description
Create a temporary file. Creates a new, uniquely named temporary file.
Parameters
directory: String Directory in which to create the temp file. [default: null]
Returns
A closed File object after creating an empty temporary file.

toOrdinal(number: Number): String
Description
Convert a number to an ordinal string.
Parameters
number: Number To convert.
Returns
An ordinal string matching the number.

toPlural(word: String, count: Number = null): String
Description
Convert a singular word to its plural form.
Parameters
word: String Word to transform.
count: Number Set to a number greater than 1 to force a plural. [default: null]
Returns
The plural form of a word.

toSingular(word: String): String
Description
Convert a singular word to its plural form.
Parameters
word: String Plural word to transform.
Returns
The plural form of a word.

typeOf(o): String
Description
Return the name of a type. This is a fixed version of the standard "typeof" operator. It returns the real Ejscript underlying type name. This call is an alias for Object.getTypeName(o).
Parameters
o Object or value to examine.
Returns
A string type name.
Specified
ejscript-2.7

ejs.web unescapeHtml(s: String): String
Description
Transform an escaped string into its original contents. This reverses the transformation done by escapeHtml. It does this by changing ", >, < back into ", < and >.
Parameters
s: String Input string.
Returns
A transformed string.
Specified
ejscript-2.7
Stability
Prototype 8.