Profound.js Directives

Profound.js Directives

Overview

Even though Node.js is coded as an interpreted language, meaning the developer does not explicitly compile the code, there is still a compilation process that takes place.

In fact, Node.js compiles JavaScript source code into native machine code instead of interpreting it in real time. This is one of the many reasons why Node.js applications generally perform and scale well.

The behind-the-scenes compilation happens on-the-fly whenever the code is executed for the first time. The code is not recompiled again unless the developer changes something in the source or the server is restarted.

Profound.js allows you to modify what code is compiled using compiler directives. Directives are processed by Profound.js before the source is passed to the Node.js compiler, so they can be used to include shared source files and to conditionally include or exclude blocks of code.

Directive Rules

  • Prefix - All directives start with a # sign.

  • Placement - Directives must start at the beginning of a source code line with no leading spaces.

  • One per line - Other than the directive itself and any parameters to the directive, no other information should appear on the line.

Available Directives

The following directives are available. Select a directive for its syntax, a description of its behavior, and examples.

Directive

Purpose

RPG Equivalent

Directive

Purpose

RPG Equivalent

#define

Defines a condition name for conditional compilation.

/DEFINE

#undefine

Removes a previously defined condition name.

/UNDEFINE

#if

Begins a conditional block; selects source lines when the condition is true.

/IF

#elseif

Tests another condition when the previous #if or #elseif was not satisfied.

/ELSEIF

#else

Selects source lines when the previous #if or #elseif was not satisfied.

/ELSE

#endif

Ends the most recent #if group.

/ENDIF

#eof

Tells the compiler to treat the current source file as ended.

/EOF

#include

Includes one Node.js source file within another.

/COPY, /INCLUDE


Related Pages