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.

31 lines
549 B

import { Item, InnerList } from './types';
const asciiRe = /^[\x20-\x7E]*$/;
const tokenRe = /^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/;
const keyRe = /^[a-z*][*\-_.a-z0-9]*$/;
export function isAscii(str: string): boolean {
return asciiRe.test(str);
}
export function isValidTokenStr(str: string): boolean {
return tokenRe.test(str);
}
export function isValidKeyStr(str: string): boolean {
return keyRe.test(str);
}
export function isInnerList(input: Item | InnerList): input is InnerList {
return Array.isArray(input[0]);
}