transform-deps

2.0.0 • Public • Published

transform-deps

parse the ast and transform require() calls.

example

var transform = require('transform-deps');
var src = "require('x'); require('y');"
src = transform(src, function (name) {
    if (name == 'x') return 'z';
});
console.log(src);

outputs:

require('z'); require('y')

api

var transform = require('transform-deps')

var str = transform(src[, opts], cb)

Transforms the string source src with the function cb, returning transformed string str.

opts are:

  • asString: Returns a plain string instead of falafel output (default: true)
  • ignoreTryCatch: Skips try/catch statements (default: false)

All of the opts will be passed to falafel.

license

mit

Package Sidebar

Install

npm i transform-deps

Weekly Downloads

1

Version

2.0.0

License

MIT

Last publish

Collaborators

  • tetsuo