Guest User

Untitled

a guest
Feb 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. const from = 'compose';
  2. const to = 'pipe';
  3.  
  4. export default (file, api) => {
  5. const j = api.jscodeshift;
  6. return j(file.source)
  7. .find(j.Identifier)
  8. .filter(i => i.value.name === from)
  9. .filter(i => i.parent.node.arguments)
  10. .forEach(i => {
  11. i.node.name = to;
  12. i.parent.node.arguments.reverse();
  13. })
  14. .toSource();
  15. };
Add Comment
Please, Sign In to add comment