@orioro/util 0.12.0 → 0.13.1
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/CHANGELOG.md +12 -0
- package/dist/array/arrayLikeIterable.d.ts +7 -0
- package/dist/array/dataJoin.d.ts +1 -1
- package/dist/array/index.d.ts +1 -0
- package/dist/array/{join.d.ts → tmp_dataJoin.d.ts} +2 -2
- package/dist/index.js +1094 -553
- package/dist/index.mjs +1095 -555
- package/dist/strExpr/syntheticJson.d.ts +1 -1
- package/package.json +9 -3
- package/dist/debug/debugFn.d.ts +0 -15
- package/dist/normalizeString/index.d.ts +0 -1
- package/dist/pathResolve/index.d.ts +0 -7
- package/dist/resolvePaths/index.d.ts +0 -4
- package/dist/strAutoCast/index.d.ts +0 -1
- package/dist/strAutoCast/strAutoCast.d.ts +0 -1
- package/dist/validate/async/index.d.ts +0 -18
- package/dist/validate/async/validateAsyncFn.d.ts +0 -2
- package/dist/validate/async/validators/index.d.ts +0 -2
- package/dist/validate/async/validators/logical.d.ts +0 -4
- package/dist/validate/async/validators/shape.d.ts +0 -7
- package/dist/validate/async/validators/tmpand.d.ts +0 -2
- package/dist/validate/async/validators/tmpor.d.ts +0 -2
- package/dist/validate/common/ValidationError.d.ts +0 -11
- package/dist/validate/common/util/defaultErrorMessage.d.ts +0 -2
- package/dist/validate/common/util/index.d.ts +0 -3
- package/dist/validate/common/util/parseValidatorInput.d.ts +0 -5
- package/dist/validate/common/util/resolveValidationResult.d.ts +0 -6
- package/dist/validate/common/validators/index.d.ts +0 -1
- package/dist/validate/common/validators/type.d.ts +0 -9
- package/dist/validate/index.d.ts +0 -3
- package/dist/validate/sync/index.d.ts +0 -18
- package/dist/validate/sync/validateSyncFn.d.ts +0 -2
- package/dist/validate/sync/validators/index.d.ts +0 -2
- package/dist/validate/sync/validators/logical.d.ts +0 -4
- package/dist/validate/sync/validators/shape.d.ts +0 -7
- package/dist/validate/types/async.d.ts +0 -5
- package/dist/validate/types/common.d.ts +0 -27
- package/dist/validate/types/index.d.ts +0 -3
- package/dist/validate/types/sync.d.ts +0 -5
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { keyBy,
|
|
1
|
+
import { keyBy, get, set } from 'lodash-es';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
3
|
import copy from 'fast-copy';
|
|
4
4
|
import traverse from 'traverse';
|
|
@@ -8,6 +8,7 @@ import memoizeOne from 'memoize-one';
|
|
|
8
8
|
import queryString from 'query-string';
|
|
9
9
|
|
|
10
10
|
function arrayChunk(array, chunkSize) {
|
|
11
|
+
console.warn('arrayChunk is deprecated, prefer lodash-es chunk');
|
|
11
12
|
var chunks = [];
|
|
12
13
|
for (var i = 0; i < array.length; i += chunkSize) {
|
|
13
14
|
chunks.push(array.slice(i, i + chunkSize));
|
|
@@ -15,6 +16,366 @@ function arrayChunk(array, chunkSize) {
|
|
|
15
16
|
return chunks;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
function _callSuper(t, o, e) {
|
|
20
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
21
|
+
}
|
|
22
|
+
function _construct(t, e, r) {
|
|
23
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
24
|
+
var o = [null];
|
|
25
|
+
o.push.apply(o, e);
|
|
26
|
+
var p = new (t.bind.apply(t, o))();
|
|
27
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
28
|
+
}
|
|
29
|
+
function _isNativeReflectConstruct() {
|
|
30
|
+
try {
|
|
31
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
32
|
+
} catch (t) {}
|
|
33
|
+
return (_isNativeReflectConstruct = function () {
|
|
34
|
+
return !!t;
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
function _iterableToArrayLimit(r, l) {
|
|
38
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
39
|
+
if (null != t) {
|
|
40
|
+
var e,
|
|
41
|
+
n,
|
|
42
|
+
i,
|
|
43
|
+
u,
|
|
44
|
+
a = [],
|
|
45
|
+
f = !0,
|
|
46
|
+
o = !1;
|
|
47
|
+
try {
|
|
48
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
49
|
+
if (Object(t) !== t) return;
|
|
50
|
+
f = !1;
|
|
51
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
52
|
+
} catch (r) {
|
|
53
|
+
o = !0, n = r;
|
|
54
|
+
} finally {
|
|
55
|
+
try {
|
|
56
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
57
|
+
} finally {
|
|
58
|
+
if (o) throw n;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return a;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function _regeneratorRuntime() {
|
|
65
|
+
_regeneratorRuntime = function () {
|
|
66
|
+
return e;
|
|
67
|
+
};
|
|
68
|
+
var t,
|
|
69
|
+
e = {},
|
|
70
|
+
r = Object.prototype,
|
|
71
|
+
n = r.hasOwnProperty,
|
|
72
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
73
|
+
t[e] = r.value;
|
|
74
|
+
},
|
|
75
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
76
|
+
a = i.iterator || "@@iterator",
|
|
77
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
78
|
+
u = i.toStringTag || "@@toStringTag";
|
|
79
|
+
function define(t, e, r) {
|
|
80
|
+
return Object.defineProperty(t, e, {
|
|
81
|
+
value: r,
|
|
82
|
+
enumerable: !0,
|
|
83
|
+
configurable: !0,
|
|
84
|
+
writable: !0
|
|
85
|
+
}), t[e];
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
define({}, "");
|
|
89
|
+
} catch (t) {
|
|
90
|
+
define = function (t, e, r) {
|
|
91
|
+
return t[e] = r;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function wrap(t, e, r, n) {
|
|
95
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
96
|
+
a = Object.create(i.prototype),
|
|
97
|
+
c = new Context(n || []);
|
|
98
|
+
return o(a, "_invoke", {
|
|
99
|
+
value: makeInvokeMethod(t, r, c)
|
|
100
|
+
}), a;
|
|
101
|
+
}
|
|
102
|
+
function tryCatch(t, e, r) {
|
|
103
|
+
try {
|
|
104
|
+
return {
|
|
105
|
+
type: "normal",
|
|
106
|
+
arg: t.call(e, r)
|
|
107
|
+
};
|
|
108
|
+
} catch (t) {
|
|
109
|
+
return {
|
|
110
|
+
type: "throw",
|
|
111
|
+
arg: t
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
e.wrap = wrap;
|
|
116
|
+
var h = "suspendedStart",
|
|
117
|
+
l = "suspendedYield",
|
|
118
|
+
f = "executing",
|
|
119
|
+
s = "completed",
|
|
120
|
+
y = {};
|
|
121
|
+
function Generator() {}
|
|
122
|
+
function GeneratorFunction() {}
|
|
123
|
+
function GeneratorFunctionPrototype() {}
|
|
124
|
+
var p = {};
|
|
125
|
+
define(p, a, function () {
|
|
126
|
+
return this;
|
|
127
|
+
});
|
|
128
|
+
var d = Object.getPrototypeOf,
|
|
129
|
+
v = d && d(d(values([])));
|
|
130
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
131
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
132
|
+
function defineIteratorMethods(t) {
|
|
133
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
134
|
+
define(t, e, function (t) {
|
|
135
|
+
return this._invoke(e, t);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function AsyncIterator(t, e) {
|
|
140
|
+
function invoke(r, o, i, a) {
|
|
141
|
+
var c = tryCatch(t[r], t, o);
|
|
142
|
+
if ("throw" !== c.type) {
|
|
143
|
+
var u = c.arg,
|
|
144
|
+
h = u.value;
|
|
145
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
146
|
+
invoke("next", t, i, a);
|
|
147
|
+
}, function (t) {
|
|
148
|
+
invoke("throw", t, i, a);
|
|
149
|
+
}) : e.resolve(h).then(function (t) {
|
|
150
|
+
u.value = t, i(u);
|
|
151
|
+
}, function (t) {
|
|
152
|
+
return invoke("throw", t, i, a);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
a(c.arg);
|
|
156
|
+
}
|
|
157
|
+
var r;
|
|
158
|
+
o(this, "_invoke", {
|
|
159
|
+
value: function (t, n) {
|
|
160
|
+
function callInvokeWithMethodAndArg() {
|
|
161
|
+
return new e(function (e, r) {
|
|
162
|
+
invoke(t, n, e, r);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function makeInvokeMethod(e, r, n) {
|
|
170
|
+
var o = h;
|
|
171
|
+
return function (i, a) {
|
|
172
|
+
if (o === f) throw new Error("Generator is already running");
|
|
173
|
+
if (o === s) {
|
|
174
|
+
if ("throw" === i) throw a;
|
|
175
|
+
return {
|
|
176
|
+
value: t,
|
|
177
|
+
done: !0
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
for (n.method = i, n.arg = a;;) {
|
|
181
|
+
var c = n.delegate;
|
|
182
|
+
if (c) {
|
|
183
|
+
var u = maybeInvokeDelegate(c, n);
|
|
184
|
+
if (u) {
|
|
185
|
+
if (u === y) continue;
|
|
186
|
+
return u;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
190
|
+
if (o === h) throw o = s, n.arg;
|
|
191
|
+
n.dispatchException(n.arg);
|
|
192
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
193
|
+
o = f;
|
|
194
|
+
var p = tryCatch(e, r, n);
|
|
195
|
+
if ("normal" === p.type) {
|
|
196
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
197
|
+
return {
|
|
198
|
+
value: p.arg,
|
|
199
|
+
done: n.done
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function maybeInvokeDelegate(e, r) {
|
|
207
|
+
var n = r.method,
|
|
208
|
+
o = e.iterator[n];
|
|
209
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
210
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
211
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
212
|
+
var a = i.arg;
|
|
213
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
214
|
+
}
|
|
215
|
+
function pushTryEntry(t) {
|
|
216
|
+
var e = {
|
|
217
|
+
tryLoc: t[0]
|
|
218
|
+
};
|
|
219
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
220
|
+
}
|
|
221
|
+
function resetTryEntry(t) {
|
|
222
|
+
var e = t.completion || {};
|
|
223
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
224
|
+
}
|
|
225
|
+
function Context(t) {
|
|
226
|
+
this.tryEntries = [{
|
|
227
|
+
tryLoc: "root"
|
|
228
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
229
|
+
}
|
|
230
|
+
function values(e) {
|
|
231
|
+
if (e || "" === e) {
|
|
232
|
+
var r = e[a];
|
|
233
|
+
if (r) return r.call(e);
|
|
234
|
+
if ("function" == typeof e.next) return e;
|
|
235
|
+
if (!isNaN(e.length)) {
|
|
236
|
+
var o = -1,
|
|
237
|
+
i = function next() {
|
|
238
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
239
|
+
return next.value = t, next.done = !0, next;
|
|
240
|
+
};
|
|
241
|
+
return i.next = i;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
245
|
+
}
|
|
246
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
247
|
+
value: GeneratorFunctionPrototype,
|
|
248
|
+
configurable: !0
|
|
249
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
250
|
+
value: GeneratorFunction,
|
|
251
|
+
configurable: !0
|
|
252
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
253
|
+
var e = "function" == typeof t && t.constructor;
|
|
254
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
255
|
+
}, e.mark = function (t) {
|
|
256
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
257
|
+
}, e.awrap = function (t) {
|
|
258
|
+
return {
|
|
259
|
+
__await: t
|
|
260
|
+
};
|
|
261
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
262
|
+
return this;
|
|
263
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
264
|
+
void 0 === i && (i = Promise);
|
|
265
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
266
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
267
|
+
return t.done ? t.value : a.next();
|
|
268
|
+
});
|
|
269
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
270
|
+
return this;
|
|
271
|
+
}), define(g, "toString", function () {
|
|
272
|
+
return "[object Generator]";
|
|
273
|
+
}), e.keys = function (t) {
|
|
274
|
+
var e = Object(t),
|
|
275
|
+
r = [];
|
|
276
|
+
for (var n in e) r.push(n);
|
|
277
|
+
return r.reverse(), function next() {
|
|
278
|
+
for (; r.length;) {
|
|
279
|
+
var t = r.pop();
|
|
280
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
281
|
+
}
|
|
282
|
+
return next.done = !0, next;
|
|
283
|
+
};
|
|
284
|
+
}, e.values = values, Context.prototype = {
|
|
285
|
+
constructor: Context,
|
|
286
|
+
reset: function (e) {
|
|
287
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
288
|
+
},
|
|
289
|
+
stop: function () {
|
|
290
|
+
this.done = !0;
|
|
291
|
+
var t = this.tryEntries[0].completion;
|
|
292
|
+
if ("throw" === t.type) throw t.arg;
|
|
293
|
+
return this.rval;
|
|
294
|
+
},
|
|
295
|
+
dispatchException: function (e) {
|
|
296
|
+
if (this.done) throw e;
|
|
297
|
+
var r = this;
|
|
298
|
+
function handle(n, o) {
|
|
299
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
300
|
+
}
|
|
301
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
302
|
+
var i = this.tryEntries[o],
|
|
303
|
+
a = i.completion;
|
|
304
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
305
|
+
if (i.tryLoc <= this.prev) {
|
|
306
|
+
var c = n.call(i, "catchLoc"),
|
|
307
|
+
u = n.call(i, "finallyLoc");
|
|
308
|
+
if (c && u) {
|
|
309
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
310
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
311
|
+
} else if (c) {
|
|
312
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
313
|
+
} else {
|
|
314
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
315
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
abrupt: function (t, e) {
|
|
321
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
322
|
+
var o = this.tryEntries[r];
|
|
323
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
324
|
+
var i = o;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
329
|
+
var a = i ? i.completion : {};
|
|
330
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
331
|
+
},
|
|
332
|
+
complete: function (t, e) {
|
|
333
|
+
if ("throw" === t.type) throw t.arg;
|
|
334
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
335
|
+
},
|
|
336
|
+
finish: function (t) {
|
|
337
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
338
|
+
var r = this.tryEntries[e];
|
|
339
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
catch: function (t) {
|
|
343
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
344
|
+
var r = this.tryEntries[e];
|
|
345
|
+
if (r.tryLoc === t) {
|
|
346
|
+
var n = r.completion;
|
|
347
|
+
if ("throw" === n.type) {
|
|
348
|
+
var o = n.arg;
|
|
349
|
+
resetTryEntry(r);
|
|
350
|
+
}
|
|
351
|
+
return o;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
throw new Error("illegal catch attempt");
|
|
355
|
+
},
|
|
356
|
+
delegateYield: function (e, r, n) {
|
|
357
|
+
return this.delegate = {
|
|
358
|
+
iterator: values(e),
|
|
359
|
+
resultName: r,
|
|
360
|
+
nextLoc: n
|
|
361
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
362
|
+
}
|
|
363
|
+
}, e;
|
|
364
|
+
}
|
|
365
|
+
function _toPrimitive(t, r) {
|
|
366
|
+
if ("object" != typeof t || !t) return t;
|
|
367
|
+
var e = t[Symbol.toPrimitive];
|
|
368
|
+
if (void 0 !== e) {
|
|
369
|
+
var i = e.call(t, r || "default");
|
|
370
|
+
if ("object" != typeof i) return i;
|
|
371
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
372
|
+
}
|
|
373
|
+
return ("string" === r ? String : Number)(t);
|
|
374
|
+
}
|
|
375
|
+
function _toPropertyKey(t) {
|
|
376
|
+
var i = _toPrimitive(t, "string");
|
|
377
|
+
return "symbol" == typeof i ? i : String(i);
|
|
378
|
+
}
|
|
18
379
|
function _typeof(o) {
|
|
19
380
|
"@babel/helpers - typeof";
|
|
20
381
|
|
|
@@ -24,175 +385,206 @@ function _typeof(o) {
|
|
|
24
385
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
25
386
|
}, _typeof(o);
|
|
26
387
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
388
|
+
function _classCallCheck(instance, Constructor) {
|
|
389
|
+
if (!(instance instanceof Constructor)) {
|
|
390
|
+
throw new TypeError("Cannot call a class as a function");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function _defineProperties(target, props) {
|
|
394
|
+
for (var i = 0; i < props.length; i++) {
|
|
395
|
+
var descriptor = props[i];
|
|
396
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
397
|
+
descriptor.configurable = true;
|
|
398
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
399
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
403
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
404
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
405
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
406
|
+
writable: false
|
|
407
|
+
});
|
|
408
|
+
return Constructor;
|
|
409
|
+
}
|
|
410
|
+
function _defineProperty(obj, key, value) {
|
|
411
|
+
key = _toPropertyKey(key);
|
|
412
|
+
if (key in obj) {
|
|
413
|
+
Object.defineProperty(obj, key, {
|
|
414
|
+
value: value,
|
|
415
|
+
enumerable: true,
|
|
416
|
+
configurable: true,
|
|
417
|
+
writable: true
|
|
418
|
+
});
|
|
419
|
+
} else {
|
|
420
|
+
obj[key] = value;
|
|
59
421
|
}
|
|
60
|
-
|
|
422
|
+
return obj;
|
|
61
423
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
424
|
+
function _inherits(subClass, superClass) {
|
|
425
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
426
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
427
|
+
}
|
|
428
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
429
|
+
constructor: {
|
|
430
|
+
value: subClass,
|
|
431
|
+
writable: true,
|
|
432
|
+
configurable: true
|
|
67
433
|
}
|
|
68
|
-
|
|
434
|
+
});
|
|
435
|
+
Object.defineProperty(subClass, "prototype", {
|
|
436
|
+
writable: false
|
|
437
|
+
});
|
|
438
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
439
|
+
}
|
|
440
|
+
function _getPrototypeOf(o) {
|
|
441
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
442
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
69
443
|
};
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
function
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
444
|
+
return _getPrototypeOf(o);
|
|
445
|
+
}
|
|
446
|
+
function _setPrototypeOf(o, p) {
|
|
447
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
448
|
+
o.__proto__ = p;
|
|
449
|
+
return o;
|
|
450
|
+
};
|
|
451
|
+
return _setPrototypeOf(o, p);
|
|
452
|
+
}
|
|
453
|
+
function _isNativeFunction(fn) {
|
|
454
|
+
try {
|
|
455
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
456
|
+
} catch (e) {
|
|
457
|
+
return typeof fn === "function";
|
|
77
458
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
459
|
+
}
|
|
460
|
+
function _wrapNativeSuper(Class) {
|
|
461
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
462
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
463
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
464
|
+
if (typeof Class !== "function") {
|
|
465
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
85
466
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} catch (e) {
|
|
90
|
-
reject(e);
|
|
91
|
-
}
|
|
467
|
+
if (typeof _cache !== "undefined") {
|
|
468
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
469
|
+
_cache.set(Class, Wrapper);
|
|
92
470
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
471
|
+
function Wrapper() {
|
|
472
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
95
473
|
}
|
|
96
|
-
|
|
97
|
-
|
|
474
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
475
|
+
constructor: {
|
|
476
|
+
value: Wrapper,
|
|
477
|
+
enumerable: false,
|
|
478
|
+
writable: true,
|
|
479
|
+
configurable: true
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
483
|
+
};
|
|
484
|
+
return _wrapNativeSuper(Class);
|
|
98
485
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
sent: function sent() {
|
|
103
|
-
if (t[0] & 1) throw t[1];
|
|
104
|
-
return t[1];
|
|
105
|
-
},
|
|
106
|
-
trys: [],
|
|
107
|
-
ops: []
|
|
108
|
-
},
|
|
109
|
-
f,
|
|
110
|
-
y,
|
|
111
|
-
t,
|
|
112
|
-
g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
113
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
114
|
-
return this;
|
|
115
|
-
}), g;
|
|
116
|
-
function verb(n) {
|
|
117
|
-
return function (v) {
|
|
118
|
-
return step([n, v]);
|
|
119
|
-
};
|
|
486
|
+
function _assertThisInitialized(self) {
|
|
487
|
+
if (self === void 0) {
|
|
488
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
120
489
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
490
|
+
return self;
|
|
491
|
+
}
|
|
492
|
+
function _possibleConstructorReturn(self, call) {
|
|
493
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
494
|
+
return call;
|
|
495
|
+
} else if (call !== void 0) {
|
|
496
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
497
|
+
}
|
|
498
|
+
return _assertThisInitialized(self);
|
|
499
|
+
}
|
|
500
|
+
function _slicedToArray(arr, i) {
|
|
501
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
502
|
+
}
|
|
503
|
+
function _toArray(arr) {
|
|
504
|
+
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
505
|
+
}
|
|
506
|
+
function _toConsumableArray(arr) {
|
|
507
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
508
|
+
}
|
|
509
|
+
function _arrayWithoutHoles(arr) {
|
|
510
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
511
|
+
}
|
|
512
|
+
function _arrayWithHoles(arr) {
|
|
513
|
+
if (Array.isArray(arr)) return arr;
|
|
514
|
+
}
|
|
515
|
+
function _iterableToArray(iter) {
|
|
516
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
517
|
+
}
|
|
518
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
519
|
+
if (!o) return;
|
|
520
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
521
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
522
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
523
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
524
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
525
|
+
}
|
|
526
|
+
function _arrayLikeToArray(arr, len) {
|
|
527
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
528
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
529
|
+
return arr2;
|
|
530
|
+
}
|
|
531
|
+
function _nonIterableSpread() {
|
|
532
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
533
|
+
}
|
|
534
|
+
function _nonIterableRest() {
|
|
535
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
536
|
+
}
|
|
537
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
538
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
539
|
+
if (!it) {
|
|
540
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
541
|
+
if (it) o = it;
|
|
542
|
+
var i = 0;
|
|
543
|
+
var F = function () {};
|
|
544
|
+
return {
|
|
545
|
+
s: F,
|
|
546
|
+
n: function () {
|
|
547
|
+
if (i >= o.length) return {
|
|
548
|
+
done: true
|
|
549
|
+
};
|
|
133
550
|
return {
|
|
134
|
-
|
|
135
|
-
|
|
551
|
+
done: false,
|
|
552
|
+
value: o[i++]
|
|
136
553
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
op = _.ops.pop();
|
|
144
|
-
_.trys.pop();
|
|
145
|
-
continue;
|
|
146
|
-
default:
|
|
147
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
148
|
-
_ = 0;
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
152
|
-
_.label = op[1];
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
156
|
-
_.label = t[1];
|
|
157
|
-
t = op;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
if (t && _.label < t[2]) {
|
|
161
|
-
_.label = t[2];
|
|
162
|
-
_.ops.push(op);
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
if (t[2]) _.ops.pop();
|
|
166
|
-
_.trys.pop();
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
op = body.call(thisArg, _);
|
|
170
|
-
} catch (e) {
|
|
171
|
-
op = [6, e];
|
|
172
|
-
y = 0;
|
|
173
|
-
} finally {
|
|
174
|
-
f = t = 0;
|
|
554
|
+
},
|
|
555
|
+
e: function (e) {
|
|
556
|
+
throw e;
|
|
557
|
+
},
|
|
558
|
+
f: F
|
|
559
|
+
};
|
|
175
560
|
}
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
value: op[0] ? op[1] : void 0,
|
|
179
|
-
done: true
|
|
180
|
-
};
|
|
561
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
181
562
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
563
|
+
var normalCompletion = true,
|
|
564
|
+
didErr = false,
|
|
565
|
+
err;
|
|
566
|
+
return {
|
|
567
|
+
s: function () {
|
|
568
|
+
it = it.call(o);
|
|
569
|
+
},
|
|
570
|
+
n: function () {
|
|
571
|
+
var step = it.next();
|
|
572
|
+
normalCompletion = step.done;
|
|
573
|
+
return step;
|
|
574
|
+
},
|
|
575
|
+
e: function (e) {
|
|
576
|
+
didErr = true;
|
|
577
|
+
err = e;
|
|
578
|
+
},
|
|
579
|
+
f: function () {
|
|
580
|
+
try {
|
|
581
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
582
|
+
} finally {
|
|
583
|
+
if (didErr) throw err;
|
|
584
|
+
}
|
|
188
585
|
}
|
|
189
|
-
}
|
|
190
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
586
|
+
};
|
|
191
587
|
}
|
|
192
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
193
|
-
var e = new Error(message);
|
|
194
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
195
|
-
};
|
|
196
588
|
|
|
197
589
|
function _isTupleDatasetInput(input) {
|
|
198
590
|
return Array.isArray(input) && typeof input[0] === 'string' && Array.isArray(input[1]);
|
|
@@ -208,10 +600,15 @@ function _parseDatasetInput(defaultOnKey, datasetInput) {
|
|
|
208
600
|
if (keySplit.length === 1) {
|
|
209
601
|
srcKey = null;
|
|
210
602
|
key = keyInput;
|
|
211
|
-
} else {
|
|
603
|
+
} else if (keySplit.length === 2) {
|
|
212
604
|
srcKey = keySplit[0];
|
|
213
605
|
key = keySplit[1];
|
|
606
|
+
} else {
|
|
607
|
+
throw new Error("Invalid keyInput: ".concat(keyInput, " - contains too many colons (:)"));
|
|
214
608
|
}
|
|
609
|
+
} else if (Array.isArray(keyInput)) {
|
|
610
|
+
srcKey = keyInput[0];
|
|
611
|
+
key = keyInput[1];
|
|
215
612
|
}
|
|
216
613
|
return {
|
|
217
614
|
srcKey: srcKey,
|
|
@@ -227,14 +624,15 @@ function _parseDatasetInput(defaultOnKey, datasetInput) {
|
|
|
227
624
|
path: null
|
|
228
625
|
};
|
|
229
626
|
}
|
|
230
|
-
function dataJoin(datasets
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
defaultOnKey =
|
|
234
|
-
|
|
235
|
-
mode =
|
|
236
|
-
var
|
|
237
|
-
|
|
627
|
+
function dataJoin(datasets) {
|
|
628
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
629
|
+
_ref$key = _ref.key,
|
|
630
|
+
defaultOnKey = _ref$key === void 0 ? 'id' : _ref$key,
|
|
631
|
+
_ref$mode = _ref.mode,
|
|
632
|
+
mode = _ref$mode === void 0 ? 'left' : _ref$mode;
|
|
633
|
+
var _datasets = _toArray(datasets),
|
|
634
|
+
base = _datasets[0],
|
|
635
|
+
others = _datasets.slice(1);
|
|
238
636
|
//
|
|
239
637
|
// Base dataset requires no byKey dict
|
|
240
638
|
//
|
|
@@ -244,7 +642,7 @@ function dataJoin(datasets, _a) {
|
|
|
244
642
|
//
|
|
245
643
|
var otherSets = others.map(function (setInput) {
|
|
246
644
|
var parsed = _parseDatasetInput(defaultOnKey, setInput);
|
|
247
|
-
return
|
|
645
|
+
return Object.assign(Object.assign({}, parsed), {
|
|
248
646
|
byKey: keyBy(parsed.entries, parsed.key)
|
|
249
647
|
});
|
|
250
648
|
});
|
|
@@ -254,35 +652,36 @@ function dataJoin(datasets, _a) {
|
|
|
254
652
|
// to another dataset
|
|
255
653
|
//
|
|
256
654
|
function _entryKey(entry, otherSet) {
|
|
257
|
-
var
|
|
258
|
-
return
|
|
655
|
+
var key = otherSet.srcKey ? get(entry, otherSet.srcKey) : get(entry, baseDataset.key);
|
|
656
|
+
return typeof key === 'string' || typeof key === 'number' ? key : null;
|
|
259
657
|
}
|
|
260
658
|
//
|
|
261
659
|
// If mode === inner, filter out missing data
|
|
262
660
|
//
|
|
263
661
|
var baseEntries = mode === 'inner' ? baseDataset.entries.filter(function (entry) {
|
|
264
662
|
return otherSets.every(function (set) {
|
|
265
|
-
|
|
663
|
+
var entryKey = _entryKey(entry, set);
|
|
664
|
+
return entryKey === null ? false : typeof set.byKey[entryKey] !== 'undefined';
|
|
266
665
|
});
|
|
267
666
|
}) : baseDataset.entries;
|
|
268
667
|
//
|
|
269
668
|
// Loop over baseDataset.entries joining it with other data
|
|
270
669
|
//
|
|
271
670
|
return baseEntries.map(function (entry) {
|
|
272
|
-
var _a;
|
|
273
671
|
//
|
|
274
672
|
// Setup a base entry over which data will be set
|
|
275
673
|
//
|
|
276
|
-
var baseEntry = baseDataset.path ? (
|
|
674
|
+
var baseEntry = baseDataset.path ? _defineProperty({}, baseDataset.path, entry) : Object.assign({}, entry);
|
|
277
675
|
//
|
|
278
676
|
// Loop over all other sets to pick up data
|
|
279
677
|
//
|
|
280
678
|
return otherSets.reduce(function (acc, otherSet) {
|
|
281
679
|
var entryKey = _entryKey(entry, otherSet);
|
|
282
|
-
var otherEntry = otherSet.byKey[entryKey];
|
|
680
|
+
var otherEntry = entryKey === null ? null : otherSet.byKey[entryKey];
|
|
283
681
|
if (otherEntry) {
|
|
284
682
|
if (otherSet.path) {
|
|
285
|
-
|
|
683
|
+
var currVal = get(acc, otherSet.path) || {};
|
|
684
|
+
set(acc, otherSet.path, Object.assign({}, _typeof(currVal) === 'object' ? currVal : {}, otherEntry));
|
|
286
685
|
} else {
|
|
287
686
|
Object.assign(acc, otherEntry);
|
|
288
687
|
}
|
|
@@ -292,46 +691,161 @@ function dataJoin(datasets, _a) {
|
|
|
292
691
|
});
|
|
293
692
|
}
|
|
294
693
|
|
|
295
|
-
|
|
296
|
-
|
|
694
|
+
function arrayLikeIterable(makeIterable) {
|
|
695
|
+
return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Symbol.iterator, function () {
|
|
696
|
+
return makeIterable()[Symbol.iterator]();
|
|
697
|
+
}), "map", function map(fn) {
|
|
698
|
+
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
699
|
+
var result = [];
|
|
700
|
+
var _iterator = _createForOfIteratorHelper(makeIterable()),
|
|
701
|
+
_step;
|
|
702
|
+
try {
|
|
703
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
704
|
+
var item = _step.value;
|
|
705
|
+
result.push(fn(item, i++));
|
|
706
|
+
}
|
|
707
|
+
} catch (err) {
|
|
708
|
+
_iterator.e(err);
|
|
709
|
+
} finally {
|
|
710
|
+
_iterator.f();
|
|
711
|
+
}
|
|
712
|
+
return result;
|
|
713
|
+
}), "forEach", function forEach(fn) {
|
|
714
|
+
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
715
|
+
var _iterator2 = _createForOfIteratorHelper(makeIterable()),
|
|
716
|
+
_step2;
|
|
717
|
+
try {
|
|
718
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
719
|
+
var item = _step2.value;
|
|
720
|
+
fn(item, i++);
|
|
721
|
+
}
|
|
722
|
+
} catch (err) {
|
|
723
|
+
_iterator2.e(err);
|
|
724
|
+
} finally {
|
|
725
|
+
_iterator2.f();
|
|
726
|
+
}
|
|
727
|
+
}), "reduce", function reduce(fn, acc) {
|
|
728
|
+
var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
729
|
+
var _iterator3 = _createForOfIteratorHelper(makeIterable()),
|
|
730
|
+
_step3;
|
|
731
|
+
try {
|
|
732
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
733
|
+
var item = _step3.value;
|
|
734
|
+
acc = fn(acc, item, i++);
|
|
735
|
+
}
|
|
736
|
+
} catch (err) {
|
|
737
|
+
_iterator3.e(err);
|
|
738
|
+
} finally {
|
|
739
|
+
_iterator3.f();
|
|
740
|
+
}
|
|
741
|
+
return acc;
|
|
742
|
+
}), "toArray", function toArray() {
|
|
743
|
+
return _toConsumableArray(makeIterable());
|
|
744
|
+
}), "filter", function filter(fn) {
|
|
745
|
+
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
746
|
+
var result = [];
|
|
747
|
+
var _iterator4 = _createForOfIteratorHelper(makeIterable()),
|
|
748
|
+
_step4;
|
|
749
|
+
try {
|
|
750
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
751
|
+
var item = _step4.value;
|
|
752
|
+
if (fn(item, i++)) result.push(item);
|
|
753
|
+
}
|
|
754
|
+
} catch (err) {
|
|
755
|
+
_iterator4.e(err);
|
|
756
|
+
} finally {
|
|
757
|
+
_iterator4.f();
|
|
758
|
+
}
|
|
759
|
+
return result;
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
var PromiseLikeEventEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
764
|
+
_inherits(PromiseLikeEventEmitter, _EventEmitter);
|
|
297
765
|
function PromiseLikeEventEmitter() {
|
|
298
|
-
var _this
|
|
766
|
+
var _this;
|
|
767
|
+
_classCallCheck(this, PromiseLikeEventEmitter);
|
|
768
|
+
_this = _callSuper(this, PromiseLikeEventEmitter);
|
|
299
769
|
_this.promise = new Promise(function (resolve, reject) {
|
|
300
770
|
_this.resolve = resolve;
|
|
301
771
|
_this.reject = reject;
|
|
302
772
|
});
|
|
303
773
|
return _this;
|
|
304
774
|
}
|
|
305
|
-
PromiseLikeEventEmitter
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
775
|
+
_createClass(PromiseLikeEventEmitter, [{
|
|
776
|
+
key: "then",
|
|
777
|
+
value: function then(onFulfilled, onRejected) {
|
|
778
|
+
return this.promise.then(onFulfilled, onRejected);
|
|
779
|
+
}
|
|
780
|
+
}, {
|
|
781
|
+
key: "catch",
|
|
782
|
+
value: function _catch(onRejected) {
|
|
783
|
+
return this.promise["catch"](onRejected);
|
|
784
|
+
}
|
|
785
|
+
}, {
|
|
786
|
+
key: "finally",
|
|
787
|
+
value: function _finally(onFinally) {
|
|
788
|
+
return this.promise["finally"](onFinally);
|
|
789
|
+
}
|
|
790
|
+
}]);
|
|
314
791
|
return PromiseLikeEventEmitter;
|
|
315
792
|
}(EventEmitter);
|
|
316
793
|
|
|
317
|
-
function
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
return __generator(this, function (_a) {
|
|
323
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
324
|
-
setTimeout(function () {
|
|
325
|
-
if (result instanceof Error) {
|
|
326
|
-
reject(result);
|
|
327
|
-
} else {
|
|
328
|
-
resolve(result);
|
|
329
|
-
}
|
|
330
|
-
}, ms);
|
|
331
|
-
})];
|
|
794
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
795
|
+
function adopt(value) {
|
|
796
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
797
|
+
resolve(value);
|
|
332
798
|
});
|
|
799
|
+
}
|
|
800
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
801
|
+
function fulfilled(value) {
|
|
802
|
+
try {
|
|
803
|
+
step(generator.next(value));
|
|
804
|
+
} catch (e) {
|
|
805
|
+
reject(e);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function rejected(value) {
|
|
809
|
+
try {
|
|
810
|
+
step(generator["throw"](value));
|
|
811
|
+
} catch (e) {
|
|
812
|
+
reject(e);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
function step(result) {
|
|
816
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
817
|
+
}
|
|
818
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
333
819
|
});
|
|
334
820
|
}
|
|
821
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
822
|
+
var e = new Error(message);
|
|
823
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
function wait() {
|
|
827
|
+
var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
828
|
+
var result = arguments.length > 1 ? arguments[1] : undefined;
|
|
829
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
830
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
831
|
+
while (1) switch (_context.prev = _context.next) {
|
|
832
|
+
case 0:
|
|
833
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
834
|
+
setTimeout(function () {
|
|
835
|
+
if (result instanceof Error) {
|
|
836
|
+
reject(result);
|
|
837
|
+
} else {
|
|
838
|
+
resolve(result);
|
|
839
|
+
}
|
|
840
|
+
}, ms);
|
|
841
|
+
}));
|
|
842
|
+
case 1:
|
|
843
|
+
case "end":
|
|
844
|
+
return _context.stop();
|
|
845
|
+
}
|
|
846
|
+
}, _callee);
|
|
847
|
+
}));
|
|
848
|
+
}
|
|
335
849
|
|
|
336
850
|
function deepFreeze(object) {
|
|
337
851
|
Object.freeze(object);
|
|
@@ -385,16 +899,13 @@ function sequentialCallIdGenerator() {
|
|
|
385
899
|
return count += 1;
|
|
386
900
|
};
|
|
387
901
|
}
|
|
388
|
-
function debugFn(fnName, fn, logCall, logResult
|
|
389
|
-
|
|
390
|
-
generateCallId = generateDeterministicId;
|
|
391
|
-
}
|
|
902
|
+
function debugFn(fnName, fn, logCall, logResult) {
|
|
903
|
+
var generateCallId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : generateDeterministicId;
|
|
392
904
|
return function () {
|
|
393
|
-
var args =
|
|
394
|
-
|
|
395
|
-
args[_i] = arguments[_i];
|
|
905
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
906
|
+
args[_key] = arguments[_key];
|
|
396
907
|
}
|
|
397
|
-
var callId = generateCallId(
|
|
908
|
+
var callId = generateCallId([fnName, fn].concat(args));
|
|
398
909
|
if (typeof logCall === 'function') {
|
|
399
910
|
// Deep clone args, so that we may detect mutations later on
|
|
400
911
|
logCall({
|
|
@@ -456,18 +967,19 @@ function _parsePathExpr(pathExpr) {
|
|
|
456
967
|
* supported: loops, conditionals, etc.
|
|
457
968
|
* @param {Object | Array} data Data context to be used for interpolation
|
|
458
969
|
*/
|
|
459
|
-
function interpolate(template, data
|
|
460
|
-
var
|
|
461
|
-
|
|
462
|
-
maxLength =
|
|
970
|
+
function interpolate(template, data) {
|
|
971
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
972
|
+
_ref$maxLength = _ref.maxLength,
|
|
973
|
+
maxLength = _ref$maxLength === void 0 ? 10000 : _ref$maxLength;
|
|
463
974
|
if (template.length > maxLength) {
|
|
464
975
|
throw new Error("Template exceeds maxLength ".concat(maxLength));
|
|
465
976
|
}
|
|
466
977
|
data = _typeof(data) === 'object' ? data : [data];
|
|
467
978
|
return template.replace(INTERPOLATION_REGEXP, function (_, pathExpr) {
|
|
468
|
-
var
|
|
469
|
-
|
|
470
|
-
|
|
979
|
+
var _parsePathExpr2 = _parsePathExpr(pathExpr),
|
|
980
|
+
_parsePathExpr3 = _slicedToArray(_parsePathExpr2, 2),
|
|
981
|
+
path = _parsePathExpr3[0],
|
|
982
|
+
defaultValue = _parsePathExpr3[1];
|
|
471
983
|
var value = get(data, path);
|
|
472
984
|
switch (_typeof(value)) {
|
|
473
985
|
case 'number':
|
|
@@ -492,19 +1004,19 @@ function interpolate(template, data, _a) {
|
|
|
492
1004
|
}
|
|
493
1005
|
|
|
494
1006
|
function maybeFn(input) {
|
|
495
|
-
var args =
|
|
496
|
-
|
|
497
|
-
args[_i - 1] = arguments[_i];
|
|
1007
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1008
|
+
args[_key - 1] = arguments[_key];
|
|
498
1009
|
}
|
|
499
1010
|
return typeof input === 'function' ? input.apply(void 0, args) : input;
|
|
500
1011
|
}
|
|
501
1012
|
|
|
502
1013
|
function pickPaths(sourceObj, paths) {
|
|
503
1014
|
return paths.reduce(function (acc, path) {
|
|
504
|
-
var
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
1015
|
+
var _ref = Array.isArray(path) ? path : [path, path],
|
|
1016
|
+
_ref2 = _slicedToArray(_ref, 3),
|
|
1017
|
+
targetPath = _ref2[0],
|
|
1018
|
+
resolver = _ref2[1],
|
|
1019
|
+
defaultValue = _ref2[2];
|
|
508
1020
|
var value = typeof resolver === 'string' ? get(sourceObj, resolver) : resolver(sourceObj);
|
|
509
1021
|
var valueAfterDefault = typeof value === 'undefined' ? defaultValue : value;
|
|
510
1022
|
//
|
|
@@ -531,89 +1043,107 @@ var DEFAULT_OPTIONS = {
|
|
|
531
1043
|
function _echo(input) {
|
|
532
1044
|
return input;
|
|
533
1045
|
}
|
|
534
|
-
function resolveNestedPromises(node
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
depth: 0
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1046
|
+
function resolveNestedPromises(node) {
|
|
1047
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1048
|
+
var ctx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
1049
|
+
root: node,
|
|
1050
|
+
depth: 0
|
|
1051
|
+
};
|
|
1052
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
545
1053
|
var opts, promises, _cloneFn, clonedNode, resolved;
|
|
546
|
-
return
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
1054
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1055
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1056
|
+
case 0:
|
|
1057
|
+
opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
1058
|
+
promises = []; //
|
|
1059
|
+
// Allow consumers to provide a clone function.
|
|
1060
|
+
// There are multiple nuances regarding cloning. Here are some
|
|
1061
|
+
// we've faced:
|
|
1062
|
+
// - clone-deep (https://www.npmjs.com/package/clone-deep) does
|
|
1063
|
+
// creates new versions of symbols
|
|
1064
|
+
// - fast-copy (default export) does not clone array custom properties
|
|
1065
|
+
// (but allows for creating a copier function that does)
|
|
1066
|
+
//
|
|
1067
|
+
// It would be incorrect to use copyStrict (from fast-copy) by default, thus
|
|
1068
|
+
// we allow consumers to provide their copy functions
|
|
1069
|
+
//
|
|
1070
|
+
// If opts.clone is set to false, use the _echo function
|
|
1071
|
+
//
|
|
1072
|
+
_cloneFn = opts.clone || _echo;
|
|
1073
|
+
clonedNode = _cloneFn(node);
|
|
1074
|
+
resolved = traverse(clonedNode).forEach(function (value) {
|
|
1075
|
+
var _this = this;
|
|
1076
|
+
var depth = ctx.depth + this.path.length;
|
|
1077
|
+
if (depth > opts.maxDepth) {
|
|
1078
|
+
throw new Error("Max depth exceeded: { depth: ".concat(depth, ", maxDepth: ").concat(opts.maxDepth, " }"));
|
|
1079
|
+
}
|
|
1080
|
+
if (value instanceof Promise) {
|
|
1081
|
+
var updatePromise = value.then(function (resolvedValue) {
|
|
1082
|
+
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1083
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1084
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1085
|
+
case 0:
|
|
1086
|
+
_context.t0 = this;
|
|
1087
|
+
if (!(opts.mode === 'eager')) {
|
|
1088
|
+
_context.next = 7;
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
_context.next = 4;
|
|
1092
|
+
return resolveNestedPromises(resolvedValue, opts, Object.assign(Object.assign({}, ctx), {
|
|
1093
|
+
// pass the base depth of the current value
|
|
1094
|
+
depth: depth
|
|
1095
|
+
}));
|
|
1096
|
+
case 4:
|
|
1097
|
+
_context.t1 = _context.sent;
|
|
1098
|
+
_context.next = 8;
|
|
1099
|
+
break;
|
|
1100
|
+
case 7:
|
|
1101
|
+
_context.t1 = resolvedValue;
|
|
1102
|
+
case 8:
|
|
1103
|
+
_context.t2 = _context.t1;
|
|
1104
|
+
_context.t0.update.call(_context.t0, _context.t2);
|
|
1105
|
+
case 10:
|
|
1106
|
+
case "end":
|
|
1107
|
+
return _context.stop();
|
|
1108
|
+
}
|
|
1109
|
+
}, _callee, this);
|
|
1110
|
+
}));
|
|
584
1111
|
});
|
|
585
|
-
|
|
1112
|
+
promises = [].concat(_toConsumableArray(promises), [updatePromise]);
|
|
1113
|
+
}
|
|
586
1114
|
});
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
1115
|
+
return _context2.abrupt("return", Promise.all(promises).then(function () {
|
|
1116
|
+
return resolved;
|
|
1117
|
+
}));
|
|
1118
|
+
case 6:
|
|
1119
|
+
case "end":
|
|
1120
|
+
return _context2.stop();
|
|
1121
|
+
}
|
|
1122
|
+
}, _callee2);
|
|
1123
|
+
}));
|
|
595
1124
|
}
|
|
596
1125
|
|
|
597
|
-
var TimeoutError =
|
|
598
|
-
|
|
1126
|
+
var TimeoutError = /*#__PURE__*/function (_Error) {
|
|
1127
|
+
_inherits(TimeoutError, _Error);
|
|
599
1128
|
function TimeoutError(message) {
|
|
600
|
-
var _this
|
|
1129
|
+
var _this;
|
|
1130
|
+
_classCallCheck(this, TimeoutError);
|
|
1131
|
+
_this = _callSuper(this, TimeoutError, [message]);
|
|
601
1132
|
_this.name = 'TimeoutError';
|
|
602
1133
|
_this.code = 'ETIMEDOUT';
|
|
603
1134
|
_this.timestamp = new Date();
|
|
604
1135
|
// Maintain proper stack trace (only available in V8 engines, e.g., Chrome and Node.js)
|
|
605
1136
|
if (Error.captureStackTrace) {
|
|
606
|
-
Error.captureStackTrace(_this, TimeoutError);
|
|
1137
|
+
Error.captureStackTrace(_assertThisInitialized(_this), TimeoutError);
|
|
607
1138
|
}
|
|
608
1139
|
return _this;
|
|
609
1140
|
}
|
|
610
|
-
return TimeoutError;
|
|
611
|
-
}(Error);
|
|
1141
|
+
return _createClass(TimeoutError);
|
|
1142
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
612
1143
|
function withTimeout(fn, timeout) {
|
|
613
1144
|
return function () {
|
|
614
|
-
var args =
|
|
615
|
-
|
|
616
|
-
args[_i] = arguments[_i];
|
|
1145
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1146
|
+
args[_key] = arguments[_key];
|
|
617
1147
|
}
|
|
618
1148
|
return new Promise(function (resolve, reject) {
|
|
619
1149
|
var timer = setTimeout(function () {
|
|
@@ -627,15 +1157,15 @@ function withTimeout(fn, timeout) {
|
|
|
627
1157
|
}
|
|
628
1158
|
|
|
629
1159
|
var SKIPPED = Symbol();
|
|
630
|
-
function batchFn(itemFn
|
|
631
|
-
var
|
|
632
|
-
|
|
633
|
-
batchSize =
|
|
634
|
-
skip =
|
|
635
|
-
|
|
636
|
-
retry =
|
|
637
|
-
timeout =
|
|
638
|
-
rollback =
|
|
1160
|
+
function batchFn(itemFn) {
|
|
1161
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1162
|
+
_ref$batchSize = _ref.batchSize,
|
|
1163
|
+
batchSize = _ref$batchSize === void 0 ? 10 : _ref$batchSize,
|
|
1164
|
+
skip = _ref.skip,
|
|
1165
|
+
_ref$retry = _ref.retry,
|
|
1166
|
+
retry = _ref$retry === void 0 ? false : _ref$retry,
|
|
1167
|
+
timeout = _ref.timeout,
|
|
1168
|
+
rollback = _ref.rollback;
|
|
639
1169
|
//
|
|
640
1170
|
// Optionally wrap itemFn into timeout
|
|
641
1171
|
//
|
|
@@ -647,11 +1177,11 @@ function batchFn(itemFn, _a) {
|
|
|
647
1177
|
// const events = new EventEmitter<EventTypes>()
|
|
648
1178
|
var progressCount = 0;
|
|
649
1179
|
var resultsPromise = promiseReduce(batches, function (acc, batchItems, index) {
|
|
650
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
1180
|
+
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1181
|
+
var _this2 = this;
|
|
651
1182
|
var batch, batchResults;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
switch (_a.label) {
|
|
1183
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1184
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
655
1185
|
case 0:
|
|
656
1186
|
batch = {
|
|
657
1187
|
index: index,
|
|
@@ -660,40 +1190,49 @@ function batchFn(itemFn, _a) {
|
|
|
660
1190
|
promise.emit('batchStart', {
|
|
661
1191
|
batch: batch
|
|
662
1192
|
});
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
1193
|
+
//
|
|
1194
|
+
// A batch items are executed in parallell
|
|
1195
|
+
//
|
|
1196
|
+
_context2.next = 4;
|
|
1197
|
+
return Promise.all(batchItems.map(function (item) {
|
|
1198
|
+
return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1199
|
+
var itemSkip, itemResult;
|
|
1200
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1201
|
+
while (1) switch (_context.prev = _context.next) {
|
|
668
1202
|
case 0:
|
|
669
|
-
|
|
1203
|
+
_context.prev = 0;
|
|
670
1204
|
promise.emit('itemStart', {
|
|
671
1205
|
batch: batch,
|
|
672
1206
|
item: item
|
|
673
1207
|
});
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
1208
|
+
_context.next = 4;
|
|
1209
|
+
return typeof skip === 'function' && skip(item);
|
|
1210
|
+
case 4:
|
|
1211
|
+
itemSkip = _context.sent;
|
|
677
1212
|
if (itemSkip) {
|
|
678
1213
|
promise.emit('itemSkip', {
|
|
679
1214
|
batch: batch,
|
|
680
1215
|
item: item
|
|
681
1216
|
});
|
|
682
1217
|
}
|
|
683
|
-
if (!itemSkip)
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
1218
|
+
if (!itemSkip) {
|
|
1219
|
+
_context.next = 10;
|
|
1220
|
+
break;
|
|
1221
|
+
}
|
|
1222
|
+
_context.t0 = SKIPPED;
|
|
1223
|
+
_context.next = 13;
|
|
1224
|
+
break;
|
|
1225
|
+
case 10:
|
|
1226
|
+
_context.next = 12;
|
|
1227
|
+
return retry === true ? backOff(function () {
|
|
688
1228
|
return itemFn(item);
|
|
689
1229
|
}) : _typeof(retry) === 'object' && retry !== null ? backOff(function () {
|
|
690
1230
|
return itemFn(item);
|
|
691
|
-
}, retry) : itemFn(item)
|
|
692
|
-
case
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
itemResult = _a;
|
|
1231
|
+
}, retry) : itemFn(item);
|
|
1232
|
+
case 12:
|
|
1233
|
+
_context.t0 = _context.sent;
|
|
1234
|
+
case 13:
|
|
1235
|
+
itemResult = _context.t0;
|
|
697
1236
|
progressCount += 1;
|
|
698
1237
|
promise.emit('progress', {
|
|
699
1238
|
type: itemSkip ? 'skip' : 'data',
|
|
@@ -702,48 +1241,55 @@ function batchFn(itemFn, _a) {
|
|
|
702
1241
|
item: item,
|
|
703
1242
|
result: itemResult
|
|
704
1243
|
});
|
|
705
|
-
return
|
|
706
|
-
case
|
|
707
|
-
|
|
1244
|
+
return _context.abrupt("return", itemResult);
|
|
1245
|
+
case 19:
|
|
1246
|
+
_context.prev = 19;
|
|
1247
|
+
_context.t1 = _context["catch"](0);
|
|
708
1248
|
progressCount += 1;
|
|
709
1249
|
promise.emit('progress', {
|
|
710
1250
|
type: 'error',
|
|
711
1251
|
batch: batch,
|
|
712
1252
|
progress: progressCount / items.length,
|
|
713
1253
|
item: item,
|
|
714
|
-
result:
|
|
1254
|
+
result: _context.t1
|
|
715
1255
|
});
|
|
716
|
-
if (!(typeof rollback === 'function'))
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
case
|
|
731
|
-
return
|
|
1256
|
+
if (!(typeof rollback === 'function')) {
|
|
1257
|
+
_context.next = 32;
|
|
1258
|
+
break;
|
|
1259
|
+
}
|
|
1260
|
+
_context.prev = 24;
|
|
1261
|
+
_context.next = 27;
|
|
1262
|
+
return rollback(item, _context.t1);
|
|
1263
|
+
case 27:
|
|
1264
|
+
_context.next = 32;
|
|
1265
|
+
break;
|
|
1266
|
+
case 29:
|
|
1267
|
+
_context.prev = 29;
|
|
1268
|
+
_context.t2 = _context["catch"](24);
|
|
1269
|
+
console.error('Failure rolling back', _context.t2);
|
|
1270
|
+
case 32:
|
|
1271
|
+
return _context.abrupt("return", _context.t1);
|
|
1272
|
+
case 33:
|
|
1273
|
+
case "end":
|
|
1274
|
+
return _context.stop();
|
|
732
1275
|
}
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
}))
|
|
736
|
-
case
|
|
737
|
-
batchResults =
|
|
1276
|
+
}, _callee, null, [[0, 19], [24, 29]]);
|
|
1277
|
+
}));
|
|
1278
|
+
}));
|
|
1279
|
+
case 4:
|
|
1280
|
+
batchResults = _context2.sent;
|
|
738
1281
|
promise.emit('batchProgress', {
|
|
739
1282
|
batch: batch,
|
|
740
1283
|
progress: batch.index + 1 / batches.length,
|
|
741
1284
|
results: batchResults
|
|
742
1285
|
});
|
|
743
|
-
return
|
|
1286
|
+
return _context2.abrupt("return", [].concat(_toConsumableArray(acc), _toConsumableArray(batchResults)));
|
|
1287
|
+
case 7:
|
|
1288
|
+
case "end":
|
|
1289
|
+
return _context2.stop();
|
|
744
1290
|
}
|
|
745
|
-
});
|
|
746
|
-
});
|
|
1291
|
+
}, _callee2);
|
|
1292
|
+
}));
|
|
747
1293
|
}, []);
|
|
748
1294
|
resultsPromise.then(function (results) {
|
|
749
1295
|
promise.resolve(results);
|
|
@@ -760,16 +1306,16 @@ function batchFn(itemFn, _a) {
|
|
|
760
1306
|
function parseBatchedResults(inputs, results) {
|
|
761
1307
|
return results.reduce(function (acc, result, index) {
|
|
762
1308
|
if (result === SKIPPED) {
|
|
763
|
-
return
|
|
764
|
-
skipped:
|
|
1309
|
+
return Object.assign(Object.assign({}, acc), {
|
|
1310
|
+
skipped: [].concat(_toConsumableArray(acc.skipped), [inputs[index]])
|
|
765
1311
|
});
|
|
766
1312
|
} else if (result instanceof Error) {
|
|
767
|
-
return
|
|
768
|
-
errors:
|
|
1313
|
+
return Object.assign(Object.assign({}, acc), {
|
|
1314
|
+
errors: [].concat(_toConsumableArray(acc.errors), [result])
|
|
769
1315
|
});
|
|
770
1316
|
} else {
|
|
771
|
-
return
|
|
772
|
-
results:
|
|
1317
|
+
return Object.assign(Object.assign({}, acc), {
|
|
1318
|
+
results: [].concat(_toConsumableArray(acc.results), [result])
|
|
773
1319
|
});
|
|
774
1320
|
}
|
|
775
1321
|
}, {
|
|
@@ -836,24 +1382,27 @@ function hasNestedPromises(input) {
|
|
|
836
1382
|
}
|
|
837
1383
|
function _makeDefaultAsyncExpFn(syncFn) {
|
|
838
1384
|
return function defaultAsyncExpFn() {
|
|
839
|
-
var args =
|
|
840
|
-
|
|
841
|
-
args[_i] = arguments[_i];
|
|
1385
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1386
|
+
args[_key] = arguments[_key];
|
|
842
1387
|
}
|
|
843
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1388
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
844
1389
|
var resolvedArgs;
|
|
845
|
-
return
|
|
846
|
-
switch (
|
|
1390
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1391
|
+
while (1) switch (_context.prev = _context.next) {
|
|
847
1392
|
case 0:
|
|
848
|
-
|
|
1393
|
+
_context.next = 2;
|
|
1394
|
+
return Promise.all(args.map(function (arg) {
|
|
849
1395
|
return resolveNestedPromises(arg);
|
|
850
|
-
}))
|
|
851
|
-
case
|
|
852
|
-
resolvedArgs =
|
|
853
|
-
return
|
|
1396
|
+
}));
|
|
1397
|
+
case 2:
|
|
1398
|
+
resolvedArgs = _context.sent;
|
|
1399
|
+
return _context.abrupt("return", syncFn.apply(void 0, _toConsumableArray(resolvedArgs)));
|
|
1400
|
+
case 4:
|
|
1401
|
+
case "end":
|
|
1402
|
+
return _context.stop();
|
|
854
1403
|
}
|
|
855
|
-
});
|
|
856
|
-
});
|
|
1404
|
+
}, _callee);
|
|
1405
|
+
}));
|
|
857
1406
|
};
|
|
858
1407
|
}
|
|
859
1408
|
function _defaultArgsContainPromises(args) {
|
|
@@ -872,44 +1421,15 @@ function _defaultArgsContainPromises(args) {
|
|
|
872
1421
|
* in the inputs and executes sync or async versions
|
|
873
1422
|
* accordingly
|
|
874
1423
|
*/
|
|
875
|
-
function maybeAsyncFn(
|
|
876
|
-
var syncFn =
|
|
877
|
-
|
|
878
|
-
asyncFn =
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
// if the any of the arguments provided are
|
|
882
|
-
// themselves a promise or if they have a nested promise
|
|
883
|
-
//
|
|
884
|
-
// Allow the argsContainPromises to be configurable.
|
|
885
|
-
// This allows for more specialized checks that
|
|
886
|
-
// would perform better, some examples:
|
|
887
|
-
// - If the first argument includes a promise
|
|
888
|
-
// - If some deeply nested argument is set
|
|
889
|
-
// to a value that will incur in the need
|
|
890
|
-
// for async resolution, even if the input arg
|
|
891
|
-
// itself is not a promise
|
|
892
|
-
//
|
|
893
|
-
_c = _a.argsContainPromises,
|
|
894
|
-
//
|
|
895
|
-
// By default, argsContainPromises checks
|
|
896
|
-
// if the any of the arguments provided are
|
|
897
|
-
// themselves a promise or if they have a nested promise
|
|
898
|
-
//
|
|
899
|
-
// Allow the argsContainPromises to be configurable.
|
|
900
|
-
// This allows for more specialized checks that
|
|
901
|
-
// would perform better, some examples:
|
|
902
|
-
// - If the first argument includes a promise
|
|
903
|
-
// - If some deeply nested argument is set
|
|
904
|
-
// to a value that will incur in the need
|
|
905
|
-
// for async resolution, even if the input arg
|
|
906
|
-
// itself is not a promise
|
|
907
|
-
//
|
|
908
|
-
argsContainPromises = _c === void 0 ? _defaultArgsContainPromises : _c;
|
|
1424
|
+
function maybeAsyncFn(_ref) {
|
|
1425
|
+
var syncFn = _ref.syncFn,
|
|
1426
|
+
_ref$asyncFn = _ref.asyncFn,
|
|
1427
|
+
asyncFn = _ref$asyncFn === void 0 ? _makeDefaultAsyncExpFn(syncFn) : _ref$asyncFn,
|
|
1428
|
+
_ref$argsContainPromi = _ref.argsContainPromises,
|
|
1429
|
+
argsContainPromises = _ref$argsContainPromi === void 0 ? _defaultArgsContainPromises : _ref$argsContainPromi;
|
|
909
1430
|
return function () {
|
|
910
|
-
var args =
|
|
911
|
-
|
|
912
|
-
args[_i] = arguments[_i];
|
|
1431
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1432
|
+
args[_key2] = arguments[_key2];
|
|
913
1433
|
}
|
|
914
1434
|
return argsContainPromises(args) ? asyncFn.apply(void 0, args) : syncFn.apply(void 0, args);
|
|
915
1435
|
};
|
|
@@ -933,9 +1453,9 @@ function untilConditionIsSatisfiedReducer(condition, reduce) {
|
|
|
933
1453
|
//
|
|
934
1454
|
var syncResult = reduce(acc, value, index, allValues);
|
|
935
1455
|
if (isPromise(syncResult)) {
|
|
936
|
-
var
|
|
1456
|
+
var remainingValues = allValues.slice(index + 1);
|
|
937
1457
|
return syncResult.then(function (asyncResult) {
|
|
938
|
-
return condition(asyncResult) ? asyncResult :
|
|
1458
|
+
return condition(asyncResult) ? asyncResult : remainingValues.reduce(reducer, asyncResult);
|
|
939
1459
|
});
|
|
940
1460
|
} else {
|
|
941
1461
|
return syncResult;
|
|
@@ -948,10 +1468,8 @@ function maybeReturnPromise(result, parseResult) {
|
|
|
948
1468
|
return isPromise(result) ? result.then(parseResult) : parseResult(result);
|
|
949
1469
|
}
|
|
950
1470
|
|
|
951
|
-
function syntheticJson(str
|
|
952
|
-
|
|
953
|
-
maxLength = 10000;
|
|
954
|
-
}
|
|
1471
|
+
function syntheticJson(str) {
|
|
1472
|
+
var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10000;
|
|
955
1473
|
// Step 0: Reject overly long input early to prevent
|
|
956
1474
|
// any possible vulnerability with ReDoS
|
|
957
1475
|
if (str.length > maxLength) {
|
|
@@ -993,15 +1511,16 @@ function _jsonLikeParseArgs(argsStr) {
|
|
|
993
1511
|
function escapeRegExp(str) {
|
|
994
1512
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
995
1513
|
}
|
|
996
|
-
function strExpr(
|
|
997
|
-
var expressions =
|
|
998
|
-
|
|
999
|
-
pipe =
|
|
1000
|
-
|
|
1001
|
-
parseArgs =
|
|
1002
|
-
var
|
|
1003
|
-
|
|
1004
|
-
|
|
1514
|
+
function strExpr(_ref) {
|
|
1515
|
+
var expressions = _ref.expressions,
|
|
1516
|
+
_ref$pipe = _ref.pipe,
|
|
1517
|
+
pipe = _ref$pipe === void 0 ? '|' : _ref$pipe,
|
|
1518
|
+
_ref$parseArgs = _ref.parseArgs,
|
|
1519
|
+
parseArgs = _ref$parseArgs === void 0 ? _jsonLikeParseArgs : _ref$parseArgs;
|
|
1520
|
+
var _ref2 = Array.isArray(expressions) ? [expressions, null] : [Object.keys(expressions), expressions],
|
|
1521
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
1522
|
+
expressionIds = _ref3[0],
|
|
1523
|
+
expressionFns = _ref3[1];
|
|
1005
1524
|
if (expressionIds.length === 0) {
|
|
1006
1525
|
throw new Error('No expressions provided');
|
|
1007
1526
|
}
|
|
@@ -1112,11 +1631,10 @@ function switchValue(input, cases) {
|
|
|
1112
1631
|
}
|
|
1113
1632
|
}
|
|
1114
1633
|
function switchExec(input, cases) {
|
|
1115
|
-
var args = [];
|
|
1116
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1117
|
-
args[_i - 2] = arguments[_i];
|
|
1118
|
-
}
|
|
1119
1634
|
var fn = switchValue(input, cases);
|
|
1635
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1636
|
+
args[_key - 2] = arguments[_key];
|
|
1637
|
+
}
|
|
1120
1638
|
return fn.apply(void 0, args);
|
|
1121
1639
|
}
|
|
1122
1640
|
|
|
@@ -1197,26 +1715,31 @@ var typeOf = makeTypeOf(DEFAULT_TYPES);
|
|
|
1197
1715
|
function defaultParseResponse(response) {
|
|
1198
1716
|
return response.json();
|
|
1199
1717
|
}
|
|
1200
|
-
function paginatedHttpFetch(
|
|
1201
|
-
var pageUrl =
|
|
1202
|
-
|
|
1203
|
-
parseResponse =
|
|
1718
|
+
function paginatedHttpFetch(_ref) {
|
|
1719
|
+
var pageUrl = _ref.pageUrl,
|
|
1720
|
+
_ref$parseResponse = _ref.parseResponse,
|
|
1721
|
+
parseResponse = _ref$parseResponse === void 0 ? defaultParseResponse : _ref$parseResponse;
|
|
1204
1722
|
return function (params) {
|
|
1205
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1723
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1206
1724
|
var response, data;
|
|
1207
|
-
return
|
|
1208
|
-
switch (
|
|
1725
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1726
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1209
1727
|
case 0:
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
response = _a.sent();
|
|
1213
|
-
return [4 /*yield*/, parseResponse(response)];
|
|
1728
|
+
_context.next = 2;
|
|
1729
|
+
return fetch(pageUrl(params));
|
|
1214
1730
|
case 2:
|
|
1215
|
-
|
|
1216
|
-
|
|
1731
|
+
response = _context.sent;
|
|
1732
|
+
_context.next = 5;
|
|
1733
|
+
return parseResponse(response);
|
|
1734
|
+
case 5:
|
|
1735
|
+
data = _context.sent;
|
|
1736
|
+
return _context.abrupt("return", data);
|
|
1737
|
+
case 7:
|
|
1738
|
+
case "end":
|
|
1739
|
+
return _context.stop();
|
|
1217
1740
|
}
|
|
1218
|
-
});
|
|
1219
|
-
});
|
|
1741
|
+
}, _callee);
|
|
1742
|
+
}));
|
|
1220
1743
|
};
|
|
1221
1744
|
}
|
|
1222
1745
|
function inMemoryDataStore() {
|
|
@@ -1226,68 +1749,69 @@ function inMemoryDataStore() {
|
|
|
1226
1749
|
return data.length;
|
|
1227
1750
|
},
|
|
1228
1751
|
storePage: function storePage(pageData) {
|
|
1229
|
-
data =
|
|
1752
|
+
data = [].concat(_toConsumableArray(data), _toConsumableArray(pageData));
|
|
1230
1753
|
},
|
|
1231
1754
|
getResult: function getResult() {
|
|
1232
1755
|
return data;
|
|
1233
1756
|
}
|
|
1234
1757
|
};
|
|
1235
1758
|
}
|
|
1236
|
-
function fetchAllPages(
|
|
1237
|
-
var fetchPage =
|
|
1238
|
-
|
|
1239
|
-
pageSize =
|
|
1240
|
-
|
|
1241
|
-
dataStore =
|
|
1242
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1759
|
+
function fetchAllPages(_ref2) {
|
|
1760
|
+
var fetchPage = _ref2.fetchPage,
|
|
1761
|
+
_ref2$pageSize = _ref2.pageSize,
|
|
1762
|
+
pageSize = _ref2$pageSize === void 0 ? 50 : _ref2$pageSize,
|
|
1763
|
+
_ref2$dataStore = _ref2.dataStore,
|
|
1764
|
+
dataStore = _ref2$dataStore === void 0 ? inMemoryDataStore : _ref2$dataStore;
|
|
1765
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1243
1766
|
var store, currentPageData, currentOffset, result;
|
|
1244
|
-
return
|
|
1245
|
-
switch (
|
|
1767
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1768
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1246
1769
|
case 0:
|
|
1247
1770
|
store = dataStore();
|
|
1248
1771
|
currentPageData = null;
|
|
1249
|
-
_d.label = 1;
|
|
1250
|
-
case 1:
|
|
1251
|
-
return [4 /*yield*/, store.getSize()];
|
|
1252
1772
|
case 2:
|
|
1253
|
-
|
|
1254
|
-
return
|
|
1773
|
+
_context2.next = 4;
|
|
1774
|
+
return store.getSize();
|
|
1775
|
+
case 4:
|
|
1776
|
+
currentOffset = _context2.sent;
|
|
1777
|
+
_context2.next = 7;
|
|
1778
|
+
return fetchPage({
|
|
1255
1779
|
offset: currentOffset,
|
|
1256
1780
|
pageSize: pageSize
|
|
1257
|
-
})
|
|
1258
|
-
case
|
|
1259
|
-
currentPageData =
|
|
1260
|
-
|
|
1781
|
+
});
|
|
1782
|
+
case 7:
|
|
1783
|
+
currentPageData = _context2.sent;
|
|
1784
|
+
_context2.next = 10;
|
|
1785
|
+
return store.storePage(currentPageData, {
|
|
1261
1786
|
offset: currentOffset,
|
|
1262
1787
|
pageSize: pageSize
|
|
1263
|
-
})
|
|
1264
|
-
case
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
return
|
|
1272
|
-
case
|
|
1273
|
-
result =
|
|
1274
|
-
return
|
|
1788
|
+
});
|
|
1789
|
+
case 10:
|
|
1790
|
+
if (currentPageData.length === pageSize) {
|
|
1791
|
+
_context2.next = 2;
|
|
1792
|
+
break;
|
|
1793
|
+
}
|
|
1794
|
+
case 11:
|
|
1795
|
+
_context2.next = 13;
|
|
1796
|
+
return store.getResult();
|
|
1797
|
+
case 13:
|
|
1798
|
+
result = _context2.sent;
|
|
1799
|
+
return _context2.abrupt("return", result);
|
|
1800
|
+
case 15:
|
|
1801
|
+
case "end":
|
|
1802
|
+
return _context2.stop();
|
|
1275
1803
|
}
|
|
1276
|
-
});
|
|
1277
|
-
});
|
|
1804
|
+
}, _callee2);
|
|
1805
|
+
}));
|
|
1278
1806
|
}
|
|
1279
1807
|
|
|
1280
1808
|
function deprecateFn(fn, message) {
|
|
1281
1809
|
// Creating a new function that wraps the original function
|
|
1282
1810
|
var wrappedFunction = function wrappedFunction() {
|
|
1283
|
-
var args = [];
|
|
1284
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1285
|
-
args[_i] = arguments[_i];
|
|
1286
|
-
}
|
|
1287
1811
|
if (process.env.NODE_ENV !== 'production') {
|
|
1288
1812
|
console.warn(["[deprecated][fn] ".concat(fn.name, " is deprecated"), message].filter(Boolean).join(': '));
|
|
1289
1813
|
}
|
|
1290
|
-
return fn.apply(void 0,
|
|
1814
|
+
return fn.apply(void 0, arguments);
|
|
1291
1815
|
};
|
|
1292
1816
|
// Copying the original function's properties to the new function
|
|
1293
1817
|
Object.assign(wrappedFunction, fn);
|
|
@@ -1322,10 +1846,8 @@ function deprecateInput(inputValue, message, convert) {
|
|
|
1322
1846
|
}
|
|
1323
1847
|
}
|
|
1324
1848
|
|
|
1325
|
-
function slugify(str
|
|
1326
|
-
|
|
1327
|
-
delimiter = '-';
|
|
1328
|
-
}
|
|
1849
|
+
function slugify(str) {
|
|
1850
|
+
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '-';
|
|
1329
1851
|
// Escape the delimiter for safe use in regex
|
|
1330
1852
|
var safeDelimiter = delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
1331
1853
|
var CONSECUTIVE_DELIMITER_RE = new RegExp("".concat(safeDelimiter, "+"), 'g');
|
|
@@ -1340,77 +1862,95 @@ function slugify(str, delimiter) {
|
|
|
1340
1862
|
}
|
|
1341
1863
|
var normalizeString = deprecateFn(slugify, 'normalizeString is depreacted, use @orioro/util -> slugify instead');
|
|
1342
1864
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
before = _a.before,
|
|
1350
|
-
output = _a.output,
|
|
1351
|
-
after = _a.after;
|
|
1865
|
+
function hookFn(fn, _ref) {
|
|
1866
|
+
var input = _ref.input,
|
|
1867
|
+
validate = _ref.validate,
|
|
1868
|
+
before = _ref.before,
|
|
1869
|
+
output = _ref.output,
|
|
1870
|
+
after = _ref.after;
|
|
1352
1871
|
return function () {
|
|
1353
|
-
var args =
|
|
1354
|
-
|
|
1355
|
-
args[_i] = arguments[_i];
|
|
1872
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1873
|
+
args[_key] = arguments[_key];
|
|
1356
1874
|
}
|
|
1357
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1358
|
-
var _input,
|
|
1359
|
-
return
|
|
1360
|
-
switch (
|
|
1875
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1876
|
+
var _input, validationResult, error, rawResult, result;
|
|
1877
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1878
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1361
1879
|
case 0:
|
|
1362
|
-
if (!(typeof input === 'function'))
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
_a = _c.sent();
|
|
1366
|
-
return [3 /*break*/, 3];
|
|
1367
|
-
case 2:
|
|
1368
|
-
_a = args;
|
|
1369
|
-
_c.label = 3;
|
|
1370
|
-
case 3:
|
|
1371
|
-
_input = _a;
|
|
1372
|
-
if (!Array.isArray(_input)) {
|
|
1373
|
-
throw new TypeError('Input hook must resolve an array of args');
|
|
1880
|
+
if (!(typeof input === 'function')) {
|
|
1881
|
+
_context.next = 6;
|
|
1882
|
+
break;
|
|
1374
1883
|
}
|
|
1375
|
-
|
|
1376
|
-
return
|
|
1377
|
-
case
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
throw error;
|
|
1382
|
-
}
|
|
1383
|
-
_c.label = 5;
|
|
1384
|
-
case 5:
|
|
1385
|
-
if (!(typeof before === 'function')) return [3 /*break*/, 7];
|
|
1386
|
-
return [4 /*yield*/, before.apply(void 0, _input)];
|
|
1884
|
+
_context.next = 3;
|
|
1885
|
+
return input.apply(void 0, args);
|
|
1886
|
+
case 3:
|
|
1887
|
+
_context.t0 = _context.sent;
|
|
1888
|
+
_context.next = 7;
|
|
1889
|
+
break;
|
|
1387
1890
|
case 6:
|
|
1388
|
-
|
|
1389
|
-
_c.label = 7;
|
|
1891
|
+
_context.t0 = args;
|
|
1390
1892
|
case 7:
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
_b = _c.sent();
|
|
1398
|
-
return [3 /*break*/, 11];
|
|
1893
|
+
_input = _context.t0;
|
|
1894
|
+
if (Array.isArray(_input)) {
|
|
1895
|
+
_context.next = 10;
|
|
1896
|
+
break;
|
|
1897
|
+
}
|
|
1898
|
+
throw new TypeError('Input hook must resolve an array of args');
|
|
1399
1899
|
case 10:
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
return
|
|
1406
|
-
case 12:
|
|
1407
|
-
_c.sent();
|
|
1408
|
-
_c.label = 13;
|
|
1900
|
+
if (!(typeof validate === 'function')) {
|
|
1901
|
+
_context.next = 17;
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
_context.next = 13;
|
|
1905
|
+
return validate.apply(void 0, _toConsumableArray(_input));
|
|
1409
1906
|
case 13:
|
|
1410
|
-
|
|
1907
|
+
validationResult = _context.sent;
|
|
1908
|
+
if (!(validationResult !== true)) {
|
|
1909
|
+
_context.next = 17;
|
|
1910
|
+
break;
|
|
1911
|
+
}
|
|
1912
|
+
error = typeof validationResult === 'string' ? new Error(validationResult) : validationResult instanceof Error ? validationResult : new Error('Invalid input');
|
|
1913
|
+
throw error;
|
|
1914
|
+
case 17:
|
|
1915
|
+
if (!(typeof before === 'function')) {
|
|
1916
|
+
_context.next = 20;
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1919
|
+
_context.next = 20;
|
|
1920
|
+
return before.apply(void 0, _toConsumableArray(_input));
|
|
1921
|
+
case 20:
|
|
1922
|
+
_context.next = 22;
|
|
1923
|
+
return fn.apply(void 0, _toConsumableArray(_input));
|
|
1924
|
+
case 22:
|
|
1925
|
+
rawResult = _context.sent;
|
|
1926
|
+
if (!(typeof output === 'function')) {
|
|
1927
|
+
_context.next = 29;
|
|
1928
|
+
break;
|
|
1929
|
+
}
|
|
1930
|
+
_context.next = 26;
|
|
1931
|
+
return output(rawResult);
|
|
1932
|
+
case 26:
|
|
1933
|
+
_context.t1 = _context.sent;
|
|
1934
|
+
_context.next = 30;
|
|
1935
|
+
break;
|
|
1936
|
+
case 29:
|
|
1937
|
+
_context.t1 = rawResult;
|
|
1938
|
+
case 30:
|
|
1939
|
+
result = _context.t1;
|
|
1940
|
+
if (!(typeof after === 'function')) {
|
|
1941
|
+
_context.next = 34;
|
|
1942
|
+
break;
|
|
1943
|
+
}
|
|
1944
|
+
_context.next = 34;
|
|
1945
|
+
return after.apply(void 0, [result].concat(_toConsumableArray(_input)));
|
|
1946
|
+
case 34:
|
|
1947
|
+
return _context.abrupt("return", result);
|
|
1948
|
+
case 35:
|
|
1949
|
+
case "end":
|
|
1950
|
+
return _context.stop();
|
|
1411
1951
|
}
|
|
1412
|
-
});
|
|
1413
|
-
});
|
|
1952
|
+
}, _callee);
|
|
1953
|
+
}));
|
|
1414
1954
|
};
|
|
1415
1955
|
}
|
|
1416
1956
|
|
|
@@ -1464,23 +2004,23 @@ function url(spec) {
|
|
|
1464
2004
|
if (typeof spec === 'string') {
|
|
1465
2005
|
return new URL(spec).href;
|
|
1466
2006
|
} else {
|
|
1467
|
-
var
|
|
1468
|
-
if (spec.protocol)
|
|
1469
|
-
if (spec.username)
|
|
1470
|
-
if (spec.password)
|
|
1471
|
-
if (spec.host)
|
|
1472
|
-
if (spec.hostname)
|
|
1473
|
-
if (spec.port)
|
|
1474
|
-
if (spec.pathname)
|
|
1475
|
-
if (spec.search)
|
|
2007
|
+
var _url = new URL(_baseHref(spec));
|
|
2008
|
+
if (spec.protocol) _url.protocol = spec.protocol;
|
|
2009
|
+
if (spec.username) _url.username = spec.username;
|
|
2010
|
+
if (spec.password) _url.password = spec.password;
|
|
2011
|
+
if (spec.host) _url.host = spec.host;
|
|
2012
|
+
if (spec.hostname) _url.hostname = spec.hostname;
|
|
2013
|
+
if (spec.port) _url.port = spec.port;
|
|
2014
|
+
if (spec.pathname) _url.pathname = spec.pathname;
|
|
2015
|
+
if (spec.search) _url.search = spec.search;
|
|
1476
2016
|
// Handle searchParams
|
|
1477
2017
|
if (spec.searchParams) {
|
|
1478
2018
|
var searchString = Array.isArray(spec.searchParams) ? queryString.stringify(spec.searchParams[0], spec.searchParams[1]) : queryString.stringify(spec.searchParams);
|
|
1479
|
-
|
|
2019
|
+
_url.search = searchString;
|
|
1480
2020
|
}
|
|
1481
|
-
if (spec.hash)
|
|
1482
|
-
return
|
|
2021
|
+
if (spec.hash) _url.hash = spec.hash;
|
|
2022
|
+
return _url.href;
|
|
1483
2023
|
}
|
|
1484
2024
|
}
|
|
1485
2025
|
|
|
1486
|
-
export { DEFAULT_TYPES, PromiseLikeEventEmitter, SKIPPED, TimeoutError, arrayChunk, batchFn, dataJoin, debugFn, deepFreeze, deprecateFn, deprecateInput, deprecateProperty, fetchAllPages, hasNestedPromises, hookFn, inMemoryDataStore, interpolate, isPromise, isValidUrl, makeDeferred, makeTypeOf, maybeAsyncFn, maybeFn, maybeReturnPromise, normalizeString, paginatedHttpFetch, parseBatchedResults, pickPaths, promiseReduce, resolveNestedPromises, sequentialCallIdGenerator, slugify, strExpr, switchExec, switchValue, syntheticJson, typeMap, typeOf, untilConditionIsSatisfiedReducer, url, wait, withTimeout };
|
|
2026
|
+
export { DEFAULT_TYPES, PromiseLikeEventEmitter, SKIPPED, TimeoutError, arrayChunk, arrayLikeIterable, batchFn, dataJoin, debugFn, deepFreeze, deprecateFn, deprecateInput, deprecateProperty, fetchAllPages, hasNestedPromises, hookFn, inMemoryDataStore, interpolate, isPromise, isValidUrl, makeDeferred, makeTypeOf, maybeAsyncFn, maybeFn, maybeReturnPromise, normalizeString, paginatedHttpFetch, parseBatchedResults, pickPaths, promiseReduce, resolveNestedPromises, sequentialCallIdGenerator, slugify, strExpr, switchExec, switchValue, syntheticJson, typeMap, typeOf, untilConditionIsSatisfiedReducer, url, wait, withTimeout };
|