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.

functionArgumentsSearch.js 1005B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. const balancedMatch = require('balanced-match');
  3. const styleSearch = require('style-search');
  4. /**
  5. * Search a CSS string for functions by name.
  6. * For every match, invoke the callback, passing the function's
  7. * "argument(s) string" (whatever is inside the parentheses)
  8. * as an argument.
  9. *
  10. * Callback will be called once for every matching function found,
  11. * with the function's "argument(s) string" and its starting index
  12. * as the arguments.
  13. *
  14. * @param {string} source
  15. * @param {string} functionName
  16. * @param {Function} callback
  17. */
  18. module.exports = function (source, functionName, callback) {
  19. styleSearch(
  20. {
  21. source,
  22. target: functionName,
  23. functionNames: 'check',
  24. },
  25. (match) => {
  26. if (source[match.endIndex] !== '(') {
  27. return;
  28. }
  29. const parensMatch = balancedMatch('(', ')', source.substr(match.startIndex));
  30. if (!parensMatch) {
  31. throw new Error(`No parens match: "${source}"`);
  32. }
  33. callback(parensMatch.body, match.endIndex + 1);
  34. },
  35. );
  36. };