characterClasses.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true,
  4. });
  5. exports.isDigit = isDigit;
  6. exports.isLetter = isLetter;
  7. exports.isNameContinue = isNameContinue;
  8. exports.isNameStart = isNameStart;
  9. exports.isWhiteSpace = isWhiteSpace;
  10. /**
  11. * ```
  12. * WhiteSpace ::
  13. * - "Horizontal Tab (U+0009)"
  14. * - "Space (U+0020)"
  15. * ```
  16. * @internal
  17. */
  18. function isWhiteSpace(code) {
  19. return code === 0x0009 || code === 0x0020;
  20. }
  21. /**
  22. * ```
  23. * Digit :: one of
  24. * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
  25. * ```
  26. * @internal
  27. */
  28. function isDigit(code) {
  29. return code >= 0x0030 && code <= 0x0039;
  30. }
  31. /**
  32. * ```
  33. * Letter :: one of
  34. * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
  35. * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
  36. * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
  37. * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
  38. * ```
  39. * @internal
  40. */
  41. function isLetter(code) {
  42. return (
  43. (code >= 0x0061 && code <= 0x007a) || // A-Z
  44. (code >= 0x0041 && code <= 0x005a) // a-z
  45. );
  46. }
  47. /**
  48. * ```
  49. * NameStart ::
  50. * - Letter
  51. * - `_`
  52. * ```
  53. * @internal
  54. */
  55. function isNameStart(code) {
  56. return isLetter(code) || code === 0x005f;
  57. }
  58. /**
  59. * ```
  60. * NameContinue ::
  61. * - Letter
  62. * - Digit
  63. * - `_`
  64. * ```
  65. * @internal
  66. */
  67. function isNameContinue(code) {
  68. return isLetter(code) || isDigit(code) || code === 0x005f;
  69. }