keyword.js 418 B

12345678910111213141516
  1. var falafel = require('../');
  2. var src = 'console.log(beep "boop", "BOOP");';
  3. function isKeyword (id) {
  4. if (id === 'beep') return true;
  5. }
  6. var output = falafel(src, { isKeyword: isKeyword }, function (node) {
  7. if (node.type === 'UnaryExpression'
  8. && node.operator === 'beep') {
  9. node.update(
  10. 'String(' + node.argument.source() + ').toUpperCase()'
  11. );
  12. }
  13. });
  14. console.log(output);