Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Apr 15, 2022
1 parent 075c7ff commit ed16c9f
Showing 1 changed file with 19 additions and 0 deletions.
@@ -0,0 +1,19 @@
/**
* Create a code check from a regex.
*
* @param {RegExp} regex
* @returns {(code: Code) => code is number}
*/
function regexCheck(regex) {
return check

/**
* Check whether a code matches the bound regex.
*
* @param {Code} code Character code
* @returns {code is number} Whether the character code matches the bound regex
*/
function check(code) {
return code !== null && regex.test(String.fromCharCode(code))
}
}

0 comments on commit ed16c9f

Please sign in to comment.