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.

26 lines
518 B

  1. "use strict";
  2. // Note that we take code points as JS numbers, not JS strings.
  3. function isASCIIDigit(c) {
  4. return c >= 0x30 && c <= 0x39;
  5. }
  6. function isASCIIAlpha(c) {
  7. return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A);
  8. }
  9. function isASCIIAlphanumeric(c) {
  10. return isASCIIAlpha(c) || isASCIIDigit(c);
  11. }
  12. function isASCIIHex(c) {
  13. return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66);
  14. }
  15. module.exports = {
  16. isASCIIDigit,
  17. isASCIIAlpha,
  18. isASCIIAlphanumeric,
  19. isASCIIHex
  20. };