JSPP

0.1.2 • Public • Published

JSPP

JSPP is a preprocessor for JavaScript.

How to use

  1. require 'JSPP':
var jspp = require('JSPP');
  1. create a preprocessor object:
var pp = jspp.create({falses: ['_debug'], donts: ['_assert'], minify: true});
  1. preprocess your JavaScript code:
sys.puts(pp.preprocess(jscode));  

Options

You can use the following options when creating a preprocessor object:

  • trues: variable_name_list
    Variables in variable_name_list are replaced with 'true'.
    if the code becomes redundant because of this replacement, JSPP optimize it.
    For example, if { trues: ['x.a'] } is given,
if (x.a || x.b) {
    y = x;
} else {
    y = null;
}

is optimized like:

y = x;
  • falses: variable_name_list
    Variables in variable_name_list are replaced with 'false'.
    if the code becomes redundant because of this replacement, JSPP optimize it.
    For example, if { falses: ['_debug'] } is given,
if (_debug) {
    ......
}

is removed.

  • donts: func_name_list
    Function calls are removed if the functions are listed in func_name_list.
    For exmaple, if { donts: ['_assert'] } is given,
_assert(...);

is removed.

  • minify: boolean
    JSPP provides code minification by using UglifyJS.

  • calc: boolean
    if { calc: true } is given, JSPP automatically calculates operations between immediate values.

Readme

Keywords

none

Package Sidebar

Install

npm i JSPP

Weekly Downloads

2

Version

0.1.2

License

none

Last publish

Collaborators

  • schrodingerz-kitten