util.js 885 B

1234567891011121314151617181920212223242526272829303132333435
  1. const unicode = require('../lib/unicode')
  2. module.exports = {
  3. isSpaceSeparator (c) {
  4. return typeof c === 'string' && unicode.Space_Separator.test(c)
  5. },
  6. isIdStartChar (c) {
  7. return typeof c === 'string' && (
  8. (c >= 'a' && c <= 'z') ||
  9. (c >= 'A' && c <= 'Z') ||
  10. (c === '$') || (c === '_') ||
  11. unicode.ID_Start.test(c)
  12. )
  13. },
  14. isIdContinueChar (c) {
  15. return typeof c === 'string' && (
  16. (c >= 'a' && c <= 'z') ||
  17. (c >= 'A' && c <= 'Z') ||
  18. (c >= '0' && c <= '9') ||
  19. (c === '$') || (c === '_') ||
  20. (c === '\u200C') || (c === '\u200D') ||
  21. unicode.ID_Continue.test(c)
  22. )
  23. },
  24. isDigit (c) {
  25. return typeof c === 'string' && /[0-9]/.test(c)
  26. },
  27. isHexDigit (c) {
  28. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
  29. },
  30. }