inline-code
A library to help you inline code in JavaScript. It automatically handles arguments that contain references to this
or arguments that are complex and get used multiple times in the inlined function. This makes it really simple to use. It also supports using temporary variables in inline functions. If you start a variable with an _
it will be automatically defined for you and guaranteed not to conflict with the user's program. This is super useful.
If you return "expressions" they will be inlined perfectly. If you return "statements" it will be assumed that the statements should replace whatever the next statement up in the tree is. See the Array.prototype.slice.call inliner for an example of this.
Installation
npm install inline-code
Usage
input.js
var d = document;exportselement = document;exportsotherElement = d;exportsfirst = ;var foo = ;exportssecond = foo;exportsarr = foo;exportsmax = ; { var args = Arrayprototypeslice; return args;} { return Arrayprototypeslice;}exportssumFast = sumFast;exportssumSlow = sumSlow;
build.js
fs;
output.js
"use strict"; exportselement = "<div>"; exportsotherElement = "<div>"; exportsfirst = "first value" + "." + "second value"; exportssecond = "first value" + "." + "second value"; exportsarr = "a0" "b1" "c2" "d3" "end" ; exportsmax = Math; { var args = ; for var _i_0 = 0; _i_0 < argumentslength; _i_0++ args; return args;} { return Arrayprototypeslice;} exportssumFast = sumFast; exportssumSlow = sumSlow;
License
MIT