Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/rename-function-calls
Renames function calls, but leaves function definitions unchanged.
https://github.com/thlorenz/rename-function-calls
Last synced: 15 days ago
JSON representation
Renames function calls, but leaves function definitions unchanged.
- Host: GitHub
- URL: https://github.com/thlorenz/rename-function-calls
- Owner: thlorenz
- License: mit
- Created: 2014-02-25T22:37:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-23T12:25:12.000Z (over 7 years ago)
- Last Synced: 2024-05-08T17:30:46.307Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 196 KB
- Stars: 6
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rename-function-calls [![build status](https://secure.travis-ci.org/thlorenz/rename-function-calls.png)](http://travis-ci.org/thlorenz/rename-function-calls)
Renames functions calls, but leaves function definitions unchanged.
```js
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');
```
## Installationnpm install rename-function-calls
## API
rename(origSrc, fromName, toName) → {string}Replaces every function call named
from
with another one that is namedto
.Example
rename(src, 'log', 'print');
// => log(x) becomes print(x)Parameters:
Name
Type
Description
origSrc
string
the original source
fromName
string
name under which function is currently called
toName
string
name to which the function calls should be renamed
Returns:
source with function calls renamed
Type
string*generated with [docme](https://github.com/thlorenz/docme)*
## License
MIT