Simplify sequenceOfCombiningMarks function, and add return type

This commit is contained in:
Matthew Lilley 2018-05-10 10:38:33 +01:00
parent c02e794b0d
commit 29225c3588
1 changed files with 7 additions and 11 deletions

View File

@ -151,17 +151,13 @@ function inAllowedSets(validationString: string) {
);
}
function sequenceOfCombiningMarks(validationString: string) {
const characters: string[] = Array.from(validationString);
for (let i = 0; i < characters.length; i++) {
if (
nonSpacingMark.test(characters[i]) &&
nonSpacingMark.test(characters[i + 1])
) {
return true;
}
continue;
}
function sequenceOfCombiningMarks(validationString: string): boolean {
return Array.from(validationString).some((character, index) => {
return (
nonSpacingMark.test(character) &&
nonSpacingMark.test(validationString[index + 1])
);
});
}
export function validate(validationString: string): boolean {