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 | ASC | Boolean | Conditional compilation constant. Used to disable compilation of certain elements. |
intrinsic const | boolean | Type | Alias for the Boolean type. |
public | CONFIG | Namespace | The CONFIG namespace used to defined conditional compilation directives. |
intrinsic const | DEPRECATED | Boolean | Conditional compilation constant. Used to deprecate elements. |
intrinsic const | DOC_ONLY | Boolean | Conditional compilation constant. Used to enable the compilation of elements only for creating the API documentation. |
intrinsic const | double | Type | Alias for the Number type. |
intrinsic const | false | Boolean | Boolean false value. |
intrinsic const | FUTURE | Boolean | Conditional compilation constant. Used to disable compilation of certain elements. |
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 | num | Type | Alias for the Number type. |
public | public | Namespace | The public namespace used to make entities visible accross modules. |
intrinsic const | REGEXP | Boolean | Conditional compilation constant. Used to deprecate elements. |
ejs.web | sessions | Array of all sessions. | |
intrinsic const | string | Type | Alias for the String type. |
intrinsic const | TODO | Boolean | Conditional compilation constant. Used to disable compilation of certain elements. |
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): Boolean |
Assert a condition is true. | |
public | basename(path: String): Path |
Get the base name of a file. | |
intrinsic | breakpoint(): Void |
public | chdir(dir: Object): Void |
Change the current working directory. | |
intrinsic | cloneBase(klass: Type): Void |
Replace the base type of a type with an exact clone. | |
public | close(file: File, graceful: Boolean): Void |
Close the file and free up all associated resources. | |
public | cp(fromPath: String, toPath: String): Void |
Copy a file. | |
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 | error(args: Array): Void |
Write to the standard error. | |
public | exists(path: String): Boolean |
Does a file exist. | |
public | extension(path: String): String |
Get the file extension portion of the file name. | |
intrinsic | formatStack(): String |
Format the current call stack. | |
public | freeSpace(path: String): Number |
Return the free space in the file system. | |
intrinsic | hashcode(o: Object): Number |
Get the object's Unique hash id. | |
intrinsic | input(): String |
Read from the standard input. | |
intrinsic | instanceOf(obj: Object, target: Object): Boolean |
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): Array |
Get a list of files in a directory. | |
public | mkdir(path: String, permissions: Number): Void |
Make a new directory. | |
public | mv(fromFile: String, toFile: String): Void |
Rename a file. | |
public | open(path: String, mode: Number, permissions: Number): File |
Open or create a file. | |
intrinsic | output(args: Array): Void |
Print the arguments to the standard output with a new line appended. | |
intrinsic | parse(input: String, preferredType: Type): Object |
Parse a string and convert to a primitive type. | |
ejs.db | pluralize(name: String): String |
intrinsic | print(args: Array): Void |
Print the arguments to the standard output with a new line appended. | |
intrinsic | printHash(name: String, o: Object): Void |
intrinsic | printv(args: Array): Void |
Print variables for debugging. | |
public | pwd(): Path |
Get the current working directory. | |
public | read(file: File, count: Number): ByteArray |
Read data bytes from a file and return a byte array containing the data. | |
public | rm(path: String): Void |
Remove a file from the file system. | |
public | rmdir(path: String, recursive: Boolean): Void |
Removes a directory. | |
intrinsic | serialize(obj: Object, maxDepth: Number, all: Boolean, base: Boolean): String |
Encode an object as a string. | |
public | tempname(directory: String): File |
Create a temporary file. | |
intrinsic | typeOf(o): String |
Return the name of a type. | |
public | write(file: File, items: Array): Number |
Write data to the file. |
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.
- Returns
- True if the condition is.
- Specified
- Ejs-11.
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.
Change the current working directory.
- Parameters
dir: Object Directory String or path to change to
Replace the base type of a type with an exact clone.
- Parameters
klass: Type Class in which to replace the base class.
- Specified
- Ejs-11.
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
- 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
- Ejs-11.
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
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
- Ejs-11.
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.
Get the file extension portion of the file name.
- Parameters
path: String Filename path to examine
- Returns
- String containing the file extension.
Format the current call stack.
- Description
- Used for debugging and when creating exception objects.
- Specified
- Ejs-11.
Return the free space in the file system.
- Parameters
path: String
- Returns
- The number of 1M blocks (1024 * 1024 bytes) of free space in the file system.
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. 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.
Rename a file.
- Description
- If the new file name exists it is removed before the rename.
- Parameters
Throws
IOError: if the original file does not exist or cannot be renamed.
Open or create a file.
- Parameters
path: String Filename path to open mode: Number optional file access mode with values ored from: Read, Write, Append, Create, Open, Truncate. Defaults to Read. [default: Read] permissions: Number optional permissions. Defaults to App.permissions
- Returns
- A File object which implements the Stream interface.
Throws
IOError: if the path or file cannot be opened or 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
- Ejs-11.
Parse a string and convert to a primitive type.
- Parameters
preferredType: Type
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
- Ejs-11.
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
maxDepth: Number The depth to recurse when converting properties to literals. If set to zero, the depth is infinite. 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
- Ejs-11.
Create a temporary file.
- Description
- Creates a new, uniquely named temporary file.
- Parameters
directory: String Directory in which to create the temp file.
- 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
- Ejs-11.
Write data to the file.
- Description
- If the stream is in sync mode, the write call blocks until the underlying stream or endpoint absorbes all the data. If in async-mode, the call accepts whatever data can be accepted immediately and returns a count of the elements that have been written.
- Parameters
file: File Open file object previously opened via $open or $File items: Array The data argument can be ByteArrays, strings or Numbers. All other types will call serialize first before writing. Note that numbers will not be written in a cross platform manner. If that is required, use the BinaryStream class to write Numbers.
- Returns
- The number of bytes written.
Throws
IOError: if the file could not be written.