jtlt 0.24.1 → 0.24.2

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/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # jtlt CHANGES
2
2
 
3
+ ## 0.24.2
4
+
5
+ - chore: update simple-get-json
6
+
3
7
  ## 0.24.1
4
8
 
5
9
  - fix: avoid fragile use of combined string (with NUL byte) as key
@@ -6,12 +6,145 @@ function _arrayLikeToArray(r, a) {
6
6
  function _arrayWithoutHoles(r) {
7
7
  if (Array.isArray(r)) return _arrayLikeToArray(r);
8
8
  }
9
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
10
+ try {
11
+ var i = n[a](c),
12
+ u = i.value;
13
+ } catch (n) {
14
+ return void e(n);
15
+ }
16
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
17
+ }
18
+ function _asyncToGenerator(n) {
19
+ return function () {
20
+ var t = this,
21
+ e = arguments;
22
+ return new Promise(function (r, o) {
23
+ var a = n.apply(t, e);
24
+ function _next(n) {
25
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
26
+ }
27
+ function _throw(n) {
28
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
29
+ }
30
+ _next(void 0);
31
+ });
32
+ };
33
+ }
9
34
  function _iterableToArray(r) {
10
35
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
11
36
  }
12
37
  function _nonIterableSpread() {
13
38
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
39
  }
40
+ function _regenerator() {
41
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
42
+ var e,
43
+ t,
44
+ r = "function" == typeof Symbol ? Symbol : {},
45
+ n = r.iterator || "@@iterator",
46
+ o = r.toStringTag || "@@toStringTag";
47
+ function i(r, n, o, i) {
48
+ var c = n && n.prototype instanceof Generator ? n : Generator,
49
+ u = Object.create(c.prototype);
50
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
51
+ var i,
52
+ c,
53
+ u,
54
+ f = 0,
55
+ p = o || [],
56
+ y = false,
57
+ G = {
58
+ p: 0,
59
+ n: 0,
60
+ v: e,
61
+ a: d,
62
+ f: d.bind(e, 4),
63
+ d: function (t, r) {
64
+ return i = t, c = 0, u = e, G.n = r, a;
65
+ }
66
+ };
67
+ function d(r, n) {
68
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
69
+ var o,
70
+ i = p[t],
71
+ d = G.p,
72
+ l = i[2];
73
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
74
+ }
75
+ if (o || r > 1) return a;
76
+ throw y = true, n;
77
+ }
78
+ return function (o, p, l) {
79
+ if (f > 1) throw TypeError("Generator is already running");
80
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
81
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
82
+ try {
83
+ if (f = 2, i) {
84
+ if (c || (o = "next"), t = i[o]) {
85
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
86
+ if (!t.done) return t;
87
+ u = t.value, c < 2 && (c = 0);
88
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
89
+ i = e;
90
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
91
+ } catch (t) {
92
+ i = e, c = 1, u = t;
93
+ } finally {
94
+ f = 1;
95
+ }
96
+ }
97
+ return {
98
+ value: t,
99
+ done: y
100
+ };
101
+ };
102
+ }(r, o, i), true), u;
103
+ }
104
+ var a = {};
105
+ function Generator() {}
106
+ function GeneratorFunction() {}
107
+ function GeneratorFunctionPrototype() {}
108
+ t = Object.getPrototypeOf;
109
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
110
+ return this;
111
+ }), t),
112
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
113
+ function f(e) {
114
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
115
+ }
116
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
117
+ return this;
118
+ }), _regeneratorDefine(u, "toString", function () {
119
+ return "[object Generator]";
120
+ }), (_regenerator = function () {
121
+ return {
122
+ w: i,
123
+ m: f
124
+ };
125
+ })();
126
+ }
127
+ function _regeneratorDefine(e, r, n, t) {
128
+ var i = Object.defineProperty;
129
+ try {
130
+ i({}, "", {});
131
+ } catch (e) {
132
+ i = 0;
133
+ }
134
+ _regeneratorDefine = function (e, r, n, t) {
135
+ function o(r, n) {
136
+ _regeneratorDefine(e, r, function (e) {
137
+ return this._invoke(r, n, e);
138
+ });
139
+ }
140
+ r ? i ? i(e, r, {
141
+ value: n,
142
+ enumerable: !t,
143
+ configurable: !t,
144
+ writable: !t
145
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
146
+ }, _regeneratorDefine(e, r, n, t);
147
+ }
15
148
  function _toConsumableArray(r) {
16
149
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
17
150
  }
@@ -31,17 +164,17 @@ function _unsupportedIterableToArray(r, a) {
31
164
  */
32
165
 
33
166
  /**
34
- * @callback SimpleJSONCallback
35
- * @param {...JSONValue} json
36
- * @returns {void}
37
- */
167
+ * @callback SimpleJSONCallback
168
+ * @param {...JSONValue[]} json
169
+ * @returns {void}
170
+ */
38
171
 
39
172
  /**
40
- * @callback SimpleJSONErrback
41
- * @param {Error} err
42
- * @param {string|string[]} jsonURL
43
- * @returns {JSONValue}
44
- */
173
+ * @callback SimpleJSONErrback
174
+ * @param {Error} err
175
+ * @param {string|string[]} jsonURL
176
+ * @returns {JSONValue}
177
+ */
45
178
 
46
179
  /**
47
180
  * @typedef {((
@@ -60,88 +193,76 @@ function _unsupportedIterableToArray(r, a) {
60
193
  * @param {import('./index-polyglot.js').SimpleFetch} [cfg.fetch]
61
194
  * @returns {getJSONCallback}
62
195
  */
63
-
64
- function _await(value, then, direct) {
65
- if (!value || !value.then) {
66
- value = Promise.resolve(value);
67
- }
68
- return then ? value.then(then) : value;
69
- }
70
- function _invoke(body, then) {
71
- var result = body();
72
- if (result && result.then) {
73
- return result.then(then);
74
- }
75
- return then(result);
76
- }
77
- function _catch(body, recover) {
78
- try {
79
- var result = body();
80
- } catch (e) {
81
- return recover(e);
82
- }
83
- if (result && result.then) {
84
- return result.then(void 0, recover);
85
- }
86
- return result;
87
- }
88
196
  function buildGetJSONWithFetch() {
89
197
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
90
198
  _ref$fetch = _ref.fetch,
91
199
  fetch = _ref$fetch === void 0 ? typeof window !== 'undefined' ? window.fetch : self.fetch : _ref$fetch;
92
200
  /**
93
- * @type {getJSONCallback}
94
- */
95
- return function getJSON(jsonURL, cb, errBack) {
96
- try {
97
- var _exit = false;
98
- return _await(_catch(function () {
99
- return _invoke(function () {
100
- if (Array.isArray(jsonURL)) {
101
- return _await(Promise.all(jsonURL.map(function (url) {
201
+ * @type {getJSONCallback}
202
+ */
203
+ return /*#__PURE__*/function () {
204
+ var _getJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(jsonURL, cb, errBack) {
205
+ var arrResult, resp, result, e, _t;
206
+ return _regenerator().w(function (_context) {
207
+ while (1) switch (_context.p = _context.n) {
208
+ case 0:
209
+ _context.p = 0;
210
+ if (!Array.isArray(jsonURL)) {
211
+ _context.n = 2;
212
+ break;
213
+ }
214
+ _context.n = 1;
215
+ return Promise.all(jsonURL.map(function (url) {
102
216
  return /** @type {getJSONCallback} */getJSON(url);
103
- })), function (arrResult) {
104
- if (cb) {
105
- // eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
106
- cb.apply(void 0, _toConsumableArray(arrResult));
107
- }
108
- _exit = true;
109
- return arrResult;
110
- });
111
- }
112
- }, function (_result) {
113
- return _exit ? _result : _await(fetch(jsonURL), function (resp) {
114
- return _await(resp.json(), function (result) {
115
- return typeof cb === 'function'
217
+ }));
218
+ case 1:
219
+ arrResult = _context.v;
220
+ if (cb) {
116
221
  // eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
117
- ? cb(result) : result;
118
- // https://github.com/bcoe/c8/issues/135
119
- /* c8 ignore next */
120
- });
121
- });
122
- });
123
- }, function (err) {
124
- var e = /** @type {Error} */err;
125
- e.message += " (File: ".concat(jsonURL, ")");
126
- if (errBack) {
127
- return errBack(e, jsonURL);
222
+ cb.apply(void 0, _toConsumableArray(arrResult));
223
+ }
224
+ return _context.a(2, arrResult);
225
+ case 2:
226
+ _context.n = 3;
227
+ return fetch(jsonURL);
228
+ case 3:
229
+ resp = _context.v;
230
+ _context.n = 4;
231
+ return resp.json();
232
+ case 4:
233
+ result = _context.v;
234
+ return _context.a(2, typeof cb === 'function'
235
+ // eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
236
+ ? cb(result) : result);
237
+ case 5:
238
+ _context.p = 5;
239
+ _t = _context.v;
240
+ e = /** @type {Error} */_t;
241
+ e.message += " (File: ".concat(jsonURL, ")");
242
+ if (!errBack) {
243
+ _context.n = 6;
244
+ break;
245
+ }
246
+ return _context.a(2, errBack(e, jsonURL));
247
+ case 6:
248
+ throw e;
249
+ case 7:
250
+ return _context.a(2);
128
251
  }
129
- throw e;
130
- // https://github.com/bcoe/c8/issues/135
131
- /* c8 ignore next */
132
- }));
133
- /* c8 ignore next */
134
- } catch (e) {
135
- return Promise.reject(e);
252
+ }, _callee, null, [[0, 5]]);
253
+ }));
254
+ function getJSON(_x, _x2, _x3) {
255
+ return _getJSON.apply(this, arguments);
136
256
  }
137
- };
257
+ return getJSON;
258
+ }();
138
259
  }
139
260
 
140
261
  var getJSON = buildGetJSONWithFetch();
141
262
 
142
263
  /**
143
264
  * For polymorphism with Node.
144
- * @returns {getJSON}
265
+ * @returns {typeof getJSON}
145
266
  */
146
267
  var buildGetJSON = function buildGetJSON() {
147
268
  return getJSON;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jtlt",
3
- "version": "0.24.1",
3
+ "version": "0.24.2",
4
4
  "type": "module",
5
5
  "author": "Brett Zamir",
6
6
  "contributors": [],
@@ -37,7 +37,7 @@
37
37
  "jsdom": "30.1.0",
38
38
  "jsonpath-plus": "10.4.0",
39
39
  "prsc": "^4.0.0",
40
- "simple-get-json": "11.0.1",
40
+ "simple-get-json": "11.0.2",
41
41
  "whynot": "^5.0.0",
42
42
  "xpath2.js": "1.0.0-alpha-6",
43
43
  "xspattern": "^3.1.0"
@@ -44,3 +44,5 @@ minimumReleaseAgeExclude:
44
44
  - jamilih@0.70.0
45
45
  - eslint@10.11.0
46
46
  - eslint-plugin-unicorn@76.0.0
47
+ - local-xmlhttprequest@4.0.1
48
+ - simple-get-json@11.0.2