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

visgl / loaders.gl / 20352515932

18 Dec 2025 09:56PM UTC coverage: 35.115% (-28.4%) from 63.485%
20352515932

push

github

web-flow
feat(loader-utils): Export is-type helpers (#3258)

1188 of 1998 branches covered (59.46%)

Branch coverage included in aggregate %.

147 of 211 new or added lines in 13 files covered. (69.67%)

30011 existing lines in 424 files now uncovered.

37457 of 108056 relevant lines covered (34.66%)

0.79 hits per line

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

29.17
/modules/json/src/lib/json-parser/json-parser.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
// @ts-nocheck
1✔
6

1✔
7
import ClarinetParser, {ClarinetParserOptions} from '../clarinet/clarinet';
1✔
8
import JSONPath from '../jsonpath/jsonpath';
1✔
9

1✔
10
// JSONParser builds a JSON object using the events emitted by the Clarinet parser
1✔
11

1✔
12
export default class JSONParser {
1✔
13
  readonly parser: ClarinetParser;
1!
UNCOV
14
  result = undefined;
×
UNCOV
15
  previousStates = [];
×
UNCOV
16
  currentState = Object.freeze({container: [], key: null});
×
UNCOV
17
  jsonpath: JSONPath = new JSONPath();
×
18

1✔
19
  constructor(options: ClarinetParserOptions) {
1✔
UNCOV
20
    this.reset();
×
UNCOV
21
    this.parser = new ClarinetParser({
×
UNCOV
22
      onready: () => {
×
UNCOV
23
        this.jsonpath = new JSONPath();
×
UNCOV
24
        this.previousStates.length = 0;
×
UNCOV
25
        this.currentState.container.length = 0;
×
UNCOV
26
      },
×
UNCOV
27

×
UNCOV
28
      onopenobject: (name) => {
×
UNCOV
29
        this._openObject({});
×
UNCOV
30
        if (typeof name !== 'undefined') {
×
UNCOV
31
          this.parser.emit('onkey', name);
×
UNCOV
32
        }
×
UNCOV
33
      },
×
UNCOV
34

×
UNCOV
35
      onkey: (name) => {
×
UNCOV
36
        this.jsonpath.set(name);
×
UNCOV
37
        this.currentState.key = name;
×
UNCOV
38
      },
×
UNCOV
39

×
UNCOV
40
      oncloseobject: () => {
×
UNCOV
41
        this._closeObject();
×
UNCOV
42
      },
×
UNCOV
43

×
UNCOV
44
      onopenarray: () => {
×
UNCOV
45
        this._openArray();
×
UNCOV
46
      },
×
UNCOV
47

×
UNCOV
48
      onclosearray: () => {
×
UNCOV
49
        this._closeArray();
×
UNCOV
50
      },
×
UNCOV
51

×
UNCOV
52
      onvalue: (value) => {
×
UNCOV
53
        this._pushOrSet(value);
×
UNCOV
54
      },
×
UNCOV
55

×
UNCOV
56
      onerror: (error) => {
×
57
        throw error;
×
58
      },
×
UNCOV
59

×
UNCOV
60
      onend: () => {
×
UNCOV
61
        this.result = this.currentState.container.pop();
×
UNCOV
62
      },
×
UNCOV
63

×
UNCOV
64
      ...options
×
UNCOV
65
    });
×
UNCOV
66
  }
×
67

1✔
68
  reset(): void {
1✔
UNCOV
69
    this.result = undefined;
×
UNCOV
70
    this.previousStates = [];
×
UNCOV
71
    this.currentState = Object.freeze({container: [], key: null});
×
UNCOV
72
    this.jsonpath = new JSONPath();
×
UNCOV
73
  }
×
74

1✔
75
  write(chunk): void {
1✔
UNCOV
76
    this.parser.write(chunk);
×
UNCOV
77
  }
×
78

1✔
79
  close(): void {
1✔
UNCOV
80
    this.parser.close();
×
UNCOV
81
  }
×
82

1✔
83
  // PRIVATE METHODS
1✔
84

1✔
85
  _pushOrSet(value): void {
1✔
UNCOV
86
    const {container, key} = this.currentState;
×
UNCOV
87
    if (key !== null) {
×
UNCOV
88
      container[key] = value;
×
UNCOV
89
      this.currentState.key = null;
×
UNCOV
90
    } else {
×
UNCOV
91
      container.push(value);
×
UNCOV
92
    }
×
UNCOV
93
  }
×
94

1✔
95
  _openArray(newContainer = []): void {
1✔
UNCOV
96
    this.jsonpath.push(null);
×
UNCOV
97
    this._pushOrSet(newContainer);
×
UNCOV
98
    this.previousStates.push(this.currentState);
×
UNCOV
99
    this.currentState = {container: newContainer, isArray: true, key: null};
×
UNCOV
100
  }
×
101

1✔
102
  _closeArray(): void {
1✔
UNCOV
103
    this.jsonpath.pop();
×
UNCOV
104
    this.currentState = this.previousStates.pop();
×
UNCOV
105
  }
×
106

1✔
107
  _openObject(newContainer = {}): void {
1✔
UNCOV
108
    this.jsonpath.push(null);
×
UNCOV
109
    this._pushOrSet(newContainer);
×
UNCOV
110
    this.previousStates.push(this.currentState);
×
UNCOV
111
    this.currentState = {container: newContainer, isArray: false, key: null};
×
UNCOV
112
  }
×
113

1✔
114
  _closeObject(): void {
1✔
UNCOV
115
    this.jsonpath.pop();
×
UNCOV
116
    this.currentState = this.previousStates.pop();
×
UNCOV
117
  }
×
118
}
1✔
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

© 2026 Coveralls, Inc