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

visgl / loaders.gl / 24112850045

08 Apr 2026 01:31AM UTC coverage: 35.137% (+0.003%) from 35.134%
24112850045

push

github

web-flow
chore: biome replaces eslint/prettier (#3349)

1225 of 2057 branches covered (59.55%)

Branch coverage included in aggregate %.

55 of 603 new or added lines in 172 files covered. (9.12%)

1 existing line in 1 file now uncovered.

39942 of 115105 relevant lines covered (34.7%)

0.77 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!
14
  result = undefined;
×
15
  previousStates = [];
×
16
  currentState = Object.freeze({container: [], key: null});
×
17
  jsonpath: JSONPath = new JSONPath();
×
18

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

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

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

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

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

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

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

×
NEW
56
      onerror: error => {
×
57
        throw error;
×
58
      },
×
59

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

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

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

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

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

1✔
83
  // PRIVATE METHODS
1✔
84

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

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

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

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

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