@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.
Files changed (33) hide show
  1. package/dist/es5/bundle.js +1 -1
  2. package/dist/es5/bundle.js.map +1 -1
  3. package/dist/es5/geojson-loader.js +34 -103
  4. package/dist/es5/geojson-loader.js.map +1 -1
  5. package/dist/es5/index.js +7 -7
  6. package/dist/es5/json-loader.js +22 -33
  7. package/dist/es5/json-loader.js.map +1 -1
  8. package/dist/es5/lib/clarinet/clarinet.js +295 -318
  9. package/dist/es5/lib/clarinet/clarinet.js.map +1 -1
  10. package/dist/es5/lib/jsonpath/jsonpath.js +44 -88
  11. package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -1
  12. package/dist/es5/lib/parse-json-in-batches.js +74 -181
  13. package/dist/es5/lib/parse-json-in-batches.js.map +1 -1
  14. package/dist/es5/lib/parse-json.js +4 -7
  15. package/dist/es5/lib/parse-json.js.map +1 -1
  16. package/dist/es5/lib/parse-ndjson-in-batches.js +29 -103
  17. package/dist/es5/lib/parse-ndjson-in-batches.js.map +1 -1
  18. package/dist/es5/lib/parse-ndjson.js +2 -2
  19. package/dist/es5/lib/parse-ndjson.js.map +1 -1
  20. package/dist/es5/lib/parser/json-parser.js +84 -106
  21. package/dist/es5/lib/parser/json-parser.js.map +1 -1
  22. package/dist/es5/lib/parser/streaming-json-parser.js +52 -95
  23. package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -1
  24. package/dist/es5/ndgeoson-loader.js +5 -23
  25. package/dist/es5/ndgeoson-loader.js.map +1 -1
  26. package/dist/es5/ndjson-loader.js +3 -21
  27. package/dist/es5/ndjson-loader.js.map +1 -1
  28. package/dist/esm/geojson-loader.js +1 -1
  29. package/dist/esm/json-loader.js +1 -1
  30. package/dist/esm/ndgeoson-loader.js +1 -1
  31. package/dist/esm/ndjson-loader.js +1 -1
  32. package/dist/geojson-worker.js +1 -1
  33. 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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(_objectSpread({
29
- onready: function onready() {
30
- _this.jsonpath = new _jsonpath.default();
31
- _this.previousStates.length = 0;
32
- _this.currentState.container.length = 0;
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: function onopenobject(name) {
35
- _this._openObject({});
28
+ onopenobject: name => {
29
+ this._openObject({});
36
30
  if (typeof name !== 'undefined') {
37
- _this.parser.emit('onkey', name);
31
+ this.parser.emit('onkey', name);
38
32
  }
39
33
  },
40
- onkey: function onkey(name) {
41
- _this.jsonpath.set(name);
42
- _this.currentState.key = name;
34
+ onkey: name => {
35
+ this.jsonpath.set(name);
36
+ this.currentState.key = name;
43
37
  },
44
- oncloseobject: function oncloseobject() {
45
- _this._closeObject();
38
+ oncloseobject: () => {
39
+ this._closeObject();
46
40
  },
47
- onopenarray: function onopenarray() {
48
- _this._openArray();
41
+ onopenarray: () => {
42
+ this._openArray();
49
43
  },
50
- onclosearray: function onclosearray() {
51
- _this._closeArray();
44
+ onclosearray: () => {
45
+ this._closeArray();
52
46
  },
53
- onvalue: function onvalue(value) {
54
- _this._pushOrSet(value);
47
+ onvalue: value => {
48
+ this._pushOrSet(value);
55
49
  },
56
- onerror: function onerror(error) {
50
+ onerror: error => {
57
51
  throw error;
58
52
  },
59
- onend: function onend() {
60
- _this.result = _this.currentState.container.pop();
61
- }
62
- }, options));
53
+ onend: () => {
54
+ this.result = this.currentState.container.pop();
55
+ },
56
+ ...options
57
+ });
63
58
  }
64
- (0, _createClass2.default)(JSONParser, [{
65
- key: "reset",
66
- value: function reset() {
67
- this.result = undefined;
68
- this.previousStates = [];
69
- this.currentState = Object.freeze({
70
- container: [],
71
- key: null
72
- });
73
- this.jsonpath = new _jsonpath.default();
74
- }
75
- }, {
76
- key: "write",
77
- value: function write(chunk) {
78
- this.parser.write(chunk);
79
- }
80
- }, {
81
- key: "close",
82
- value: function close() {
83
- this.parser.close();
84
- }
85
- }, {
86
- key: "_pushOrSet",
87
- value: function _pushOrSet(value) {
88
- var _this$currentState = this.currentState,
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
- return JSONParser;
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","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","JSONParser","options","_this","_classCallCheck2","undefined","freeze","container","JSONPath","reset","parser","ClarinetParser","onready","jsonpath","previousStates","currentState","onopenobject","name","_openObject","emit","onkey","set","oncloseobject","_closeObject","onopenarray","_openArray","onclosearray","_closeArray","onvalue","value","_pushOrSet","onerror","error","onend","result","pop","_createClass2","write","chunk","close","_this$currentState","newContainer","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;AAA4C,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA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C,CAAC;MACnB,IAAI,CAACpB,YAAY,GAAG,IAAI,CAACD,cAAc,CAACqB,GAAG,CAAC,CAAC;IAC/C;EAAC;EAAA,OAAAlC,UAAA;AAAA;AAAA0C,OAAA,CAAA9C,OAAA,GAAAI,UAAA"}
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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,GAAAC,SAAA,CAAA3B,MAAA,QAAA2B,SAAA,QAAAvC,SAAA,GAAAuC,SAAA,MAAG,CAAC,CAAC;IAC3B,IAAI,CAAC7B,QAAQ,CAAC2B,IAAI,CAAC,IAAI,CAAC;IACxB,IAAI,CAACT,UAAU,CAACU,YAAY,CAAC;IAC7B,IAAI,CAAC3B,cAAc,CAAC0B,IAAI,CAAC,IAAI,CAACxB,YAAY,CAAC;IAC3C,IAAI,CAACA,YAAY,GAAG;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
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
20
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
22
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
23
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
- var StreamingJSONParser = function (_JSONParser) {
25
- (0, _inherits2.default)(StreamingJSONParser, _JSONParser);
26
- var _super = _createSuper(StreamingJSONParser);
27
- function StreamingJSONParser() {
28
- var _this;
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
- _this._openArray();
24
+ this._openArray();
42
25
  },
43
- onopenobject: function onopenobject(name) {
44
- if (!_this.topLevelObject) {
45
- _this.topLevelObject = {};
46
- _this._openObject(_this.topLevelObject);
26
+ onopenobject: name => {
27
+ if (!this.topLevelObject) {
28
+ this.topLevelObject = {};
29
+ this._openObject(this.topLevelObject);
47
30
  } else {
48
- _this._openObject({});
31
+ this._openObject({});
49
32
  }
50
33
  if (typeof name !== 'undefined') {
51
- _this.parser.emit('onkey', name);
34
+ this.parser.emit('onkey', name);
52
35
  }
53
36
  }
54
37
  });
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "jsonPaths", void 0);
56
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "streamingJsonPath", null);
57
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "streamingArray", null);
58
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "topLevelObject", null);
59
- var jsonpaths = options.jsonpaths || [];
60
- _this.jsonPaths = jsonpaths.map(function (jsonpath) {
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
- (0, _createClass2.default)(StreamingJSONParser, [{
66
- key: "write",
67
- value: function write(chunk) {
68
- (0, _get2.default)((0, _getPrototypeOf2.default)(StreamingJSONParser.prototype), "write", this).call(this, chunk);
69
- var array = [];
70
- if (this.streamingArray) {
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
- key: "getStreamingJsonPathAsString",
88
- value: function getStreamingJsonPathAsString() {
89
- return this.streamingJsonPath && this.streamingJsonPath.toString();
90
- }
91
- }, {
92
- key: "getJsonPath",
93
- value: function getJsonPath() {
94
- return this.jsonpath;
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
- key: "_matchJSONPath",
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
- return StreamingJSONParser;
121
- }(_jsonParser.default);
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","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","Reflect","construct","arguments","apply","_possibleConstructorReturn2","sham","Proxy","Boolean","valueOf","StreamingJSONParser","_JSONParser","_inherits2","_super","_this","options","undefined","_classCallCheck2","onopenarray","streamingArray","_matchJSONPath","streamingJsonPath","getJsonPath","clone","_openArray","onopenobject","topLevelObject","_openObject","parser","emit","_defineProperty2","_assertThisInitialized2","jsonpaths","jsonPaths","map","jsonpath","JSONPath","_createClass2","key","write","chunk","_get2","array","_toConsumableArray2","getPartialResult","getStreamingJsonPath","getStreamingJsonPathAsString","currentPath","_iterator","_step","jsonPath","equals","JSONParser","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;AAA4C,SAAAE,2BAAAC,CAAA,EAAAC,cAAA,QAAAC,EAAA,UAAAC,MAAA,oBAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,EAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,EAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,cAAA,IAAAD,CAAA,WAAAA,CAAA,CAAAQ,MAAA,qBAAAN,EAAA,EAAAF,CAAA,GAAAE,EAAA,MAAAO,CAAA,UAAAC,CAAA,YAAAA,EAAA,eAAAC,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAA,EAAA,QAAAH,CAAA,IAAAT,CAAA,CAAAQ,MAAA,WAAAK,IAAA,mBAAAA,IAAA,SAAAC,KAAA,EAAAd,CAAA,CAAAS,CAAA,UAAAM,CAAA,WAAAA,EAAAC,EAAA,UAAAA,EAAA,KAAAC,CAAA,EAAAP,CAAA,gBAAAQ,SAAA,iJAAAC,gBAAA,SAAAC,MAAA,UAAAC,GAAA,WAAAV,CAAA,WAAAA,EAAA,IAAAT,EAAA,GAAAA,EAAA,CAAAoB,IAAA,CAAAtB,CAAA,MAAAY,CAAA,WAAAA,EAAA,QAAAW,IAAA,GAAArB,EAAA,CAAAsB,IAAA,IAAAL,gBAA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AA,CAAAhF,CAAA;MAAA;MAED,OAAO,KAAK;IACd;EAAC;EAAA,OAAA0C,mBAAA;AAAA,EAnG8C0C,mBAAU;AAAAC,OAAA,CAAAvD,OAAA,GAAAY,mBAAA"}
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,CA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AsB,4BAA4BA,CAAA,EAAG;IAC7B,OAAO,IAAI,CAACtB,iBAAiB,IAAI,IAAI,CAACA,iBAAiB,CAACuB,QAAQ,CAAC,CAAC;EACpE;EAEAtB,WAAWA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACc,QAAQ;EACtB;EAOAhB,cAAcA,CAAA,EAAG;IACf,MAAMyB,WAAW,GAAG,IAAI,CAACvB,WAAW,CAAC,CAAC;IAKtC,IAAI,IAAI,CAACY,SAAS,CAAClB,MAAM,KAAK,CAAC,EAAE;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
- var VERSION = typeof "3.4.13" !== 'undefined' ? "3.4.13" : 'latest';
13
- var DEFAULT_NDGEOJSON_LOADER_OPTIONS = {
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
- var NDJSONLoader = {
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: function () {
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
- var _typecheckNDJSONLoader = NDJSONLoader;
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","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","wrap","_callee$","_context","prev","next","abrupt","parseNDJSONSync","TextDecoder","decode","stop","_x","apply","arguments","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,IAAME,OAAO,GAAG,eAAkB,KAAK,WAAW,cAAiB,QAAQ;AAW3E,IAAMC,gCAAgC,GAAG;EACvCC,OAAO,EAAE;IACPC,KAAK,EAAE;EACT,CAAC;EACDC,GAAG,EAAE;IACHC,MAAM,EAAE;EAC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","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
- var VERSION = typeof "3.4.13" !== 'undefined' ? "3.4.13" : 'latest';
13
- var NDJSONLoader = {
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: function () {
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","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","wrap","_callee$","_context","prev","next","abrupt","parseNDJSONSync","TextDecoder","decode","stop","_x","apply","arguments","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,IAAME,OAAO,GAAG,eAAkB,KAAK,WAAW,cAAiB,QAAQ;AAEpE,IAAMC,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;IAAA,IAAAC,MAAA,OAAAC,kBAAA,CAAAC,OAAA,EAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAE,SAAAC,QAAOC,WAAwB;MAAA,OAAAH,YAAA,CAAAD,OAAA,CAAAK,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,OAAAF,QAAA,CAAAG,MAAA,WAAK,IAAAC,oBAAe,EAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACT,WAAW,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAG,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAX,OAAA;IAAA;IAAA,SAAAN,MAAAkB,EAAA;MAAA,OAAAjB,MAAA,CAAAkB,KAAA,OAAAC,SAAA;IAAA;IAAA,OAAApB,KAAA;EAAA;EACjGqB,aAAa,EAAEP,oBAAe;EAC9BQ,cAAc,EAAEC,6BAAoB;EACpCC,OAAO,EAAE,CAAC;AACZ,CAAC;AAACC,OAAA,CAAAlC,YAAA,GAAAA,YAAA"}
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"}