added util functions for checking if arrays (sorted and unsorted) are equal

This commit is contained in:
Miodec 2022-10-17 12:32:18 +02:00
parent 7a678a2cdf
commit d5ae0466bb

View file

@ -1251,3 +1251,11 @@ export function isPasswordStrong(password: string): boolean {
const isLong = password.length >= 8;
return hasCapital && hasNumber && hasSpecial && isLong;
}
export function areUnsortedArraysEqual<T>(a: T[], b: T[]): boolean {
return a.length === b.length && a.every((v) => b.includes(v));
}
export function areSortedArraysEqual<T>(a: T[], b: T[]): boolean {
return a.length === b.length && a.every((v, i) => v === b[i]);
}