0.0.3 • Published 12 years ago
inlinify v0.0.3
inlinify
Preprocesses JavaScript functions so that they can be inlined as macros.
Example
var inline = require("inlinify")
//Preprocess a function for inlining
var inline_block = inline(
function(local_arg0, local_arg1) {
var s = local_arg0 + local_arg1
this.potato = s
console.log("s = ", s)
return s * 10
}, "inline_prefix_", ["arg0", "arg1"])
//Retrieve variables
console.log(inline_block.variables)
console.log(inline_block.this_variables)
console.log(inline_block.return_variable)
console.log(body)require("inlinify")(func, prefix, args)
Preprocesses func so that it can be inlined into a block of code.
funcis the function to inlineprefixis a string which is used to relabel all the variables in func to avoid conflictsargsis the list of arguments forfunc
Returns An object with the following properties:
variablesa list of the local variables in functhis_variablesa list of variables in thethisobject of the funcbodyan inlinable string representing the body of the functionreturn_variablethe name of the return variable for the function
Credits
(c) 2013 Mikola Lysenko. MIT License