• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

deriv-com / deriv-com-v2 / 7326480845

26 Dec 2023 04:09AM CUT coverage: 84.692%. First build
7326480845

Pull #287

github

jia-deriv
chore: update

Signed-off-by: jia-deriv <jiawei@regentmarkets.com>
Pull Request #287: Testing

205 of 272 branches covered (0.0%)

Branch coverage included in aggregate %.

7524 of 8854 relevant lines covered (84.98%)

3.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.69
/libs/utils/src/lib/utils.ts
1
import { closestMatch, distance } from 'closest-match';
1✔
2

1✔
3
export function utils(): string {
1✔
4
  return 'utils';
1✔
5
}
1✔
6

1✔
7
export const searchString = (
1✔
8
  query: string,
×
9
  items: string[],
×
10
  maxDistance = 2,
×
11
) => {
×
12
  const matches = closestMatch(query, items, true);
×
13
  const finalMatches: string[] = [];
×
14

×
15
  if (Array.isArray(matches)) {
×
16
    matches.forEach((match) => {
×
17
      let lowestDistance = 10;
×
18
      let stringExist = false;
×
19

×
20
      match.split(' ').forEach((m) => {
×
21
        const dist = distance(query, m);
×
22

×
23
        if (lowestDistance > dist) {
×
24
          lowestDistance = dist;
×
25
        }
×
26

×
27
        if (m.toLowerCase().includes(query.toLowerCase())) {
×
28
          stringExist = true;
×
29
        }
×
30
      });
×
31

×
32
      if (
×
33
        lowestDistance <= maxDistance ||
×
34
        stringExist ||
×
35
        match.toLowerCase().includes(query.toLowerCase())
×
36
      ) {
×
37
        finalMatches.push(match);
×
38
      }
×
39
    });
×
40

×
41
    // Merge other exact matches inside the string
×
42
    const otherMatches = items.filter((e) =>
×
43
      e.toLowerCase().includes(query.toLowerCase()),
×
44
    );
×
45

×
46
    return Array.from(new Set(otherMatches.concat(finalMatches)));
×
47
  }
×
48

×
49
  return [];
×
50
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc