@loaders.gl/json 3.0.9 → 3.0.13

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.
@@ -7,30 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.GeoJSONLoader = exports.GeoJSONWorkerLoader = void 0;
9
9
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
- var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
17
-
18
- var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
19
-
20
- var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
21
-
22
10
  var _gis = require("@loaders.gl/gis");
23
11
 
24
12
  var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
25
13
 
26
14
  var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
27
15
 
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
-
32
- var VERSION = typeof "3.0.9" !== 'undefined' ? "3.0.9" : 'latest';
33
- var DEFAULT_GEOJSON_LOADER_OPTIONS = {
16
+ const VERSION = typeof "3.0.13" !== 'undefined' ? "3.0.13" : 'latest';
17
+ const DEFAULT_GEOJSON_LOADER_OPTIONS = {
34
18
  geojson: {
35
19
  shape: 'object-row-table'
36
20
  },
@@ -41,7 +25,7 @@ var DEFAULT_GEOJSON_LOADER_OPTIONS = {
41
25
  format: 'geojson'
42
26
  }
43
27
  };
44
- var GeoJSONWorkerLoader = {
28
+ const GeoJSONWorkerLoader = {
45
29
  name: 'GeoJSON',
46
30
  id: 'geojson',
47
31
  module: 'geojson',
@@ -54,42 +38,26 @@ var GeoJSONWorkerLoader = {
54
38
  options: DEFAULT_GEOJSON_LOADER_OPTIONS
55
39
  };
56
40
  exports.GeoJSONWorkerLoader = GeoJSONWorkerLoader;
57
-
58
- var GeoJSONLoader = _objectSpread(_objectSpread({}, GeoJSONWorkerLoader), {}, {
59
- parse: parse,
60
- parseTextSync: parseTextSync,
61
- parseInBatches: parseInBatches
62
- });
63
-
41
+ const GeoJSONLoader = { ...GeoJSONWorkerLoader,
42
+ parse,
43
+ parseTextSync,
44
+ parseInBatches
45
+ };
64
46
  exports.GeoJSONLoader = GeoJSONLoader;
65
47
 
66
- function parse(_x2, _x3) {
67
- return _parse.apply(this, arguments);
68
- }
69
-
70
- function _parse() {
71
- _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, options) {
72
- return _regenerator.default.wrap(function _callee2$(_context2) {
73
- while (1) {
74
- switch (_context2.prev = _context2.next) {
75
- case 0:
76
- return _context2.abrupt("return", parseTextSync(new TextDecoder().decode(arrayBuffer), options));
77
-
78
- case 1:
79
- case "end":
80
- return _context2.stop();
81
- }
82
- }
83
- }, _callee2);
84
- }));
85
- return _parse.apply(this, arguments);
48
+ async function parse(arrayBuffer, options) {
49
+ return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
86
50
  }
87
51
 
88
52
  function parseTextSync(text, options) {
89
- options = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS), options);
90
- options.json = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS.geojson), options.geojson);
53
+ options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
54
+ ...options
55
+ };
56
+ options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
57
+ ...options.geojson
58
+ };
91
59
  options.gis = options.gis || {};
92
- var json = (0, _parseJson.default)(text, options);
60
+ const json = (0, _parseJson.default)(text, options);
93
61
 
94
62
  switch (options.gis.format) {
95
63
  case 'binary':
@@ -101,9 +69,13 @@ function parseTextSync(text, options) {
101
69
  }
102
70
 
103
71
  function parseInBatches(asyncIterator, options) {
104
- options = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS), options);
105
- options.json = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS.geojson), options.geojson);
106
- var geojsonIterator = (0, _parseJsonInBatches.default)(asyncIterator, options);
72
+ options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
73
+ ...options
74
+ };
75
+ options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
76
+ ...options.geojson
77
+ };
78
+ const geojsonIterator = (0, _parseJsonInBatches.default)(asyncIterator, options);
107
79
 
108
80
  switch (options.gis.format) {
109
81
  case 'binary':
@@ -114,96 +86,10 @@ function parseInBatches(asyncIterator, options) {
114
86
  }
115
87
  }
116
88
 
117
- function makeBinaryGeometryIterator(_x) {
118
- return _makeBinaryGeometryIterator.apply(this, arguments);
119
- }
120
-
121
- function _makeBinaryGeometryIterator() {
122
- _makeBinaryGeometryIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee(geojsonIterator) {
123
- var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, batch;
124
-
125
- return _regenerator.default.wrap(function _callee$(_context) {
126
- while (1) {
127
- switch (_context.prev = _context.next) {
128
- case 0:
129
- _iteratorNormalCompletion = true;
130
- _didIteratorError = false;
131
- _context.prev = 2;
132
- _iterator = (0, _asyncIterator2.default)(geojsonIterator);
133
-
134
- case 4:
135
- _context.next = 6;
136
- return (0, _awaitAsyncGenerator2.default)(_iterator.next());
137
-
138
- case 6:
139
- _step = _context.sent;
140
- _iteratorNormalCompletion = _step.done;
141
- _context.next = 10;
142
- return (0, _awaitAsyncGenerator2.default)(_step.value);
143
-
144
- case 10:
145
- _value = _context.sent;
146
-
147
- if (_iteratorNormalCompletion) {
148
- _context.next = 19;
149
- break;
150
- }
151
-
152
- batch = _value;
153
- batch.data = (0, _gis.geojsonToBinary)(batch.data);
154
- _context.next = 16;
155
- return batch;
156
-
157
- case 16:
158
- _iteratorNormalCompletion = true;
159
- _context.next = 4;
160
- break;
161
-
162
- case 19:
163
- _context.next = 25;
164
- break;
165
-
166
- case 21:
167
- _context.prev = 21;
168
- _context.t0 = _context["catch"](2);
169
- _didIteratorError = true;
170
- _iteratorError = _context.t0;
171
-
172
- case 25:
173
- _context.prev = 25;
174
- _context.prev = 26;
175
-
176
- if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
177
- _context.next = 30;
178
- break;
179
- }
180
-
181
- _context.next = 30;
182
- return (0, _awaitAsyncGenerator2.default)(_iterator.return());
183
-
184
- case 30:
185
- _context.prev = 30;
186
-
187
- if (!_didIteratorError) {
188
- _context.next = 33;
189
- break;
190
- }
191
-
192
- throw _iteratorError;
193
-
194
- case 33:
195
- return _context.finish(30);
196
-
197
- case 34:
198
- return _context.finish(25);
199
-
200
- case 35:
201
- case "end":
202
- return _context.stop();
203
- }
204
- }
205
- }, _callee, null, [[2, 21, 25, 35], [26,, 30, 34]]);
206
- }));
207
- return _makeBinaryGeometryIterator.apply(this, arguments);
89
+ async function* makeBinaryGeometryIterator(geojsonIterator) {
90
+ for await (const batch of geojsonIterator) {
91
+ batch.data = (0, _gis.geojsonToBinary)(batch.data);
92
+ yield batch;
93
+ }
208
94
  }
209
95
  //# sourceMappingURL=geojson-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/geojson-loader.ts"],"names":["VERSION","DEFAULT_GEOJSON_LOADER_OPTIONS","geojson","shape","json","jsonpaths","gis","format","GeoJSONWorkerLoader","name","id","module","version","worker","extensions","mimeTypes","category","text","options","GeoJSONLoader","parse","parseTextSync","parseInBatches","arrayBuffer","TextDecoder","decode","asyncIterator","geojsonIterator","makeBinaryGeometryIterator","batch","data"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;;;;;AAIA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAWA,IAAMC,8BAA8B,GAAG;AACrCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,KAAK,EAAE;AADA,GAD4B;AAIrCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,SAAS,EAAE,CAAC,GAAD,EAAM,YAAN;AADP,GAJ+B;AAOrCC,EAAAA,GAAG,EAAE;AACHC,IAAAA,MAAM,EAAE;AADL;AAPgC,CAAvC;AAeO,IAAMC,mBAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,SADmC;AAEzCC,EAAAA,EAAE,EAAE,SAFqC;AAGzCC,EAAAA,MAAM,EAAE,SAHiC;AAIzCC,EAAAA,OAAO,EAAEZ,OAJgC;AAKzCa,EAAAA,MAAM,EAAE,IALiC;AAMzCC,EAAAA,UAAU,EAAE,CAAC,SAAD,CAN6B;AAOzCC,EAAAA,SAAS,EAAE,CAAC,sBAAD,CAP8B;AAQzCC,EAAAA,QAAQ,EAAE,UAR+B;AASzCC,EAAAA,IAAI,EAAE,IATmC;AAUzCC,EAAAA,OAAO,EAAEjB;AAVgC,CAApC;;;AAaA,IAAMkB,aAA+B,mCACvCX,mBADuC;AAE1CY,EAAAA,KAAK,EAALA,KAF0C;AAG1CC,EAAAA,aAAa,EAAbA,aAH0C;AAI1CC,EAAAA,cAAc,EAA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;AAAA,qDAC4BA,eAD5B;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AACmBE,YAAAA,KADnB;AAEIA,YAAAA,KAAK,CAACC,IAAN,GAAa,0BAAgBD,KAAK,CAACC,IAAtB,CAAb;AAFJ;AAGI,mBAAMD,KAAN;;AAHJ;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {JSONLoaderOptions} from './json-loader';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-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 GeoJSONLoaderOptions = JSONLoaderOptions & {\n geojson?: {\n shape?: 'object-row-table';\n };\n gis?: {\n format: 'geojson';\n };\n};\n\nconst DEFAULT_GEOJSON_LOADER_OPTIONS = {\n geojson: {\n shape: 'object-row-table'\n },\n json: {\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n};\n\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader: Loader = {\n name: 'GeoJSON',\n id: 'geojson',\n module: 'geojson',\n version: VERSION,\n worker: true,\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n category: 'geometry',\n text: true,\n options: DEFAULT_GEOJSON_LOADER_OPTIONS\n};\n\nexport const GeoJSONLoader: LoaderWithParser = {\n ...GeoJSONWorkerLoader,\n parse,\n parseTextSync,\n parseInBatches\n};\n\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n options.gis = options.gis || {};\n const json = parseJSONSync(text, options);\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(json);\n default:\n return json;\n }\n}\n\nfunction parseInBatches(asyncIterator, options): AsyncIterable<any> {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\n }\n}\n\nasync function* makeBinaryGeometryIterator(geojsonIterator) {\n for await (const batch of geojsonIterator) {\n batch.data = geojsonToBinary(batch.data);\n yield batch;\n }\n}\n"],"file":"geojson-loader.js"}
1
+ {"version":3,"sources":["../../src/geojson-loader.ts"],"names":["VERSION","DEFAULT_GEOJSON_LOADER_OPTIONS","geojson","shape","json","jsonpaths","gis","format","GeoJSONWorkerLoader","name","id","module","version","worker","extensions","mimeTypes","category","text","options","GeoJSONLoader","parse","parseTextSync","parseInBatches","arrayBuffer","TextDecoder","decode","asyncIterator","geojsonIterator","makeBinaryGeometryIterator","batch","data"],"mappings":";;;;;;;;;AAEA;;AACA;;AACA;;AAIA,MAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAWA,MAAMC,8BAA8B,GAAG;AACrCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,KAAK,EAAE;AADA,GAD4B;AAIrCC,EAAAA,IA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UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAO,0BAAgBH,IAAhB,CAAP;;AACF;AACE,aAAOA,IAAP;AAJJ;AAMD;;AAED,SAASkB,cAAT,CAAwBI,aAAxB,EAAuCR,OAAvC,EAAoE;AAElEA,EAAAA,OAAO,GAAG,EAAC,GAAGjB,8BAAJ;AAAoC,OAAGiB;AAAvC,GAAV;AACAA,EAAAA,OAAO,CAACd,IAAR,GAAe,EAAC,GAAGH,8BAA8B,CAACC,OAAnC;AAA4C,OAAGgB,OAAO,CAAChB;AAAvD,GAAf;AAEA,QAAMyB,eAAe,GAAG,iCAAmBD,aAAnB,EAAkCR,OAAlC,CAAxB;;AAEA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAOqB,0BAA0B,CAACD,eAAD,CAAjC;;AACF;AACE,aAAOA,eAAP;AAJJ;AAMD;;AAED,gBAAgBC,0BAAhB,CAA2CD,eAA3C,EAA4D;AAC1D,aAAW,MAAME,KAAjB,IAA0BF,eAA1B,EAA2C;AACzCE,IAAAA,KAAK,CAACC,IAAN,GAAa,0BAAgBD,KAAK,CAACC,IAAtB,CAAb;AACA,UAAMD,KAAN;AACD;AACF","sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {JSONLoaderOptions} from './json-loader';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-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 GeoJSONLoaderOptions = JSONLoaderOptions & {\n geojson?: {\n shape?: 'object-row-table';\n };\n gis?: {\n format: 'geojson';\n };\n};\n\nconst DEFAULT_GEOJSON_LOADER_OPTIONS = {\n geojson: {\n shape: 'object-row-table'\n },\n json: {\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n};\n\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader: Loader = {\n name: 'GeoJSON',\n id: 'geojson',\n module: 'geojson',\n version: VERSION,\n worker: true,\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n category: 'geometry',\n text: true,\n options: DEFAULT_GEOJSON_LOADER_OPTIONS\n};\n\nexport const GeoJSONLoader: LoaderWithParser = {\n ...GeoJSONWorkerLoader,\n parse,\n parseTextSync,\n parseInBatches\n};\n\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n options.gis = options.gis || {};\n const json = parseJSONSync(text, options);\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(json);\n default:\n return json;\n }\n}\n\nfunction parseInBatches(asyncIterator, options): AsyncIterable<any> {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\n }\n}\n\nasync function* makeBinaryGeometryIterator(geojsonIterator) {\n for await (const batch of geojsonIterator) {\n batch.data = geojsonToBinary(batch.data);\n yield batch;\n }\n}\n"],"file":"geojson-loader.js"}
package/dist/es5/index.js CHANGED
@@ -7,31 +7,31 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "JSONLoader", {
9
9
  enumerable: true,
10
- get: function get() {
10
+ get: function () {
11
11
  return _jsonLoader.JSONLoader;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "_GeoJSONLoader", {
15
15
  enumerable: true,
16
- get: function get() {
16
+ get: function () {
17
17
  return _geojsonLoader.GeoJSONLoader;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "_GeoJSONWorkerLoader", {
21
21
  enumerable: true,
22
- get: function get() {
22
+ get: function () {
23
23
  return _geojsonLoader.GeoJSONWorkerLoader;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "_JSONPath", {
27
27
  enumerable: true,
28
- get: function get() {
28
+ get: function () {
29
29
  return _jsonpath.default;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "_ClarinetParser", {
33
33
  enumerable: true,
34
- get: function get() {
34
+ get: function () {
35
35
  return _clarinet.default;
36
36
  }
37
37
  });
@@ -7,29 +7,19 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.JSONLoader = void 0;
9
9
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
10
  var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
17
11
 
18
12
  var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
19
13
 
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
-
24
- var VERSION = typeof "3.0.9" !== 'undefined' ? "3.0.9" : 'latest';
25
- var DEFAULT_JSON_LOADER_OPTIONS = {
14
+ const VERSION = typeof "3.0.13" !== 'undefined' ? "3.0.13" : 'latest';
15
+ const DEFAULT_JSON_LOADER_OPTIONS = {
26
16
  json: {
27
17
  shape: 'row-table',
28
18
  table: false,
29
19
  jsonpaths: []
30
20
  }
31
21
  };
32
- var JSONLoader = {
22
+ const JSONLoader = {
33
23
  name: 'JSON',
34
24
  id: 'json',
35
25
  module: 'json',
@@ -38,48 +28,32 @@ var JSONLoader = {
38
28
  mimeTypes: ['application/json'],
39
29
  category: 'table',
40
30
  text: true,
41
- parse: parse,
42
- parseTextSync: parseTextSync,
43
- parseInBatches: parseInBatches,
31
+ parse,
32
+ parseTextSync,
33
+ parseInBatches,
44
34
  options: DEFAULT_JSON_LOADER_OPTIONS
45
35
  };
46
36
  exports.JSONLoader = JSONLoader;
47
37
 
48
- function parse(_x, _x2) {
49
- return _parse.apply(this, arguments);
50
- }
51
-
52
- function _parse() {
53
- _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
54
- return _regenerator.default.wrap(function _callee$(_context) {
55
- while (1) {
56
- switch (_context.prev = _context.next) {
57
- case 0:
58
- return _context.abrupt("return", parseTextSync(new TextDecoder().decode(arrayBuffer), options));
59
-
60
- case 1:
61
- case "end":
62
- return _context.stop();
63
- }
64
- }
65
- }, _callee);
66
- }));
67
- return _parse.apply(this, arguments);
38
+ async function parse(arrayBuffer, options) {
39
+ return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
68
40
  }
69
41
 
70
42
  function parseTextSync(text, options) {
71
- var jsonOptions = _objectSpread(_objectSpread({}, options), {}, {
72
- json: _objectSpread(_objectSpread({}, DEFAULT_JSON_LOADER_OPTIONS.json), options === null || options === void 0 ? void 0 : options.json)
73
- });
74
-
43
+ const jsonOptions = { ...options,
44
+ json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
45
+ ...(options === null || options === void 0 ? void 0 : options.json)
46
+ }
47
+ };
75
48
  return (0, _parseJson.default)(text, jsonOptions);
76
49
  }
77
50
 
78
51
  function parseInBatches(asyncIterator, options) {
79
- var jsonOptions = _objectSpread(_objectSpread({}, options), {}, {
80
- json: _objectSpread(_objectSpread({}, DEFAULT_JSON_LOADER_OPTIONS.json), options === null || options === void 0 ? void 0 : options.json)
81
- });
82
-
52
+ const jsonOptions = { ...options,
53
+ json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
54
+ ...(options === null || options === void 0 ? void 0 : options.json)
55
+ }
56
+ };
83
57
  return (0, _parseJsonInBatches.default)(asyncIterator, jsonOptions);
84
58
  }
85
59
  //# sourceMappingURL=json-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","DEFAULT_JSON_LOADER_OPTIONS","json","shape","table","jsonpaths","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","jsonOptions","asyncIterator"],"mappings":";;;;;;;;;;;;;;;AAEA;;AACA;;;;;;AAIA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAcA,IAAMC,2BAA2B,GAAG;AAClCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,WADH;AAEJC,IAAAA,KAAK,EAAE,KAFH;AAGJC,IAAAA,SAAS,EAAE;AAHP;AAD4B,CAApC;AASO,IAAMC,UAA4B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,MADoC;AAE1CC,EAAAA,EAAE,EAAE,MAFsC;AAG1CC,EAAAA,MAAM,EAAE,MAHkC;AAI1CC,EAAAA,OAAO,EAAEV,OAJiC;AAK1CW,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CAL8B;AAM1CC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CAN+B;AAoB1CC,EAAAA,QAAQ,EAAE,OApBgC;AAqB1CC,EAAAA,IAAI,EAAE,IArBoC;AAsB1CC,EAAAA,KAAK,EAALA,KAtB0C;AAuB1CC,EAAAA,aAAa,EAAbA,aAvB0C;AAwB1CC,EAAAA,cAAc,EAAdA,cAxB0C;AAyB1CC,EAAAA,OAAO,EAAEjB;AAzBiC,CAArC;;;SA4BQc,K;;;;;qEAAf,iBAAqBI,WAArB,EAA+CD,OAA/C;AAAA;AAAA;AAAA;AAAA;AAAA,6CACSF,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCD,OAAxC,CADtB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAIA,SAASF,aAAT,CAAuBF,IAAvB,EAAqCI,OAArC,EAAkE;AAChE,MAAMI,WAAW,mCAAOJ,OAAP;AAAgBhB,IAAAA,IAAI,kCAAMD,2BAA2B,CAACC,IAAlC,GAA2CgB,OAA3C,aAA2CA,OAA3C,uBAA2CA,OAAO,CAAEhB,IAApD;AAApB,IAAjB;;AACA,SAAO,wBAAcY,IAAd,EAAoBQ,WAApB,CAAP;AACD;;AAED,SAASL,cAAT,CACEM,aADF,EAEEL,OAFF,EAGwB;AACtB,MAAMI,WAAW,mCAAOJ,OAAP;AAAgBhB,IAAAA,IAAI,kCAAMD,2BAA2B,CAACC,IAAlC,GAA2CgB,OAA3C,aAA2CA,OAA3C,uBAA2CA,OAAO,CAAEhB,IAApD;AAApB,IAAjB;;AACA,SAAO,iCAAmBqB,aAAnB,EAAkCD,WAAlC,CAAP;AACD","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-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\n/**\n * @param table -\n * @param jsonpaths -\n */\nexport type JSONLoaderOptions = LoaderOptions & {\n json?: {\n shape?: 'row-table';\n table?: false;\n jsonpaths?: string[];\n };\n};\n\nconst DEFAULT_JSON_LOADER_OPTIONS = {\n json: {\n shape: 'row-table',\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n};\n\nexport const JSONLoader: LoaderWithParser = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n // TODO - support various line based JSON formats\n /*\n extensions: {\n json: null,\n jsonl: {stream: true},\n ndjson: {stream: true}\n },\n mimeTypes: {\n 'application/json': null,\n 'application/json-seq': {stream: true},\n 'application/x-ndjson': {stream: true}\n },\n */\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: DEFAULT_JSON_LOADER_OPTIONS\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: JSONLoaderOptions) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text: string, options?: JSONLoaderOptions) {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONSync(text, jsonOptions as JSONLoaderOptions);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: JSONLoaderOptions\n): AsyncIterable<Batch> {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONInBatches(asyncIterator, jsonOptions as JSONLoaderOptions);\n}\n"],"file":"json-loader.js"}
1
+ {"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","DEFAULT_JSON_LOADER_OPTIONS","json","shape","table","jsonpaths","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","jsonOptions","asyncIterator"],"mappings":";;;;;;;;;AAEA;;AACA;;AAIA,MAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAcA,MAAMC,2BAA2B,GAAG;AAClCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,WADH;AAEJC,IAAAA,KAAK,EAAE,KAFH;AAGJC,IAAAA,SAAS,EAAE;AAHP;AAD4B,CAApC;AASO,MAAMC,UAA4B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,MADoC;AAE1CC,EAAAA,EAAE,EAAE,MAFsC;AAG1CC,EAAAA,MAAM,EAAE,MAHkC;AAI1CC,EAAAA,OAAO,EAAEV,OAJiC;AAK1CW,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CAL8B;AAM1CC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CAN+B;AAoB1CC,EAAAA,QAAQ,EAAE,OApBgC;AAqB1CC,EAAAA,IAAI,EAAE,IArBoC;AAsB1CC,EAAAA,KAtB0C;AAuB1CC,EAAAA,aAvB0C;AAwB1CC,EAAAA,cAxB0C;AAyB1CC,EAAAA,OAAO,EAAEjB;AAzBiC,CAArC;;;AA4BP,eAAec,KAAf,CAAqBI,WAArB,EAA+CD,OAA/C,EAA4E;AAC1E,SAAOF,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCD,OAAxC,CAApB;AACD;;AAED,SAASF,aAAT,CAAuBF,IAAvB,EAAqCI,OAArC,EAAkE;AAChE,QAAMI,WAAW,GAAG,EAAC,GAAGJ,OAAJ;AAAahB,IAAAA,IAAI,EAAE,EAAC,GAAGD,2BAA2B,CAACC,IAAhC;AAAsC,UAAGgB,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEhB,IAAZ;AAAtC;AAAnB,GAApB;AACA,SAAO,wBAAcY,IAAd,EAAoBQ,WAApB,CAAP;AACD;;AAED,SAASL,cAAT,CACEM,aADF,EAEEL,OAFF,EAGwB;AACtB,QAAMI,WAAW,GAAG,EAAC,GAAGJ,OAAJ;AAAahB,IAAAA,IAAI,EAAE,EAAC,GAAGD,2BAA2B,CAACC,IAAhC;AAAsC,UAAGgB,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEhB,IAAZ;AAAtC;AAAnB,GAApB;AACA,SAAO,iCAAmBqB,aAAnB,EAAkCD,WAAlC,CAAP;AACD","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-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\n/**\n * @param table -\n * @param jsonpaths -\n */\nexport type JSONLoaderOptions = LoaderOptions & {\n json?: {\n shape?: 'row-table';\n table?: false;\n jsonpaths?: string[];\n };\n};\n\nconst DEFAULT_JSON_LOADER_OPTIONS = {\n json: {\n shape: 'row-table',\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n};\n\nexport const JSONLoader: LoaderWithParser = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n // TODO - support various line based JSON formats\n /*\n extensions: {\n json: null,\n jsonl: {stream: true},\n ndjson: {stream: true}\n },\n mimeTypes: {\n 'application/json': null,\n 'application/json-seq': {stream: true},\n 'application/x-ndjson': {stream: true}\n },\n */\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: DEFAULT_JSON_LOADER_OPTIONS\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: JSONLoaderOptions) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text: string, options?: JSONLoaderOptions) {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONSync(text, jsonOptions as JSONLoaderOptions);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: JSONLoaderOptions\n): AsyncIterable<Batch> {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONInBatches(asyncIterator, jsonOptions as JSONLoaderOptions);\n}\n"],"file":"json-loader.js"}