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

unexpectedjs / unexpected-snapshot / 4281364852

pending completion
4281364852

push

github

GitHub
Update eslint to version 8.35.0

124 of 169 branches covered (73.37%)

Branch coverage included in aggregate %.

235 of 297 relevant lines covered (79.12%)

36.59 hits per line

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

100.0
/lib/isSimpleObjectTree.js
1
const expect = require('unexpected');
37✔
2

3
function isSimpleObjectTree(obj) {
4
  const seen = new Set();
26✔
5
  return (function isSimple(obj) {
26✔
6
    if (seen.has(obj)) {
79✔
7
      return false; // Circular
5✔
8
    } else {
9
      const type = expect.findTypeOf(obj);
74✔
10
      if (type.name === 'array') {
74✔
11
        seen.add(obj);
8✔
12
        const result = obj.every(isSimple);
8✔
13
        seen.delete(obj);
8✔
14
        return result;
8✔
15
      } else if (type.name === 'object') {
66✔
16
        seen.add(obj);
22✔
17
        const result =
18
          obj.constructor === Object &&
22✔
19
          Object.getOwnPropertyNames(obj).every((name) =>
20
            isSimple(obj[name])
31✔
21
          ) &&
22
          Object.getOwnPropertySymbols(obj).length === 0;
23
        seen.delete(obj);
22✔
24
        return result;
22✔
25
      } else {
26
        return [
44✔
27
          'any',
28
          'number',
29
          'NaN',
30
          'boolean',
31
          'regexp',
32
          'null',
33
          'undefined',
34
          'string',
35
          'Buffer',
36
          'date',
37
        ].includes(type.name);
38
      }
39
    }
40
  })(obj);
41
}
42

43
module.exports = isSimpleObjectTree;
37✔
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