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

xjdesigns / HelpingHand / 8837538075

25 Apr 2024 06:23PM UTC coverage: 90.196% (-1.1%) from 91.304%
8837538075

push

github

web-flow
Merge pull request #6 from xjdesigns/Additions0422

Additions0422

65 of 72 branches covered (90.28%)

Branch coverage included in aggregate %.

40 of 43 new or added lines in 3 files covered. (93.02%)

119 of 132 relevant lines covered (90.15%)

6.28 hits per line

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

62.5
/src/functionUtils.ts
1
/**
2
 * Remap an arrays object keys
3
 *
4
 * ```ts
5
 * import { remapData } from 'helping_hand'
6
 * const remappedData = remapData(...);
7
 * ```
8
 * @category Data Utility
9
 * 
10
 * @example
11
 * This will remap the name key to firstname
12
 * ```ts
13
 * const data = [
14
 *  {
15
 *    name: 'Jason'
16
 *  }
17
 * ]
18
 * const dataMap = {
19
 *   firstname: 'name'
20
 * }
21
 * 
22
 * const remappedData = remapData(data, dataMap);
23
 * ```
24
 *
25
 */
26
export function remapData (data: {}[], dataMap: {}): {}[] {
27
  return data.map(d => {
2✔
28
    const mapped = {}
4✔
29
    for (const key in dataMap) {
4✔
30
      mapped[key] = d[dataMap[key]]
6✔
31
    }
32
    return mapped
4✔
33
  })
34
}
35

36
/**
37
 * Joins additional data to the provided data set
38
 *
39
 * ```ts
40
 * import { remapData } from 'helping_hand'
41
 * const remappedData = remapData(...);
42
 * ```
43
 * @category Data Utility
44
 * 
45
 * @example
46
 * This will remap the name key to firstname
47
 * ```ts
48
 * const data = [
49
 *  {
50
 *    name: 'Jason'
51
 *  }
52
 * ]
53
 * const dataMap = {
54
 *   firstname: 'name'
55
 * }
56
 * 
57
 * const remappedData = remapData(data, dataMap);
58
 * ```
59
 *
60
 */
61
export function addDataKeys (data: {}[], additionalData: {}): {}[] {
NEW
62
  return data.map(d => {
×
NEW
63
    const mapped = { ...d, ...additionalData }
×
NEW
64
    return mapped
×
65
  })
66
}
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