Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

commentHandler.js 852B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import esquery from 'esquery';
  2. import {
  3. visitorKeys as jsdocTypePrattParserVisitorKeys
  4. } from 'jsdoc-type-pratt-parser';
  5. import {
  6. commentParserToESTree, jsdocVisitorKeys
  7. } from './commentParserToESTree.js';
  8. /**
  9. * @callback CommentHandler
  10. * @param {string} commentSelector
  11. * @param {Node} jsdoc
  12. * @returns {boolean}
  13. */
  14. /**
  15. * @param {Settings} settings
  16. * @returns {CommentHandler}
  17. */
  18. const commentHandler = (settings) => {
  19. /**
  20. * @type {CommentHandler}
  21. */
  22. return (commentSelector, jsdoc) => {
  23. const {mode} = settings;
  24. const selector = esquery.parse(commentSelector);
  25. const ast = commentParserToESTree(jsdoc, mode);
  26. return esquery.matches(ast, selector, null, {
  27. visitorKeys: {
  28. ...jsdocTypePrattParserVisitorKeys,
  29. ...jsdocVisitorKeys
  30. }
  31. });
  32. };
  33. };
  34. export default commentHandler;