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

u-wave / core / 11980470338

22 Nov 2024 09:32PM UTC coverage: 78.436% (-1.7%) from 80.16%
11980470338

Pull #637

github

goto-bus-stop
explicitly store UTC in sqlite
Pull Request #637: Switch to a relational database

757 of 915 branches covered (82.73%)

Branch coverage included in aggregate %.

1977 of 2768 new or added lines in 52 files covered. (71.42%)

9 existing lines in 7 files now uncovered.

8653 of 11082 relevant lines covered (78.08%)

70.79 hits per line

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

8.89
/src/utils/Multimap.js
1
/**
1✔
2
 * A map with multiple values per key.
1✔
3
 *
1✔
4
 * @template K
1✔
5
 * @template T
1✔
6
 */
1✔
7
export default class Multimap {
1!
NEW
8
  /** @type {Map<K, T[]>} */
×
NEW
9
  #map = new Map();
×
NEW
10

×
NEW
11
  /**
×
NEW
12
   * Return true if the given key exists in the map.
×
NEW
13
   *
×
NEW
14
   * @param {K} key
×
NEW
15
   */
×
NEW
16
  has(key) {
×
NEW
17
    return this.#map.has(key);
×
NEW
18
  }
×
NEW
19

×
NEW
20
  /**
×
NEW
21
   * Get all values for a key.
×
NEW
22
   *
×
NEW
23
   * @param {K} key
×
NEW
24
   */
×
NEW
25
  get(key) {
×
NEW
26
    return this.#map.get(key);
×
NEW
27
  }
×
NEW
28

×
NEW
29
  /**
×
NEW
30
   * Add a key/value pair.
×
NEW
31
   *
×
NEW
32
   * @param {K} key
×
NEW
33
   * @param {T} value
×
NEW
34
   */
×
NEW
35
  set(key, value) {
×
NEW
36
    const existing = this.#map.get(key);
×
NEW
37
    if (existing) {
×
NEW
38
      existing.push(value);
×
NEW
39
    } else {
×
NEW
40
      this.#map.set(key, [value]);
×
NEW
41
    }
×
NEW
42
    return this;
×
NEW
43
  }
×
NEW
44

×
NEW
45
  /**
×
NEW
46
   * Delete all elements with a given key. Return true if any elements existed.
×
NEW
47
   *
×
NEW
48
   * @param {K} key
×
NEW
49
   */
×
NEW
50
  delete(key) {
×
NEW
51
    return this.#map.delete(key);
×
NEW
52
  }
×
NEW
53

×
NEW
54
  /**
×
NEW
55
   * Remove a specific element with a given key. Return true if it existed.
×
NEW
56
   *
×
NEW
57
   * @param {K} key
×
NEW
58
   * @param {T} value
×
NEW
59
   */
×
NEW
60
  remove(key, value) {
×
NEW
61
    const existing = this.#map.get(key);
×
NEW
62
    if (!existing) {
×
NEW
63
      return false;
×
NEW
64
    }
×
NEW
65

×
NEW
66
    // If this is the only element for the key, delete the whole key, so
×
NEW
67
    // we never have empty keys.
×
NEW
68
    if (existing.length === 1 && existing[0] === value) {
×
NEW
69
      return this.#map.delete(key);
×
NEW
70
    }
×
NEW
71

×
NEW
72
    const index = existing.indexOf(value);
×
NEW
73
    if (index === -1) {
×
NEW
74
      return false;
×
NEW
75
    }
×
NEW
76
    existing.splice(index, 1);
×
NEW
77
    return true;
×
NEW
78
  }
×
NEW
79

×
NEW
80
  /** Iterate over the keys in the map. */
×
NEW
81
  keys() {
×
NEW
82
    return this.#map.keys();
×
NEW
83
  }
×
NEW
84

×
NEW
85
  [Symbol.iterator]() {
×
NEW
86
    return this.#map.entries();
×
NEW
87
  }
×
NEW
88
}
×
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