utils.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isValidFunctionLiteralChar = exports.isNumber = exports.isLetter = exports.isWhitespace = void 0;
  4. function isWhitespace(code) {
  5. // TODO: other whitespaces
  6. return 32 /* SPACE */ === code ||
  7. 9 /* TAB */ === code ||
  8. 10 /* LINE_FEED */ === code ||
  9. 13 /* CARRIAGE_RETURN */ === code;
  10. }
  11. exports.isWhitespace = isWhitespace;
  12. function isLetter(code) {
  13. return (code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */) || // A-Z
  14. (code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */) || // a-z
  15. code === 45 /* MINUS */ || // -
  16. code === 95 /* UNDER_LINE */; // _
  17. }
  18. exports.isLetter = isLetter;
  19. function isNumber(code) {
  20. return code >= 48 /* _0 */ && code <= 57 /* _9 */; // 0-9
  21. }
  22. exports.isNumber = isNumber;
  23. function isValidFunctionLiteralChar(code) {
  24. return isNumber(code) ||
  25. (code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */) ||
  26. (code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */) ||
  27. code === 95 /* UNDER_LINE */ ||
  28. code === 36 /* $ */;
  29. }
  30. exports.isValidFunctionLiteralChar = isValidFunctionLiteralChar;