node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »


funlinify Build Status

Inline javascript functions within a file (inline expansion).

How it works ?

The algorithm is pretty simple at this moment.

  • Search all CallExpressions.
    • Search if the function body is reachable (same file/ast)
    • Prefix all variable arguments with a unique hash
    • Replace ReturnExpression in the function by an AssignamentExpression(=) and break till the end of the function body.
    • Replace the CallExpression with the given return variable.
    • Append argument conversion before the CallExpression
    • Append function before the CallExpression

It's pretty straight forward, don't do anything fancy. So is no error prone.


  • Do not support nested CallExpressions (just one will be replaced)
  • Do not inline functions outside given 'file/string/ast'
  • Do not inline functions with expressions as arguments.


Browserify transform

output_stream = fs.createWriteStream('debug/js-2dmath-browser-debug.js');


var file_contents = require("fs").fileReadSync("your-file.js");
require("funlinify")(file_contents, {}, callback(err, new_file_contents));