Global Functions and Variables
Global object containing all global functions and variables.
Properties
Qualifiers | Property | Type | Description |
---|---|---|---|
ejs.web | action | Namespace | Controller.es -- Ejscript Controller class as part of the MVC framework. Also contains control helpers for views. |
intrinsic const | boolean | Type | Alias for the Boolean type. |
intrinsic const | double | Type | Alias for the Number type. |
intrinsic const | false | Boolean | Boolean false value. |
intrinsic | global | Object | Global 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. |
intrinsic const | Infinity | Number | Infinity value. |
public | internal | Namespace | The internal namespace used to make entities visible within a single module only. |
public | intrinsic | Namespace | The intrinsic namespace used for entities that are part of and intrinsic to, the Ejscript platform. |
public | iterator | Namespace | The iterator namespace used to defined iterators. |
intrinsic const | NaN | Number | Invalid numeric value. If the numeric type is set to an integral type, the value is zero. |
intrinsic const | NegativeInfinity | Number | Negative infinity value. |
intrinsic const | null | Null | Null 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. |
intrinsic const | REGEXP | Boolean | Conditional compilation constant. Used to deprecate elements. |
ejs.sys.worker | self | Worker | Reference to the Worker object for use inside a worker script This is only present inside Worker scripts. |
ejs.web | sessions | Hash of all sessions. Held by the master interpreter. | |
intrinsic const | string | Type | Alias for the String type. |
intrinsic const | true | Boolean | True value. |
intrinsic const | undefined | Void | Undefined variable value. The undefined value is returned when testing for a property that has not been defined. |
ejs.web | view | View | Current view in the web framework. |
intrinsic const | void | Type | Void type value. This is an alias for Void. |
Global Methods
Qualifiers | Method |
---|---|
intrinsic | assert(condition: Boolean): Void |
Assert a condition is true. | |
public | basename(path: String): Path |
Get the base name of a file. | |
intrinsic | breakpoint(): Void |
Convenient way to trap to the debugger. | |
public | chdir(dir: Object): Void |
Change the current working directory. | |
public | chmod(path: String, perms: Number): Void |
Set the permissions of a file or directory. | |
public | cp(fromPath: String, toPath: String): Void |
Copy a file. | |
intrinsic | decodeURI(str: String): String |
Reverse www-url encoding on a string. | |
intrinsic | deserialize(obj: String): Object |
Convert a string into an object. | |
public | dirname(path: String): Path |
Get the directory name portion of a file. | |
intrinsic | dump(args: Array): Void |
Dump the contents of objects. | |
intrinsic | encodeURI(str: String): String |
Encode a string using www-url encoding. | |
intrinsic | error(args: Array): Void |
Write to the standard error. | |
intrinsic | escape(str: String): String |
HTML escape a string. | |
intrinsic | eval(script: String): Object |
Evaluate a script. | |
public | exists(path: String): Boolean |
Does a file exist. | |
ejs.sys.worker | exit(): Void |
Exit the worker This is only valid inside Worker scripts. | |
public | extension(path: String): String |
Get the file extension portion of the file name. | |
public | find(path: Object, glob: String, recurse: Boolean = true): Array |
Find matching files. | |
intrinsic | formatStack(): String |
Format the current call stack. | |
intrinsic | hashcode(o: Object): Number |
Get the object's Unique hash id. | |
intrinsic | input(): String |
Read from the standard input. | |
public | isDir(path: String): Boolean |
Is a file a directory. | |
intrinsic | load(file: String): Void |
Load a script or module. | |
public | ls(path: String = . , enumDirs: Boolean = false): Array |
Get a list of files in a directory. | |
intrinsic | md5(str: String): String |
Computed an MD5 sum of a string This function is prototype and may be renamed in a future release. | |
public | mkdir(path: String, permissions: Number = 493): Void |
Make a new directory. | |
public | mv(fromFile: String, toFile: String): Void |
Rename a file. | |
intrinsic | output(args: Array): Void |
Print the arguments to the standard output with a new line appended. | |
intrinsic | parse(str: String, preferredType: Type = null): Object |
Parse a string and convert to a primitive type. | |
ejs.sys.worker | postMessage(data: Object): Void |
Post a message to the Worker's parent. | |
intrinsic | print(args: Array): Void |
Print the arguments to the standard output with a new line appended. | |
public | pwd(): Path |
Get the current working directory. | |
public | rm(path: Path): Void |
Remove a file from the file system. | |
public | rmdir(path: Path, contents: Boolean = false): Void |
Removes a directory. | |
intrinsic | serialize(obj: Object, maxDepth: Number = 0 , all: Boolean = false , base: Boolean = false): String |
Encode an object as a string. | |
public | tempname(directory: String = null): File |
Create a temporary file. | |
intrinsic | typeOf(o): String |
Return the name of a type. |
Method Detail
Assert a condition is true.
- Description
- 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-1.1
Get the base name of a file.
- Description
- 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.
Convenient way to trap to the debugger.
Change the current working directory.
- Parameters
dir: Object Directory String or path to change to.
Reverse www-url encoding on a string.
- Parameters
str: String URL encoded string.
- Returns
- A decoded string.
Convert a string into an object.
- Description
- This will parse a string that has been encoded via serialize. It may contain nested objects and arrays. This is a static method.
- Parameters
obj: 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-1.1
Get the directory name portion of a file.
- Description
- 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.
Dump the contents of objects.
- Description
- Used for debugging, this routine serializes the objects and prints to the standard output.
- Parameters
args: Array Variable number of arguments of any type.
Encode a string using www-url encoding.
- Parameters
str: String URL encoded string.
- Returns
- An encoded string.
- Specified
- ejscript-1.1
Write to the standard error.
- Description
- This call writes the arguments to the standard error with a new line appended. It evaluates the arguments, converts the result to strings and prints the result to the standard error. Arguments are converted to strings by calling their toSource method.
- Parameters
args: Array Data to write.
- Specified
- ejscript-1.1
HTML escape a string.
- Description
- This quotes characters which would otherwise be interpreted as HTML directives.
- Parameters
str: String String to html escape.
- Returns
- A HTML escaped string.
- Specified
- ejscript-1.1
Evaluate a script.
- Description
- Not present in ejsvm.
- Parameters
script: String Script to evaluate.
- Returns
- The the script expression value.
Does a file exist.
- Description
- 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.
Exit the worker This is only valid inside Worker scripts.
- Specified
- ejscript-1.1
Get the file extension portion of the file name.
- Description
- 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 does not include "." as the first character.
Find matching files.
- Description
- Files are listed in a depth first order.
- Parameters
path: Object Starting path from which to find matching files. glob: String Glob style Pattern that files must match. This is similar to a ls() style pattern. recurse: Boolean Set to true to examine sub-directories. [default: true]
- Returns
- Return a list of matching files.
Format the current call stack.
- Description
- Used for debugging and when creating exception objects.
- Specified
- ejscript-1.1
Get the object's Unique hash id.
- Description
- All objects have a unique object hash.
- Returns
- This property accessor returns a long containing the object's unique hash identifier.
Read from the standard input.
- Description
- This call reads a line of input from the standard input.
- Returns
- A string containing the input. Returns null on EOF.
Is a file a directory.
- Description
- 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.
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.
Get a list of files in a directory.
- Description
- The returned array contains the base file name portion only.
- Parameters
path: String Directory path to enumerate. [default: . ] enumDirs: Boolean If set to true, then dirList will include sub-directories in the returned list of files. [default: false]
- Returns
- An Array of strings containing the filenames in the directory.
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
- ejscript-1.1
Make a new directory.
- Description
- 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.
Print the arguments to the standard output with a new line appended.
- Description
- 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-1.1
Post a message to the Worker's parent.
- Parameters
data: Object Data to pass to the worker's onmessage callback. This is only valid inside Worker scripts.
Print the arguments to the standard output with a new line appended.
- Description
- 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. This method invokes output as its implementation.
- Parameters
args: Array Variables to print.
- Specified
- ejscript-1.1
Get the current working directory.
- Returns
- A Path containing the current working directory.
Encode an object as a string.
- Description
- This function returns a literal string for the object and all its properties. If.
- Parameters
obj: Object Object to serialize. maxDepth: Number The depth to recurse when converting properties to literals. If set to zero, the depth is infinite. [default: 0 ] all: Boolean Encode non-enumerable and class fixture properties and functions. [default: false ] base: Boolean Encode base class properties. [default: false]
- Returns
- This function returns 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-1.1
Create a temporary file.
- Description
- 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.
Return the name of a type.
- Description
- This is a fixed version of the standard "typeof" operator. It returns the real Ejscript underlying type. This is implemented as a wrapper around Reflect(o).typeName.
- Parameters
o Object or value to examine.
- Returns
- A string type name. If the object to examine is a type object, then return the name of the base type. If the object is Object, then return null.
- Specified
- ejscript-1.1