one.js 415 B

123456789101112131415161718192021
  1. 'use strict';
  2. module.exports = one;
  3. function one(node, parent) {
  4. var self = this;
  5. var visitors = self.visitors;
  6. /* Fail on unknown nodes. */
  7. if (typeof visitors[node.type] !== 'function') {
  8. self.file.fail(
  9. new Error(
  10. 'Missing compiler for node of type `' +
  11. node.type + '`: `' + node + '`'
  12. ),
  13. node
  14. );
  15. }
  16. return visitors[node.type].call(self, node, parent);
  17. }