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

yext / search-ui-react / 7147201737

08 Dec 2023 11:06PM UTC coverage: 85.159% (-0.8%) from 85.921%
7147201737

push

github

web-flow
Version 1.4.0 (#411)

### Changes
- Added compatibility with PagesJS v1 (#400, #402, #404)
### Fixes
- Upgraded `@babel/traverse` version to address a vulnerability in the package (#409)

1283 of 1683 branches covered (0.0%)

Branch coverage included in aggregate %.

122 of 122 new or added lines in 69 files covered. (100.0%)

1 existing line in 1 file now uncovered.

1850 of 1996 relevant lines covered (92.69%)

136.93 hits per line

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

0.0
/src/utils/arrayutils.tsx
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2

3
type MapFunction = (element: any, index: number) => any;
4

5
/**
6
 * Reduces an array into an object consisting of groups. The keys of the object indicate the groups
7
 * and the values hold an array of elements which are in that group. Mapping functions can be specified
8
 * which determine the key and the value for the element. An initial object may be optionally specified.
9
 *
10
 * @param arr - array to be grouped
11
 * @param keyMap - Mapping function that evaluates what key to give an array element.
12
 * @param valueMap - Mapping function that evaluates what value to give an array element.
13
 * @param intitial - the initial object to add to, defaulting to \{\}
14
 */
UNCOV
15
export function mapArrayToObject(
×
16
  arr: Array<any>,
17
  keyMap: MapFunction = (key: any) => key,
×
18
  valueMap: MapFunction = (value: any) => value,
×
19
  initial: Record<any, any> = {}
×
20
): Record<any, any> {
21
  return arr.reduce((groups, element, idx) => {
×
22
    const key = keyMap(element, idx);
×
23
    const value = valueMap(element, idx);
×
24
    if (!groups[key]) {
×
25
      groups[key] = [value];
×
26
    } else {
27
      groups[key].push(value);
×
28
    }
29
    return groups;
×
30
  }, initial);
31
}
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