Renames functions calls, but leaves function definitions unchanged.
var code = [
'function log(s) { console.error(s); }'
, 'function print(s) { console.log(s); }'
, 'print(\'hello\');'
, 'log(\'world\');'
].join('\n')
var rename = require('rename-function-call');
var renamed = rename('log', 'print', code)
console.log(renamed);function log(s) { console.error(s); }
function print(s) { console.log(s); }
print('hello');
print('world');
npm install rename-function-calls
-
Replaces every function call named
fromwith another one that is namedto.rename(src, 'log', 'print'); // => log(x) becomes print(x)
Name Type Description origSrcstring the original source
fromNamestring name under which function is currently called
toNamestring name to which the function calls should be renamed
source with function calls renamed
- Type
- string
generated with docme
MIT
