UNPKG

badge-urls

Version:

Helper functions to generate URLs for all badges / shields from shields.io

13 lines (12 loc) 639 B
const A = "A".charCodeAt(0); const Z = "Z".charCodeAt(0); const a = "a".charCodeAt(0); const z = "z".charCodeAt(0); const zero = "0".charCodeAt(0); const nine = "9".charCodeAt(0); const isInRange = (n, min, max) => n >= min && n <= max; export const isUpperCaseLatin = (s, n = 0) => isInRange(s.charCodeAt(n), A, Z); export const isLowerCaseLatin = (s, n = 0) => isInRange(s.charCodeAt(n), a, z); export const isNumber = (s, n = 0) => isInRange(s.charCodeAt(n), zero, nine); export const isLatin = (s, n = 0) => isLowerCaseLatin(s, n) || isUpperCaseLatin(s, n); export const isAlphaNumeric = (s, n = 0) => isNumber(s, n) || isLatin(s, n);