A8000
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.

20 lines
547 B

8 months ago
  1. /**
  2. * target source
  3. * @param source
  4. * @param target
  5. * @returns
  6. */
  7. export function fuzzyMatchBySequence(source: string, target: string): boolean {
  8. const sourceLower = source.toLowerCase();
  9. const targetLower = target.toLowerCase();
  10. let i = 0;
  11. let j = 0;
  12. while (i < sourceLower.length && j < targetLower.length) {
  13. if (sourceLower[i] === targetLower[j]) {
  14. j++;
  15. }
  16. i++;
  17. }
  18. return j === targetLower.length;
  19. }