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

gmaclennan / rpc-reflector / 4495159168

pending completion
4495159168

push

github

GitHub
fix: specify missing pump dep (#13)

181 of 193 branches covered (93.78%)

Branch coverage included in aggregate %.

317 of 326 relevant lines covered (97.24%)

242.02 hits per line

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

100.0
/lib/prop-array-utils.js
1
// A "propArray" is an array that expresses nested props, e.g.
2
// myTarget.thing.method() would be expressed as ['thing', 'method']. These
3
// parse and stringify functions are used for encoding the event name with the
4
// method they apply to, because we need to use a single event emitter to
5
// simulate multiple event emitters (because every method and submethod on our
6
// proxied API is an event emitter) to avoid memory leaks
7

8
module.exports = {
5✔
9
  stringify,
10
  parse,
11
  isStringArray,
12
}
13

14
/**
15
 * @param {string[]} propArray
16
 * @param {string} eventName
17
 * @returns {string}
18
 */
19
function stringify(propArray, eventName) {
20
  return JSON.stringify([propArray, eventName])
80✔
21
}
22

23
/**
24
 * @param {string} string
25
 * @returns {[string[], string]}
26
 */
27
function parse(string) {
28
  const parsed = JSON.parse(string)
21✔
29
  if (!Array.isArray(parsed) || parsed.length !== 2) {
21✔
30
    throw new SyntaxError('Cannot parse, invalid string')
3✔
31
  }
32
  const [propArray, eventName] = parsed
18✔
33
  if (!isStringArray(propArray)) {
18✔
34
    throw new SyntaxError('Cannot parse, invalid propArray')
3✔
35
  }
36
  if (typeof eventName !== 'string') {
15✔
37
    throw new SyntaxError('Cannot parse, invalid event name')
2✔
38
  }
39
  return [propArray, eventName]
13✔
40
}
41

42
/**
43
 * @param {unknown} maybeStringArray
44
 * @return {maybeStringArray is string[]}
45
 */
46
function isStringArray(maybeStringArray) {
47
  return (
212✔
48
    Array.isArray(maybeStringArray) &&
381✔
49
    maybeStringArray.every((item) => typeof item === 'string')
144✔
50
  )
51
}
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