@loaders.gl/json 3.4.13 → 3.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/geojson-loader.js +34 -103
- package/dist/es5/geojson-loader.js.map +1 -1
- package/dist/es5/index.js +7 -7
- package/dist/es5/json-loader.js +22 -33
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/clarinet/clarinet.js +295 -318
- package/dist/es5/lib/clarinet/clarinet.js.map +1 -1
- package/dist/es5/lib/jsonpath/jsonpath.js +44 -88
- package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -1
- package/dist/es5/lib/parse-json-in-batches.js +74 -181
- package/dist/es5/lib/parse-json-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-json.js +4 -7
- package/dist/es5/lib/parse-json.js.map +1 -1
- package/dist/es5/lib/parse-ndjson-in-batches.js +29 -103
- package/dist/es5/lib/parse-ndjson-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-ndjson.js +2 -2
- package/dist/es5/lib/parse-ndjson.js.map +1 -1
- package/dist/es5/lib/parser/json-parser.js +84 -106
- package/dist/es5/lib/parser/json-parser.js.map +1 -1
- package/dist/es5/lib/parser/streaming-json-parser.js +52 -95
- package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -1
- package/dist/es5/ndgeoson-loader.js +5 -23
- package/dist/es5/ndgeoson-loader.js.map +1 -1
- package/dist/es5/ndjson-loader.js +3 -21
- package/dist/es5/ndjson-loader.js.map +1 -1
- package/dist/esm/geojson-loader.js +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/ndgeoson-loader.js +1 -1
- package/dist/esm/ndjson-loader.js +1 -1
- package/dist/geojson-worker.js +1 -1
- package/package.json +5 -5
|
@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
9
|
var _clarinet = _interopRequireDefault(require("../clarinet/clarinet"));
|
|
12
10
|
var _jsonpath = _interopRequireDefault(require("../jsonpath/jsonpath"));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var JSONParser = function () {
|
|
16
|
-
function JSONParser(options) {
|
|
17
|
-
var _this = this;
|
|
18
|
-
(0, _classCallCheck2.default)(this, JSONParser);
|
|
11
|
+
class JSONParser {
|
|
12
|
+
constructor(options) {
|
|
19
13
|
(0, _defineProperty2.default)(this, "parser", void 0);
|
|
20
14
|
(0, _defineProperty2.default)(this, "result", undefined);
|
|
21
15
|
(0, _defineProperty2.default)(this, "previousStates", []);
|
|
@@ -25,116 +19,100 @@ var JSONParser = function () {
|
|
|
25
19
|
}));
|
|
26
20
|
(0, _defineProperty2.default)(this, "jsonpath", new _jsonpath.default());
|
|
27
21
|
this.reset();
|
|
28
|
-
this.parser = new _clarinet.default(
|
|
29
|
-
onready:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
this.parser = new _clarinet.default({
|
|
23
|
+
onready: () => {
|
|
24
|
+
this.jsonpath = new _jsonpath.default();
|
|
25
|
+
this.previousStates.length = 0;
|
|
26
|
+
this.currentState.container.length = 0;
|
|
33
27
|
},
|
|
34
|
-
onopenobject:
|
|
35
|
-
|
|
28
|
+
onopenobject: name => {
|
|
29
|
+
this._openObject({});
|
|
36
30
|
if (typeof name !== 'undefined') {
|
|
37
|
-
|
|
31
|
+
this.parser.emit('onkey', name);
|
|
38
32
|
}
|
|
39
33
|
},
|
|
40
|
-
onkey:
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
onkey: name => {
|
|
35
|
+
this.jsonpath.set(name);
|
|
36
|
+
this.currentState.key = name;
|
|
43
37
|
},
|
|
44
|
-
oncloseobject:
|
|
45
|
-
|
|
38
|
+
oncloseobject: () => {
|
|
39
|
+
this._closeObject();
|
|
46
40
|
},
|
|
47
|
-
onopenarray:
|
|
48
|
-
|
|
41
|
+
onopenarray: () => {
|
|
42
|
+
this._openArray();
|
|
49
43
|
},
|
|
50
|
-
onclosearray:
|
|
51
|
-
|
|
44
|
+
onclosearray: () => {
|
|
45
|
+
this._closeArray();
|
|
52
46
|
},
|
|
53
|
-
onvalue:
|
|
54
|
-
|
|
47
|
+
onvalue: value => {
|
|
48
|
+
this._pushOrSet(value);
|
|
55
49
|
},
|
|
56
|
-
onerror:
|
|
50
|
+
onerror: error => {
|
|
57
51
|
throw error;
|
|
58
52
|
},
|
|
59
|
-
onend:
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
53
|
+
onend: () => {
|
|
54
|
+
this.result = this.currentState.container.pop();
|
|
55
|
+
},
|
|
56
|
+
...options
|
|
57
|
+
});
|
|
63
58
|
}
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
container = _this$currentState.container,
|
|
90
|
-
key = _this$currentState.key;
|
|
91
|
-
if (key !== null) {
|
|
92
|
-
container[key] = value;
|
|
93
|
-
this.currentState.key = null;
|
|
94
|
-
} else {
|
|
95
|
-
container.push(value);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "_openArray",
|
|
100
|
-
value: function _openArray() {
|
|
101
|
-
var newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
102
|
-
this.jsonpath.push(null);
|
|
103
|
-
this._pushOrSet(newContainer);
|
|
104
|
-
this.previousStates.push(this.currentState);
|
|
105
|
-
this.currentState = {
|
|
106
|
-
container: newContainer,
|
|
107
|
-
isArray: true,
|
|
108
|
-
key: null
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "_closeArray",
|
|
113
|
-
value: function _closeArray() {
|
|
114
|
-
this.jsonpath.pop();
|
|
115
|
-
this.currentState = this.previousStates.pop();
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "_openObject",
|
|
119
|
-
value: function _openObject() {
|
|
120
|
-
var newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
121
|
-
this.jsonpath.push(null);
|
|
122
|
-
this._pushOrSet(newContainer);
|
|
123
|
-
this.previousStates.push(this.currentState);
|
|
124
|
-
this.currentState = {
|
|
125
|
-
container: newContainer,
|
|
126
|
-
isArray: false,
|
|
127
|
-
key: null
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "_closeObject",
|
|
132
|
-
value: function _closeObject() {
|
|
133
|
-
this.jsonpath.pop();
|
|
134
|
-
this.currentState = this.previousStates.pop();
|
|
59
|
+
reset() {
|
|
60
|
+
this.result = undefined;
|
|
61
|
+
this.previousStates = [];
|
|
62
|
+
this.currentState = Object.freeze({
|
|
63
|
+
container: [],
|
|
64
|
+
key: null
|
|
65
|
+
});
|
|
66
|
+
this.jsonpath = new _jsonpath.default();
|
|
67
|
+
}
|
|
68
|
+
write(chunk) {
|
|
69
|
+
this.parser.write(chunk);
|
|
70
|
+
}
|
|
71
|
+
close() {
|
|
72
|
+
this.parser.close();
|
|
73
|
+
}
|
|
74
|
+
_pushOrSet(value) {
|
|
75
|
+
const {
|
|
76
|
+
container,
|
|
77
|
+
key
|
|
78
|
+
} = this.currentState;
|
|
79
|
+
if (key !== null) {
|
|
80
|
+
container[key] = value;
|
|
81
|
+
this.currentState.key = null;
|
|
82
|
+
} else {
|
|
83
|
+
container.push(value);
|
|
135
84
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
85
|
+
}
|
|
86
|
+
_openArray() {
|
|
87
|
+
let newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
88
|
+
this.jsonpath.push(null);
|
|
89
|
+
this._pushOrSet(newContainer);
|
|
90
|
+
this.previousStates.push(this.currentState);
|
|
91
|
+
this.currentState = {
|
|
92
|
+
container: newContainer,
|
|
93
|
+
isArray: true,
|
|
94
|
+
key: null
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
_closeArray() {
|
|
98
|
+
this.jsonpath.pop();
|
|
99
|
+
this.currentState = this.previousStates.pop();
|
|
100
|
+
}
|
|
101
|
+
_openObject() {
|
|
102
|
+
let newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
103
|
+
this.jsonpath.push(null);
|
|
104
|
+
this._pushOrSet(newContainer);
|
|
105
|
+
this.previousStates.push(this.currentState);
|
|
106
|
+
this.currentState = {
|
|
107
|
+
container: newContainer,
|
|
108
|
+
isArray: false,
|
|
109
|
+
key: null
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
_closeObject() {
|
|
113
|
+
this.jsonpath.pop();
|
|
114
|
+
this.currentState = this.previousStates.pop();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
139
117
|
exports.default = JSONParser;
|
|
140
118
|
//# sourceMappingURL=json-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-parser.js","names":["_clarinet","_interopRequireDefault","require","_jsonpath","
|
|
1
|
+
{"version":3,"file":"json-parser.js","names":["_clarinet","_interopRequireDefault","require","_jsonpath","JSONParser","constructor","options","_defineProperty2","default","undefined","Object","freeze","container","key","JSONPath","reset","parser","ClarinetParser","onready","jsonpath","previousStates","length","currentState","onopenobject","name","_openObject","emit","onkey","set","oncloseobject","_closeObject","onopenarray","_openArray","onclosearray","_closeArray","onvalue","value","_pushOrSet","onerror","error","onend","result","pop","write","chunk","close","push","newContainer","arguments","isArray","exports"],"sources":["../../../../src/lib/parser/json-parser.ts"],"sourcesContent":["// @ts-nocheck\n\nimport ClarinetParser, {ClarinetParserOptions} from '../clarinet/clarinet';\nimport JSONPath from '../jsonpath/jsonpath';\n\n// JSONParser builds a JSON object using the events emitted by the Clarinet parser\n\nexport default class JSONParser {\n readonly parser: ClarinetParser;\n result = undefined;\n previousStates = [];\n currentState = Object.freeze({container: [], key: null});\n jsonpath: JSONPath = new JSONPath();\n\n constructor(options: ClarinetParserOptions) {\n this.reset();\n this.parser = new ClarinetParser({\n onready: () => {\n this.jsonpath = new JSONPath();\n this.previousStates.length = 0;\n this.currentState.container.length = 0;\n },\n\n onopenobject: (name) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n },\n\n onkey: (name) => {\n this.jsonpath.set(name);\n this.currentState.key = name;\n },\n\n oncloseobject: () => {\n this._closeObject();\n },\n\n onopenarray: () => {\n this._openArray();\n },\n\n onclosearray: () => {\n this._closeArray();\n },\n\n onvalue: (value) => {\n this._pushOrSet(value);\n },\n\n onerror: (error) => {\n throw error;\n },\n\n onend: () => {\n this.result = this.currentState.container.pop();\n },\n\n ...options\n });\n }\n\n reset(): void {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({container: [], key: null});\n this.jsonpath = new JSONPath();\n }\n\n write(chunk): void {\n this.parser.write(chunk);\n }\n\n close(): void {\n this.parser.close();\n }\n\n // PRIVATE METHODS\n\n _pushOrSet(value): void {\n const {container, key} = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n } else {\n container.push(value);\n }\n }\n\n _openArray(newContainer = []): void {\n this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: true, key: null};\n }\n\n _closeArray(): void {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n\n _openObject(newContainer = {}): void {\n this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: false, key: null};\n }\n\n _closeObject(): void {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n}\n"],"mappings":";;;;;;;;AAEA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIe,MAAME,UAAU,CAAC;EAO9BC,WAAWA,CAACC,OAA8B,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,kBALnCC,SAAS;IAAA,IAAAF,gBAAA,CAAAC,OAAA,0BACD,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACJE,MAAM,CAACC,MAAM,CAAC;MAACC,SAAS,EAAE,EAAE;MAAEC,GAAG,EAAE;IAAI,CAAC,CAAC;IAAA,IAAAN,gBAAA,CAAAC,OAAA,oBACnC,IAAIM,iBAAQ,CAAC,CAAC;IAGjC,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAI,CAACC,MAAM,GAAG,IAAIC,iBAAc,CAAC;MAC/BC,OAAO,EAAEA,CAAA,KAAM;QACb,IAAI,CAACC,QAAQ,GAAG,IAAIL,iBAAQ,CAAC,CAAC;QAC9B,IAAI,CAACM,cAAc,CAACC,MAAM,GAAG,CAAC;QAC9B,IAAI,CAACC,YAAY,CAACV,SAAS,CAACS,MAAM,GAAG,CAAC;MACxC,CAAC;MAEDE,YAAY,EAAGC,IAAI,IAAK;QACtB,IAAI,CAACC,WAAW,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,OAAOD,IAAI,KAAK,WAAW,EAAE;UAC/B,IAAI,CAACR,MAAM,CAACU,IAAI,CAAC,OAAO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G;MAACV,SAAS,EAAEmC,YAAY;MAAEE,OAAO,EAAE,KAAK;MAAEpC,GAAG,EAAE;IAAI,CAAC;EAC1E;EAEAiB,YAAYA,CAAA,EAAS;IACnB,IAAI,CAACX,QAAQ,CAACuB,GAAG,CAAC,CAAC;IACnB,IAAI,CAACpB,YAAY,GAAG,IAAI,CAACF,cAAc,CAACsB,GAAG,CAAC,CAAC;EAC/C;AACF;AAACQ,OAAA,CAAA1C,OAAA,GAAAJ,UAAA"}
|
|
@@ -5,119 +5,76 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
9
|
var _jsonParser = _interopRequireDefault(require("./json-parser"));
|
|
18
10
|
var _jsonpath = _interopRequireDefault(require("../jsonpath/jsonpath"));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
-
(0, _classCallCheck2.default)(this, StreamingJSONParser);
|
|
31
|
-
_this = _super.call(this, {
|
|
32
|
-
onopenarray: function onopenarray() {
|
|
33
|
-
if (!_this.streamingArray) {
|
|
34
|
-
if (_this._matchJSONPath()) {
|
|
35
|
-
_this.streamingJsonPath = _this.getJsonPath().clone();
|
|
36
|
-
_this.streamingArray = [];
|
|
37
|
-
_this._openArray(_this.streamingArray);
|
|
11
|
+
class StreamingJSONParser extends _jsonParser.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
|
+
super({
|
|
15
|
+
onopenarray: () => {
|
|
16
|
+
if (!this.streamingArray) {
|
|
17
|
+
if (this._matchJSONPath()) {
|
|
18
|
+
this.streamingJsonPath = this.getJsonPath().clone();
|
|
19
|
+
this.streamingArray = [];
|
|
20
|
+
this._openArray(this.streamingArray);
|
|
38
21
|
return;
|
|
39
22
|
}
|
|
40
23
|
}
|
|
41
|
-
|
|
24
|
+
this._openArray();
|
|
42
25
|
},
|
|
43
|
-
onopenobject:
|
|
44
|
-
if (!
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
onopenobject: name => {
|
|
27
|
+
if (!this.topLevelObject) {
|
|
28
|
+
this.topLevelObject = {};
|
|
29
|
+
this._openObject(this.topLevelObject);
|
|
47
30
|
} else {
|
|
48
|
-
|
|
31
|
+
this._openObject({});
|
|
49
32
|
}
|
|
50
33
|
if (typeof name !== 'undefined') {
|
|
51
|
-
|
|
34
|
+
this.parser.emit('onkey', name);
|
|
52
35
|
}
|
|
53
36
|
}
|
|
54
37
|
});
|
|
55
|
-
(0, _defineProperty2.default)(
|
|
56
|
-
(0, _defineProperty2.default)(
|
|
57
|
-
(0, _defineProperty2.default)(
|
|
58
|
-
(0, _defineProperty2.default)(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return new _jsonpath.default(jsonpath);
|
|
62
|
-
});
|
|
63
|
-
return _this;
|
|
38
|
+
(0, _defineProperty2.default)(this, "jsonPaths", void 0);
|
|
39
|
+
(0, _defineProperty2.default)(this, "streamingJsonPath", null);
|
|
40
|
+
(0, _defineProperty2.default)(this, "streamingArray", null);
|
|
41
|
+
(0, _defineProperty2.default)(this, "topLevelObject", null);
|
|
42
|
+
const jsonpaths = options.jsonpaths || [];
|
|
43
|
+
this.jsonPaths = jsonpaths.map(jsonpath => new _jsonpath.default(jsonpath));
|
|
64
44
|
}
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
array = (0, _toConsumableArray2.default)(this.streamingArray);
|
|
72
|
-
this.streamingArray.length = 0;
|
|
73
|
-
}
|
|
74
|
-
return array;
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "getPartialResult",
|
|
78
|
-
value: function getPartialResult() {
|
|
79
|
-
return this.topLevelObject;
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "getStreamingJsonPath",
|
|
83
|
-
value: function getStreamingJsonPath() {
|
|
84
|
-
return this.streamingJsonPath;
|
|
45
|
+
write(chunk) {
|
|
46
|
+
super.write(chunk);
|
|
47
|
+
let array = [];
|
|
48
|
+
if (this.streamingArray) {
|
|
49
|
+
array = [...this.streamingArray];
|
|
50
|
+
this.streamingArray.length = 0;
|
|
85
51
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
52
|
+
return array;
|
|
53
|
+
}
|
|
54
|
+
getPartialResult() {
|
|
55
|
+
return this.topLevelObject;
|
|
56
|
+
}
|
|
57
|
+
getStreamingJsonPath() {
|
|
58
|
+
return this.streamingJsonPath;
|
|
59
|
+
}
|
|
60
|
+
getStreamingJsonPathAsString() {
|
|
61
|
+
return this.streamingJsonPath && this.streamingJsonPath.toString();
|
|
62
|
+
}
|
|
63
|
+
getJsonPath() {
|
|
64
|
+
return this.jsonpath;
|
|
65
|
+
}
|
|
66
|
+
_matchJSONPath() {
|
|
67
|
+
const currentPath = this.getJsonPath();
|
|
68
|
+
if (this.jsonPaths.length === 0) {
|
|
69
|
+
return true;
|
|
95
70
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
value: function _matchJSONPath() {
|
|
99
|
-
var currentPath = this.getJsonPath();
|
|
100
|
-
if (this.jsonPaths.length === 0) {
|
|
71
|
+
for (const jsonPath of this.jsonPaths) {
|
|
72
|
+
if (jsonPath.equals(currentPath)) {
|
|
101
73
|
return true;
|
|
102
74
|
}
|
|
103
|
-
var _iterator = _createForOfIteratorHelper(this.jsonPaths),
|
|
104
|
-
_step;
|
|
105
|
-
try {
|
|
106
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
107
|
-
var jsonPath = _step.value;
|
|
108
|
-
if (jsonPath.equals(currentPath)) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
} catch (err) {
|
|
113
|
-
_iterator.e(err);
|
|
114
|
-
} finally {
|
|
115
|
-
_iterator.f();
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
75
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
122
79
|
exports.default = StreamingJSONParser;
|
|
123
80
|
//# sourceMappingURL=streaming-json-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming-json-parser.js","names":["_jsonParser","_interopRequireDefault","require","_jsonpath","
|
|
1
|
+
{"version":3,"file":"streaming-json-parser.js","names":["_jsonParser","_interopRequireDefault","require","_jsonpath","StreamingJSONParser","JSONParser","constructor","options","arguments","length","undefined","onopenarray","streamingArray","_matchJSONPath","streamingJsonPath","getJsonPath","clone","_openArray","onopenobject","name","topLevelObject","_openObject","parser","emit","_defineProperty2","default","jsonpaths","jsonPaths","map","jsonpath","JSONPath","write","chunk","array","getPartialResult","getStreamingJsonPath","getStreamingJsonPathAsString","toString","currentPath","jsonPath","equals","exports"],"sources":["../../../../src/lib/parser/streaming-json-parser.ts"],"sourcesContent":["import {default as JSONParser} from './json-parser';\nimport JSONPath from '../jsonpath/jsonpath';\n\n/**\n * The `StreamingJSONParser` looks for the first array in the JSON structure.\n * and emits an array of chunks\n */\nexport default class StreamingJSONParser extends JSONParser {\n private jsonPaths: JSONPath[];\n private streamingJsonPath: JSONPath | null = null;\n private streamingArray: any[] | null = null;\n private topLevelObject: object | null = null;\n\n constructor(options: {[key: string]: any} = {}) {\n super({\n onopenarray: () => {\n if (!this.streamingArray) {\n if (this._matchJSONPath()) {\n // @ts-ignore\n this.streamingJsonPath = this.getJsonPath().clone();\n this.streamingArray = [];\n this._openArray(this.streamingArray as []);\n return;\n }\n }\n\n this._openArray();\n },\n\n // Redefine onopenarray to inject value for top-level object\n onopenobject: (name) => {\n if (!this.topLevelObject) {\n this.topLevelObject = {};\n this._openObject(this.topLevelObject);\n } else {\n this._openObject({});\n }\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n }\n });\n const jsonpaths = options.jsonpaths || [];\n this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));\n }\n\n /**\n * write REDEFINITION\n * - super.write() chunk to parser\n * - get the contents (so far) of \"topmost-level\" array as batch of rows\n * - clear top-level array\n * - return the batch of rows\\\n */\n write(chunk) {\n super.write(chunk);\n let array: any[] = [];\n if (this.streamingArray) {\n array = [...this.streamingArray];\n this.streamingArray.length = 0;\n }\n return array;\n }\n\n /**\n * Returns a partially formed result object\n * Useful for returning the \"wrapper\" object when array is not top level\n * e.g. GeoJSON\n */\n getPartialResult() {\n return this.topLevelObject;\n }\n\n getStreamingJsonPath() {\n return this.streamingJsonPath;\n }\n\n getStreamingJsonPathAsString() {\n return this.streamingJsonPath && this.streamingJsonPath.toString();\n }\n\n getJsonPath() {\n return this.jsonpath;\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks is this.getJsonPath matches the jsonpaths provided in options\n */\n _matchJSONPath() {\n const currentPath = this.getJsonPath();\n // console.debug(`Testing JSONPath`, currentPath);\n\n // Backwards compatibility, match any array\n // TODO implement using wildcard once that is supported\n if (this.jsonPaths.length === 0) {\n return true;\n }\n\n for (const jsonPath of this.jsonPaths) {\n if (jsonPath.equals(currentPath)) {\n return true;\n }\n }\n\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AAMe,MAAME,mBAAmB,SAASC,mBAAU,CAAC;EAM1DC,WAAWA,CAAA,EAAqC;IAAA,IAApCC,OAA6B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC5C,KAAK,CAAC;MACJG,WAAW,EAAEA,CAAA,KAAM;QACjB,IAAI,CAAC,IAAI,CAACC,cAAc,EAAE;UACxB,IAAI,IAAI,CAACC,cAAc,CAAC,CAAC,EAAE;YAEzB,IAAI,CAACC,iBAAiB,GAAG,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC;YACnD,IAAI,CAACJ,cAAc,GAAG,EAAE;YACxB,IAAI,CAACK,UAAU,CAAC,IAAI,CAACL,cAAoB,CAAC;YAC1C;UACF;QACF;QAEA,IAAI,CAACK,UAAU,CAAC,CAAC;MACnB,CAAC;MAGDC,YAAY,EAAGC,IAAI,IAAK;QACtB,IAAI,CAAC,IAAI,CAACC,cAAc,EAAE;UACxB,IAAI,CAACA,cAAc,GAAG,CAAC,CAAC;UACxB,IAAI,CAACC,WAAW,CAAC,IAAI,CAACD,cAAc,CAAC;QACvC,CAAC,MAAM;UACL,IAAI,CAACC,WAAW,CAAC,CAAC,CAAC,CAAC;QACtB;QACA,I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E;MAC/B,OAAO,IAAI;IACb;IAEA,KAAK,MAAM8B,QAAQ,IAAI,IAAI,CAACZ,SAAS,EAAE;MACrC,IAAIY,QAAQ,CAACC,MAAM,CAACF,WAAW,CAAC,EAAE;QAChC,OAAO,IAAI;MACb;IACF;IAEA,OAAO,KAAK;EACd;AACF;AAACG,OAAA,CAAAhB,OAAA,GAAArB,mBAAA"}
|
|
@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports._typecheckNDJSONLoader = exports.NDJSONLoader = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
8
|
var _parseNdjson = _interopRequireDefault(require("./lib/parse-ndjson"));
|
|
11
9
|
var _parseNdjsonInBatches = _interopRequireDefault(require("./lib/parse-ndjson-in-batches"));
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : 'latest';
|
|
11
|
+
const DEFAULT_NDGEOJSON_LOADER_OPTIONS = {
|
|
14
12
|
geojson: {
|
|
15
13
|
shape: 'object-row-table'
|
|
16
14
|
},
|
|
@@ -18,7 +16,7 @@ var DEFAULT_NDGEOJSON_LOADER_OPTIONS = {
|
|
|
18
16
|
format: 'geojson'
|
|
19
17
|
}
|
|
20
18
|
};
|
|
21
|
-
|
|
19
|
+
const NDJSONLoader = {
|
|
22
20
|
name: 'NDJSON',
|
|
23
21
|
id: 'ndjson',
|
|
24
22
|
module: 'json',
|
|
@@ -27,28 +25,12 @@ var NDJSONLoader = {
|
|
|
27
25
|
mimeTypes: ['application/geo+x-ndjson', 'application/geo+x-ldjson', 'application/jsonlines', 'application/geo+json-seq', 'application/x-ndjson'],
|
|
28
26
|
category: 'table',
|
|
29
27
|
text: true,
|
|
30
|
-
parse:
|
|
31
|
-
var _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer) {
|
|
32
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
33
|
-
while (1) switch (_context.prev = _context.next) {
|
|
34
|
-
case 0:
|
|
35
|
-
return _context.abrupt("return", (0, _parseNdjson.default)(new TextDecoder().decode(arrayBuffer)));
|
|
36
|
-
case 1:
|
|
37
|
-
case "end":
|
|
38
|
-
return _context.stop();
|
|
39
|
-
}
|
|
40
|
-
}, _callee);
|
|
41
|
-
}));
|
|
42
|
-
function parse(_x) {
|
|
43
|
-
return _parse.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
return parse;
|
|
46
|
-
}(),
|
|
28
|
+
parse: async arrayBuffer => (0, _parseNdjson.default)(new TextDecoder().decode(arrayBuffer)),
|
|
47
29
|
parseTextSync: _parseNdjson.default,
|
|
48
30
|
parseInBatches: _parseNdjsonInBatches.default,
|
|
49
31
|
options: DEFAULT_NDGEOJSON_LOADER_OPTIONS
|
|
50
32
|
};
|
|
51
33
|
exports.NDJSONLoader = NDJSONLoader;
|
|
52
|
-
|
|
34
|
+
const _typecheckNDJSONLoader = NDJSONLoader;
|
|
53
35
|
exports._typecheckNDJSONLoader = _typecheckNDJSONLoader;
|
|
54
36
|
//# sourceMappingURL=ndgeoson-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ndgeoson-loader.js","names":["_parseNdjson","_interopRequireDefault","require","_parseNdjsonInBatches","VERSION","DEFAULT_NDGEOJSON_LOADER_OPTIONS","geojson","shape","gis","format","NDJSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","
|
|
1
|
+
{"version":3,"file":"ndgeoson-loader.js","names":["_parseNdjson","_interopRequireDefault","require","_parseNdjsonInBatches","VERSION","DEFAULT_NDGEOJSON_LOADER_OPTIONS","geojson","shape","gis","format","NDJSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","arrayBuffer","parseNDJSONSync","TextDecoder","decode","parseTextSync","parseInBatches","parseNDJSONInBatches","options","exports","_typecheckNDJSONLoader"],"sources":["../../src/ndgeoson-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseNDJSONSync from './lib/parse-ndjson';\nimport parseNDJSONInBatches from './lib/parse-ndjson-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type NDGeoJSONLoaderOptions = LoaderOptions & {\n geojson?: {\n shape?: 'object-row-table';\n };\n gis?: {\n format: 'geojson';\n };\n};\n\nconst DEFAULT_NDGEOJSON_LOADER_OPTIONS = {\n geojson: {\n shape: 'object-row-table'\n },\n gis: {\n format: 'geojson'\n }\n};\n\nexport const NDJSONLoader = {\n name: 'NDJSON',\n id: 'ndjson',\n module: 'json',\n version: VERSION,\n extensions: ['ndjson', 'ndgeojson'],\n mimeTypes: [\n 'application/geo+x-ndjson',\n 'application/geo+x-ldjson',\n 'application/jsonlines', // https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html#cm-batch\n 'application/geo+json-seq',\n 'application/x-ndjson'\n ],\n category: 'table',\n text: true,\n parse: async (arrayBuffer: ArrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),\n parseTextSync: parseNDJSONSync,\n parseInBatches: parseNDJSONInBatches,\n options: DEFAULT_NDGEOJSON_LOADER_OPTIONS\n};\n\nexport const _typecheckNDJSONLoader: LoaderWithParser = NDJSONLoader;\n"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA,MAAME,OAAO,GAAG,eAAkB,KAAK,WAAW,cAAiB,QAAQ;AAW3E,MAAMC,gCAAgC,GAAG;EACvCC,OAAO,EAAE;IACPC,KAAK,EAAE;EACT,CAAC;EACDC,GAAG,EAAE;IACHC,MAAM,EAAE;EACV;AACF,CAAC;AAEM,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEV,OAAO;EAChBW,UAAU,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;EACnCC,SAAS,EAAE,CACT,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,CACvB;EACDC,QAAQ,EAAE,OAAO;EACjBC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE,MAAOC,WAAwB,IAAK,IAAAC,oBAAe,EAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC,CAAC;EACjGI,aAAa,EAAEH,oBAAe;EAC9BI,cAAc,EAAEC,6BAAoB;EACpCC,OAAO,EAAEtB;AACX,CAAC;AAACuB,OAAA,CAAAlB,YAAA,GAAAA,YAAA;AAEK,MAAMmB,sBAAwC,GAAGnB,YAAY;AAACkB,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
|
|
@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.NDJSONLoader = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
8
|
var _parseNdjson = _interopRequireDefault(require("./lib/parse-ndjson"));
|
|
11
9
|
var _parseNdjsonInBatches = _interopRequireDefault(require("./lib/parse-ndjson-in-batches"));
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : 'latest';
|
|
11
|
+
const NDJSONLoader = {
|
|
14
12
|
name: 'NDJSON',
|
|
15
13
|
id: 'ndjson',
|
|
16
14
|
module: 'json',
|
|
@@ -19,23 +17,7 @@ var NDJSONLoader = {
|
|
|
19
17
|
mimeTypes: ['application/x-ndjson', 'application/jsonlines', 'application/json-seq'],
|
|
20
18
|
category: 'table',
|
|
21
19
|
text: true,
|
|
22
|
-
parse:
|
|
23
|
-
var _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer) {
|
|
24
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
25
|
-
while (1) switch (_context.prev = _context.next) {
|
|
26
|
-
case 0:
|
|
27
|
-
return _context.abrupt("return", (0, _parseNdjson.default)(new TextDecoder().decode(arrayBuffer)));
|
|
28
|
-
case 1:
|
|
29
|
-
case "end":
|
|
30
|
-
return _context.stop();
|
|
31
|
-
}
|
|
32
|
-
}, _callee);
|
|
33
|
-
}));
|
|
34
|
-
function parse(_x) {
|
|
35
|
-
return _parse.apply(this, arguments);
|
|
36
|
-
}
|
|
37
|
-
return parse;
|
|
38
|
-
}(),
|
|
20
|
+
parse: async arrayBuffer => (0, _parseNdjson.default)(new TextDecoder().decode(arrayBuffer)),
|
|
39
21
|
parseTextSync: _parseNdjson.default,
|
|
40
22
|
parseInBatches: _parseNdjsonInBatches.default,
|
|
41
23
|
options: {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ndjson-loader.js","names":["_parseNdjson","_interopRequireDefault","require","_parseNdjsonInBatches","VERSION","NDJSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","
|
|
1
|
+
{"version":3,"file":"ndjson-loader.js","names":["_parseNdjson","_interopRequireDefault","require","_parseNdjsonInBatches","VERSION","NDJSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","arrayBuffer","parseNDJSONSync","TextDecoder","decode","parseTextSync","parseInBatches","parseNDJSONInBatches","options","exports"],"sources":["../../src/ndjson-loader.ts"],"sourcesContent":["import parseNDJSONSync from './lib/parse-ndjson';\nimport parseNDJSONInBatches from './lib/parse-ndjson-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport const NDJSONLoader = {\n name: 'NDJSON',\n id: 'ndjson',\n module: 'json',\n version: VERSION,\n extensions: ['ndjson', 'jsonl'],\n mimeTypes: [\n 'application/x-ndjson',\n 'application/jsonlines', // https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html#cm-batch\n 'application/json-seq'\n ],\n category: 'table',\n text: true,\n parse: async (arrayBuffer: ArrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),\n parseTextSync: parseNDJSONSync,\n parseInBatches: parseNDJSONInBatches,\n options: {}\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA,MAAME,OAAO,GAAG,eAAkB,KAAK,WAAW,cAAiB,QAAQ;AAEpE,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC/BC,SAAS,EAAE,CACT,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,CACvB;EACDC,QAAQ,EAAE,OAAO;EACjBC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE,MAAOC,WAAwB,IAAK,IAAAC,oBAAe,EAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC,CAAC;EACjGI,aAAa,EAAEH,oBAAe;EAC9BI,cAAc,EAAEC,6BAAoB;EACpCC,OAAO,EAAE,CAAC;AACZ,CAAC;AAACC,OAAA,CAAAlB,YAAA,GAAAA,YAAA"}
|