tsu 1.0.2 → 1.1.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.
@@ -1,1461 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /**
6
- * Removes the first n items of an array.
7
- *
8
- * @param n - The number of items to remove.
9
- * @param array - The array.
10
- * @returns The remaining items.
11
- */
12
- function drop(n, array) {
13
- if (n <= 0) {
14
- return [].concat(array);
15
- }
16
-
17
- return array.slice(n);
18
- }
19
- /**
20
- * Returns the first item of an array.
21
- *
22
- * @param array - The array.
23
- * @returns The first item.
24
- */
25
-
26
- function head(array) {
27
- return array[0];
28
- }
29
- /**
30
- * Returns all but the last item of an array.
31
- *
32
- * @param array - The array.
33
- * @returns The array without the last item.
34
- */
35
-
36
- function init(array) {
37
- return array.slice(0, array.length - 1);
38
- }
39
- /**
40
- * Returns the last item of an array.
41
- *
42
- * @param array - The array.
43
- * @returns The last item.
44
- */
45
-
46
- function last(array) {
47
- return array[array.length - 1];
48
- }
49
- /**
50
- * Returns the maximum number of an array.
51
- *
52
- * @param array - The array of numbers.
53
- * @returns The maximum number.
54
- */
55
-
56
- function max(array) {
57
- if (!array.length) {
58
- return;
59
- }
60
-
61
- return Math.max.apply(Math, array);
62
- }
63
- /**
64
- * Returns the minimum number of an array.
65
- *
66
- * @param array - The array of numbers.
67
- * @returns The minimum number.
68
- */
69
-
70
- function min(array) {
71
- if (!array.length) {
72
- return;
73
- }
74
-
75
- return Math.min.apply(Math, array);
76
- }
77
- /**
78
- * Splits an array into two based on a predicate function.
79
- *
80
- * @param filter - The predicate function.
81
- * @param array - The array.
82
- * @returns The array split in two.
83
- */
84
-
85
- function partition(filter, array) {
86
- return array.reduce(function (_ref, item, idx, arr) {
87
- var passed = _ref[0],
88
- failed = _ref[1];
89
-
90
- if (filter(item, idx, arr)) {
91
- return [[].concat(passed, [item]), failed];
92
- }
93
-
94
- return [passed, [].concat(failed, [item])];
95
- }, [[], []]);
96
- }
97
- /**
98
- * Splits an array into two at a given index.
99
- *
100
- * @param i - The position to split at.
101
- * @param array - The array.
102
- * @returns The array split in two.
103
- */
104
-
105
- function splitAt(i, array) {
106
- if (i <= 0) {
107
- return [[], [].concat(array)];
108
- }
109
-
110
- return [array.slice(0, i), array.slice(i)];
111
- }
112
- /**
113
- * Returns the sum of the numbers of an array.
114
- *
115
- * @param array - The array of numbers.
116
- * @returns The sum.
117
- */
118
-
119
- function sum(array) {
120
- if (!array.length) {
121
- return 0;
122
- }
123
-
124
- return array.reduce(function (sum, current) {
125
- return sum + current;
126
- }, 0);
127
- }
128
- /**
129
- * Returns all but the first item of an array.
130
- *
131
- * @param array - The array.
132
- * @returns The array without the first item.
133
- */
134
-
135
- function tail(array) {
136
- return array.slice(1);
137
- }
138
- /**
139
- * Returns the first n items of an array.
140
- *
141
- * @param n - The number of items to return.
142
- * @param array - The array.
143
- * @returns The first n items.
144
- */
145
-
146
- function take(n, array) {
147
- if (n <= 0) {
148
- return [];
149
- }
150
-
151
- return array.slice(0, n);
152
- }
153
- /**
154
- * Wraps a single value of an array, if not already an array.
155
- *
156
- * @param maybeArray - The value to wrap, or the existing array.
157
- * @returns The item wrapped in an array, or the provided array.
158
- */
159
-
160
- function toArray(maybeArray) {
161
- if (!maybeArray) {
162
- return [];
163
- }
164
-
165
- return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
166
- }
167
- /**
168
- * Removes duplicate primitive values from an array.
169
- *
170
- * @param array - The array.
171
- * @returns The array without duplicated primitive values.
172
- */
173
-
174
- function uniq(array) {
175
- return Array.from(new Set(array));
176
- }
177
-
178
- /**
179
- * Prevents a function from running until it hasn't been called for a certain time period.
180
- *
181
- * @param fn - The function.
182
- * @param delay - The time period (in ms).
183
- * @returns The debounced function.
184
- */
185
- function debounce(fn, delay) {
186
- var timeout;
187
- return function () {
188
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
189
- args[_key] = arguments[_key];
190
- }
191
-
192
- clearTimeout(timeout);
193
- timeout = setTimeout(function () {
194
- clearTimeout(timeout);
195
- fn.apply(void 0, args);
196
- }, delay);
197
- };
198
- }
199
- /**
200
- * Optimises subsequent calls of a function by caching return values.
201
- *
202
- * @param fn - The function.
203
- * @returns The memoized function.
204
- */
205
-
206
- function memoize(fn) {
207
- var cache = {};
208
- return function () {
209
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
210
- args[_key2] = arguments[_key2];
211
- }
212
-
213
- var argsString = JSON.stringify(args);
214
-
215
- if (argsString in cache) {
216
- return cache[argsString];
217
- }
218
-
219
- var result = fn.apply(void 0, args);
220
- cache[argsString] = result;
221
- return result;
222
- };
223
- }
224
- /**
225
- * Prevents a function from running for some time period after it was last called.
226
- *
227
- * @param fn - The function.
228
- * @param limit - The time period.
229
- * @returns The throttled function.
230
- */
231
-
232
- function throttle(fn, limit) {
233
- var isWaiting = false;
234
- return function () {
235
- if (!isWaiting) {
236
- fn.apply(void 0, arguments);
237
- isWaiting = true;
238
- setTimeout(function () {
239
- isWaiting = false;
240
- }, limit);
241
- }
242
- };
243
- }
244
-
245
- /**
246
- * Identifies if a value is an array.
247
- *
248
- * @param val - The value.
249
- * @returns If the value is an array.
250
- */
251
- function isArray(val) {
252
- return Array.isArray(val);
253
- }
254
- /**
255
- * Identifies if a value is a boolean.
256
- *
257
- * @param val - The value.
258
- * @returns If the value is a boolean.
259
- */
260
-
261
- function isBoolean(val) {
262
- return typeof val === 'boolean';
263
- }
264
- /**
265
- * Identifies if the code is being run in the browser.
266
- *
267
- * @returns If the code is being run on a browser.
268
- */
269
-
270
- function isBrowser() {
271
- return typeof window !== 'undefined';
272
- }
273
- /**
274
- * Identifies if a value is defined.
275
- *
276
- * @param val - The value.
277
- * @returns If the value is defined.
278
- */
279
-
280
- function isDefined(val) {
281
- return typeof val !== 'undefined';
282
- }
283
- /**
284
- * Identifies if a value is a function.
285
- *
286
- * @param val - The value.
287
- * @returns If the value is a function.
288
- */
289
-
290
- function isFunction(val) {
291
- return typeof val === 'function';
292
- }
293
- /**
294
- * Identifies if a value is a number.
295
- *
296
- * @param val - The value.
297
- * @returns If the value is a number.
298
- */
299
-
300
- function isNumber(val) {
301
- return typeof val === 'number';
302
- }
303
- /**
304
- * Identifies if a value is an object.
305
- *
306
- * @param val - The value.
307
- * @returns If the value is an object.
308
- */
309
-
310
- function isObject(val) {
311
- return Object.prototype.toString.call(val) === '[object Object]';
312
- }
313
- /**
314
- * Identifies if a value is a string.
315
- *
316
- * @param val - The value.
317
- * @returns If the value is a string.
318
- */
319
-
320
- function isString(val) {
321
- return typeof val === 'string';
322
- }
323
- /**
324
- * Identifies if a value is the global window.
325
- *
326
- * @param val - The value.
327
- * @returns If the value is the global window.
328
- */
329
-
330
- function isWindow(val) {
331
- return isBrowser() && toString.call(val) === '[object Window]';
332
- }
333
-
334
- /**
335
- * Identifies if a number is even.
336
- *
337
- * @param n - The number.
338
- * @returns If the number is even.
339
- */
340
- function isEven(n) {
341
- return n % 2 === 0;
342
- }
343
- /**
344
- * Identifies if a number is odd.
345
- *
346
- * @param n - The number.
347
- * @returns If the number is odd.
348
- */
349
-
350
- function isOdd(n) {
351
- return n % 2 !== 0;
352
- }
353
- /**
354
- * Opinionated implementation of modulo (%).
355
- *
356
- * @param n - The dividend.
357
- * @param m - The divisor.
358
- * @returns The remainder of dividing n by m.
359
- */
360
-
361
- function modulo(n, m) {
362
- return n - Math.floor(n / m) * m;
363
- }
364
- /**
365
- * Generates a random integer between bounds.
366
- *
367
- * @param max - The exclusive maximum bound.
368
- * @param min - The inclusive minimum bound.
369
- * @returns The random integer.
370
- */
371
-
372
- function randomNumber(max, min) {
373
- if (min === void 0) {
374
- min = 0;
375
- }
376
-
377
- return Math.floor(Math.random() * (max - min)) + min;
378
- }
379
- /**
380
- * Rolls an n-sided die.
381
- *
382
- * @param n - The number of sides on the die.
383
- * @returns If the die roll was 0.
384
- */
385
-
386
- function randomChance(n) {
387
- return randomNumber(n) === 0;
388
- }
389
-
390
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
391
- try {
392
- var info = gen[key](arg);
393
- var value = info.value;
394
- } catch (error) {
395
- reject(error);
396
- return;
397
- }
398
-
399
- if (info.done) {
400
- resolve(value);
401
- } else {
402
- Promise.resolve(value).then(_next, _throw);
403
- }
404
- }
405
-
406
- function _asyncToGenerator(fn) {
407
- return function () {
408
- var self = this,
409
- args = arguments;
410
- return new Promise(function (resolve, reject) {
411
- var gen = fn.apply(self, args);
412
-
413
- function _next(value) {
414
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
415
- }
416
-
417
- function _throw(err) {
418
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
419
- }
420
-
421
- _next(undefined);
422
- });
423
- };
424
- }
425
-
426
- function createCommonjsModule(fn, module) {
427
- return module = { exports: {} }, fn(module, module.exports), module.exports;
428
- }
429
-
430
- var runtime_1 = createCommonjsModule(function (module) {
431
- /**
432
- * Copyright (c) 2014-present, Facebook, Inc.
433
- *
434
- * This source code is licensed under the MIT license found in the
435
- * LICENSE file in the root directory of this source tree.
436
- */
437
-
438
- var runtime = (function (exports) {
439
-
440
- var Op = Object.prototype;
441
- var hasOwn = Op.hasOwnProperty;
442
- var undefined$1; // More compressible than void 0.
443
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
444
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
445
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
446
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
447
-
448
- function define(obj, key, value) {
449
- Object.defineProperty(obj, key, {
450
- value: value,
451
- enumerable: true,
452
- configurable: true,
453
- writable: true
454
- });
455
- return obj[key];
456
- }
457
- try {
458
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
459
- define({}, "");
460
- } catch (err) {
461
- define = function(obj, key, value) {
462
- return obj[key] = value;
463
- };
464
- }
465
-
466
- function wrap(innerFn, outerFn, self, tryLocsList) {
467
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
468
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
469
- var generator = Object.create(protoGenerator.prototype);
470
- var context = new Context(tryLocsList || []);
471
-
472
- // The ._invoke method unifies the implementations of the .next,
473
- // .throw, and .return methods.
474
- generator._invoke = makeInvokeMethod(innerFn, self, context);
475
-
476
- return generator;
477
- }
478
- exports.wrap = wrap;
479
-
480
- // Try/catch helper to minimize deoptimizations. Returns a completion
481
- // record like context.tryEntries[i].completion. This interface could
482
- // have been (and was previously) designed to take a closure to be
483
- // invoked without arguments, but in all the cases we care about we
484
- // already have an existing method we want to call, so there's no need
485
- // to create a new function object. We can even get away with assuming
486
- // the method takes exactly one argument, since that happens to be true
487
- // in every case, so we don't have to touch the arguments object. The
488
- // only additional allocation required is the completion record, which
489
- // has a stable shape and so hopefully should be cheap to allocate.
490
- function tryCatch(fn, obj, arg) {
491
- try {
492
- return { type: "normal", arg: fn.call(obj, arg) };
493
- } catch (err) {
494
- return { type: "throw", arg: err };
495
- }
496
- }
497
-
498
- var GenStateSuspendedStart = "suspendedStart";
499
- var GenStateSuspendedYield = "suspendedYield";
500
- var GenStateExecuting = "executing";
501
- var GenStateCompleted = "completed";
502
-
503
- // Returning this object from the innerFn has the same effect as
504
- // breaking out of the dispatch switch statement.
505
- var ContinueSentinel = {};
506
-
507
- // Dummy constructor functions that we use as the .constructor and
508
- // .constructor.prototype properties for functions that return Generator
509
- // objects. For full spec compliance, you may wish to configure your
510
- // minifier not to mangle the names of these two functions.
511
- function Generator() {}
512
- function GeneratorFunction() {}
513
- function GeneratorFunctionPrototype() {}
514
-
515
- // This is a polyfill for %IteratorPrototype% for environments that
516
- // don't natively support it.
517
- var IteratorPrototype = {};
518
- define(IteratorPrototype, iteratorSymbol, function () {
519
- return this;
520
- });
521
-
522
- var getProto = Object.getPrototypeOf;
523
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
524
- if (NativeIteratorPrototype &&
525
- NativeIteratorPrototype !== Op &&
526
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
527
- // This environment has a native %IteratorPrototype%; use it instead
528
- // of the polyfill.
529
- IteratorPrototype = NativeIteratorPrototype;
530
- }
531
-
532
- var Gp = GeneratorFunctionPrototype.prototype =
533
- Generator.prototype = Object.create(IteratorPrototype);
534
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
535
- define(Gp, "constructor", GeneratorFunctionPrototype);
536
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
537
- GeneratorFunction.displayName = define(
538
- GeneratorFunctionPrototype,
539
- toStringTagSymbol,
540
- "GeneratorFunction"
541
- );
542
-
543
- // Helper for defining the .next, .throw, and .return methods of the
544
- // Iterator interface in terms of a single ._invoke method.
545
- function defineIteratorMethods(prototype) {
546
- ["next", "throw", "return"].forEach(function(method) {
547
- define(prototype, method, function(arg) {
548
- return this._invoke(method, arg);
549
- });
550
- });
551
- }
552
-
553
- exports.isGeneratorFunction = function(genFun) {
554
- var ctor = typeof genFun === "function" && genFun.constructor;
555
- return ctor
556
- ? ctor === GeneratorFunction ||
557
- // For the native GeneratorFunction constructor, the best we can
558
- // do is to check its .name property.
559
- (ctor.displayName || ctor.name) === "GeneratorFunction"
560
- : false;
561
- };
562
-
563
- exports.mark = function(genFun) {
564
- if (Object.setPrototypeOf) {
565
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
566
- } else {
567
- genFun.__proto__ = GeneratorFunctionPrototype;
568
- define(genFun, toStringTagSymbol, "GeneratorFunction");
569
- }
570
- genFun.prototype = Object.create(Gp);
571
- return genFun;
572
- };
573
-
574
- // Within the body of any async function, `await x` is transformed to
575
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
576
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
577
- // meant to be awaited.
578
- exports.awrap = function(arg) {
579
- return { __await: arg };
580
- };
581
-
582
- function AsyncIterator(generator, PromiseImpl) {
583
- function invoke(method, arg, resolve, reject) {
584
- var record = tryCatch(generator[method], generator, arg);
585
- if (record.type === "throw") {
586
- reject(record.arg);
587
- } else {
588
- var result = record.arg;
589
- var value = result.value;
590
- if (value &&
591
- typeof value === "object" &&
592
- hasOwn.call(value, "__await")) {
593
- return PromiseImpl.resolve(value.__await).then(function(value) {
594
- invoke("next", value, resolve, reject);
595
- }, function(err) {
596
- invoke("throw", err, resolve, reject);
597
- });
598
- }
599
-
600
- return PromiseImpl.resolve(value).then(function(unwrapped) {
601
- // When a yielded Promise is resolved, its final value becomes
602
- // the .value of the Promise<{value,done}> result for the
603
- // current iteration.
604
- result.value = unwrapped;
605
- resolve(result);
606
- }, function(error) {
607
- // If a rejected Promise was yielded, throw the rejection back
608
- // into the async generator function so it can be handled there.
609
- return invoke("throw", error, resolve, reject);
610
- });
611
- }
612
- }
613
-
614
- var previousPromise;
615
-
616
- function enqueue(method, arg) {
617
- function callInvokeWithMethodAndArg() {
618
- return new PromiseImpl(function(resolve, reject) {
619
- invoke(method, arg, resolve, reject);
620
- });
621
- }
622
-
623
- return previousPromise =
624
- // If enqueue has been called before, then we want to wait until
625
- // all previous Promises have been resolved before calling invoke,
626
- // so that results are always delivered in the correct order. If
627
- // enqueue has not been called before, then it is important to
628
- // call invoke immediately, without waiting on a callback to fire,
629
- // so that the async generator function has the opportunity to do
630
- // any necessary setup in a predictable way. This predictability
631
- // is why the Promise constructor synchronously invokes its
632
- // executor callback, and why async functions synchronously
633
- // execute code before the first await. Since we implement simple
634
- // async functions in terms of async generators, it is especially
635
- // important to get this right, even though it requires care.
636
- previousPromise ? previousPromise.then(
637
- callInvokeWithMethodAndArg,
638
- // Avoid propagating failures to Promises returned by later
639
- // invocations of the iterator.
640
- callInvokeWithMethodAndArg
641
- ) : callInvokeWithMethodAndArg();
642
- }
643
-
644
- // Define the unified helper method that is used to implement .next,
645
- // .throw, and .return (see defineIteratorMethods).
646
- this._invoke = enqueue;
647
- }
648
-
649
- defineIteratorMethods(AsyncIterator.prototype);
650
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
651
- return this;
652
- });
653
- exports.AsyncIterator = AsyncIterator;
654
-
655
- // Note that simple async functions are implemented on top of
656
- // AsyncIterator objects; they just return a Promise for the value of
657
- // the final result produced by the iterator.
658
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
659
- if (PromiseImpl === void 0) PromiseImpl = Promise;
660
-
661
- var iter = new AsyncIterator(
662
- wrap(innerFn, outerFn, self, tryLocsList),
663
- PromiseImpl
664
- );
665
-
666
- return exports.isGeneratorFunction(outerFn)
667
- ? iter // If outerFn is a generator, return the full iterator.
668
- : iter.next().then(function(result) {
669
- return result.done ? result.value : iter.next();
670
- });
671
- };
672
-
673
- function makeInvokeMethod(innerFn, self, context) {
674
- var state = GenStateSuspendedStart;
675
-
676
- return function invoke(method, arg) {
677
- if (state === GenStateExecuting) {
678
- throw new Error("Generator is already running");
679
- }
680
-
681
- if (state === GenStateCompleted) {
682
- if (method === "throw") {
683
- throw arg;
684
- }
685
-
686
- // Be forgiving, per 25.3.3.3.3 of the spec:
687
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
688
- return doneResult();
689
- }
690
-
691
- context.method = method;
692
- context.arg = arg;
693
-
694
- while (true) {
695
- var delegate = context.delegate;
696
- if (delegate) {
697
- var delegateResult = maybeInvokeDelegate(delegate, context);
698
- if (delegateResult) {
699
- if (delegateResult === ContinueSentinel) continue;
700
- return delegateResult;
701
- }
702
- }
703
-
704
- if (context.method === "next") {
705
- // Setting context._sent for legacy support of Babel's
706
- // function.sent implementation.
707
- context.sent = context._sent = context.arg;
708
-
709
- } else if (context.method === "throw") {
710
- if (state === GenStateSuspendedStart) {
711
- state = GenStateCompleted;
712
- throw context.arg;
713
- }
714
-
715
- context.dispatchException(context.arg);
716
-
717
- } else if (context.method === "return") {
718
- context.abrupt("return", context.arg);
719
- }
720
-
721
- state = GenStateExecuting;
722
-
723
- var record = tryCatch(innerFn, self, context);
724
- if (record.type === "normal") {
725
- // If an exception is thrown from innerFn, we leave state ===
726
- // GenStateExecuting and loop back for another invocation.
727
- state = context.done
728
- ? GenStateCompleted
729
- : GenStateSuspendedYield;
730
-
731
- if (record.arg === ContinueSentinel) {
732
- continue;
733
- }
734
-
735
- return {
736
- value: record.arg,
737
- done: context.done
738
- };
739
-
740
- } else if (record.type === "throw") {
741
- state = GenStateCompleted;
742
- // Dispatch the exception by looping back around to the
743
- // context.dispatchException(context.arg) call above.
744
- context.method = "throw";
745
- context.arg = record.arg;
746
- }
747
- }
748
- };
749
- }
750
-
751
- // Call delegate.iterator[context.method](context.arg) and handle the
752
- // result, either by returning a { value, done } result from the
753
- // delegate iterator, or by modifying context.method and context.arg,
754
- // setting context.delegate to null, and returning the ContinueSentinel.
755
- function maybeInvokeDelegate(delegate, context) {
756
- var method = delegate.iterator[context.method];
757
- if (method === undefined$1) {
758
- // A .throw or .return when the delegate iterator has no .throw
759
- // method always terminates the yield* loop.
760
- context.delegate = null;
761
-
762
- if (context.method === "throw") {
763
- // Note: ["return"] must be used for ES3 parsing compatibility.
764
- if (delegate.iterator["return"]) {
765
- // If the delegate iterator has a return method, give it a
766
- // chance to clean up.
767
- context.method = "return";
768
- context.arg = undefined$1;
769
- maybeInvokeDelegate(delegate, context);
770
-
771
- if (context.method === "throw") {
772
- // If maybeInvokeDelegate(context) changed context.method from
773
- // "return" to "throw", let that override the TypeError below.
774
- return ContinueSentinel;
775
- }
776
- }
777
-
778
- context.method = "throw";
779
- context.arg = new TypeError(
780
- "The iterator does not provide a 'throw' method");
781
- }
782
-
783
- return ContinueSentinel;
784
- }
785
-
786
- var record = tryCatch(method, delegate.iterator, context.arg);
787
-
788
- if (record.type === "throw") {
789
- context.method = "throw";
790
- context.arg = record.arg;
791
- context.delegate = null;
792
- return ContinueSentinel;
793
- }
794
-
795
- var info = record.arg;
796
-
797
- if (! info) {
798
- context.method = "throw";
799
- context.arg = new TypeError("iterator result is not an object");
800
- context.delegate = null;
801
- return ContinueSentinel;
802
- }
803
-
804
- if (info.done) {
805
- // Assign the result of the finished delegate to the temporary
806
- // variable specified by delegate.resultName (see delegateYield).
807
- context[delegate.resultName] = info.value;
808
-
809
- // Resume execution at the desired location (see delegateYield).
810
- context.next = delegate.nextLoc;
811
-
812
- // If context.method was "throw" but the delegate handled the
813
- // exception, let the outer generator proceed normally. If
814
- // context.method was "next", forget context.arg since it has been
815
- // "consumed" by the delegate iterator. If context.method was
816
- // "return", allow the original .return call to continue in the
817
- // outer generator.
818
- if (context.method !== "return") {
819
- context.method = "next";
820
- context.arg = undefined$1;
821
- }
822
-
823
- } else {
824
- // Re-yield the result returned by the delegate method.
825
- return info;
826
- }
827
-
828
- // The delegate iterator is finished, so forget it and continue with
829
- // the outer generator.
830
- context.delegate = null;
831
- return ContinueSentinel;
832
- }
833
-
834
- // Define Generator.prototype.{next,throw,return} in terms of the
835
- // unified ._invoke helper method.
836
- defineIteratorMethods(Gp);
837
-
838
- define(Gp, toStringTagSymbol, "Generator");
839
-
840
- // A Generator should always return itself as the iterator object when the
841
- // @@iterator function is called on it. Some browsers' implementations of the
842
- // iterator prototype chain incorrectly implement this, causing the Generator
843
- // object to not be returned from this call. This ensures that doesn't happen.
844
- // See https://github.com/facebook/regenerator/issues/274 for more details.
845
- define(Gp, iteratorSymbol, function() {
846
- return this;
847
- });
848
-
849
- define(Gp, "toString", function() {
850
- return "[object Generator]";
851
- });
852
-
853
- function pushTryEntry(locs) {
854
- var entry = { tryLoc: locs[0] };
855
-
856
- if (1 in locs) {
857
- entry.catchLoc = locs[1];
858
- }
859
-
860
- if (2 in locs) {
861
- entry.finallyLoc = locs[2];
862
- entry.afterLoc = locs[3];
863
- }
864
-
865
- this.tryEntries.push(entry);
866
- }
867
-
868
- function resetTryEntry(entry) {
869
- var record = entry.completion || {};
870
- record.type = "normal";
871
- delete record.arg;
872
- entry.completion = record;
873
- }
874
-
875
- function Context(tryLocsList) {
876
- // The root entry object (effectively a try statement without a catch
877
- // or a finally block) gives us a place to store values thrown from
878
- // locations where there is no enclosing try statement.
879
- this.tryEntries = [{ tryLoc: "root" }];
880
- tryLocsList.forEach(pushTryEntry, this);
881
- this.reset(true);
882
- }
883
-
884
- exports.keys = function(object) {
885
- var keys = [];
886
- for (var key in object) {
887
- keys.push(key);
888
- }
889
- keys.reverse();
890
-
891
- // Rather than returning an object with a next method, we keep
892
- // things simple and return the next function itself.
893
- return function next() {
894
- while (keys.length) {
895
- var key = keys.pop();
896
- if (key in object) {
897
- next.value = key;
898
- next.done = false;
899
- return next;
900
- }
901
- }
902
-
903
- // To avoid creating an additional object, we just hang the .value
904
- // and .done properties off the next function object itself. This
905
- // also ensures that the minifier will not anonymize the function.
906
- next.done = true;
907
- return next;
908
- };
909
- };
910
-
911
- function values(iterable) {
912
- if (iterable) {
913
- var iteratorMethod = iterable[iteratorSymbol];
914
- if (iteratorMethod) {
915
- return iteratorMethod.call(iterable);
916
- }
917
-
918
- if (typeof iterable.next === "function") {
919
- return iterable;
920
- }
921
-
922
- if (!isNaN(iterable.length)) {
923
- var i = -1, next = function next() {
924
- while (++i < iterable.length) {
925
- if (hasOwn.call(iterable, i)) {
926
- next.value = iterable[i];
927
- next.done = false;
928
- return next;
929
- }
930
- }
931
-
932
- next.value = undefined$1;
933
- next.done = true;
934
-
935
- return next;
936
- };
937
-
938
- return next.next = next;
939
- }
940
- }
941
-
942
- // Return an iterator with no values.
943
- return { next: doneResult };
944
- }
945
- exports.values = values;
946
-
947
- function doneResult() {
948
- return { value: undefined$1, done: true };
949
- }
950
-
951
- Context.prototype = {
952
- constructor: Context,
953
-
954
- reset: function(skipTempReset) {
955
- this.prev = 0;
956
- this.next = 0;
957
- // Resetting context._sent for legacy support of Babel's
958
- // function.sent implementation.
959
- this.sent = this._sent = undefined$1;
960
- this.done = false;
961
- this.delegate = null;
962
-
963
- this.method = "next";
964
- this.arg = undefined$1;
965
-
966
- this.tryEntries.forEach(resetTryEntry);
967
-
968
- if (!skipTempReset) {
969
- for (var name in this) {
970
- // Not sure about the optimal order of these conditions:
971
- if (name.charAt(0) === "t" &&
972
- hasOwn.call(this, name) &&
973
- !isNaN(+name.slice(1))) {
974
- this[name] = undefined$1;
975
- }
976
- }
977
- }
978
- },
979
-
980
- stop: function() {
981
- this.done = true;
982
-
983
- var rootEntry = this.tryEntries[0];
984
- var rootRecord = rootEntry.completion;
985
- if (rootRecord.type === "throw") {
986
- throw rootRecord.arg;
987
- }
988
-
989
- return this.rval;
990
- },
991
-
992
- dispatchException: function(exception) {
993
- if (this.done) {
994
- throw exception;
995
- }
996
-
997
- var context = this;
998
- function handle(loc, caught) {
999
- record.type = "throw";
1000
- record.arg = exception;
1001
- context.next = loc;
1002
-
1003
- if (caught) {
1004
- // If the dispatched exception was caught by a catch block,
1005
- // then let that catch block handle the exception normally.
1006
- context.method = "next";
1007
- context.arg = undefined$1;
1008
- }
1009
-
1010
- return !! caught;
1011
- }
1012
-
1013
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1014
- var entry = this.tryEntries[i];
1015
- var record = entry.completion;
1016
-
1017
- if (entry.tryLoc === "root") {
1018
- // Exception thrown outside of any try block that could handle
1019
- // it, so set the completion value of the entire function to
1020
- // throw the exception.
1021
- return handle("end");
1022
- }
1023
-
1024
- if (entry.tryLoc <= this.prev) {
1025
- var hasCatch = hasOwn.call(entry, "catchLoc");
1026
- var hasFinally = hasOwn.call(entry, "finallyLoc");
1027
-
1028
- if (hasCatch && hasFinally) {
1029
- if (this.prev < entry.catchLoc) {
1030
- return handle(entry.catchLoc, true);
1031
- } else if (this.prev < entry.finallyLoc) {
1032
- return handle(entry.finallyLoc);
1033
- }
1034
-
1035
- } else if (hasCatch) {
1036
- if (this.prev < entry.catchLoc) {
1037
- return handle(entry.catchLoc, true);
1038
- }
1039
-
1040
- } else if (hasFinally) {
1041
- if (this.prev < entry.finallyLoc) {
1042
- return handle(entry.finallyLoc);
1043
- }
1044
-
1045
- } else {
1046
- throw new Error("try statement without catch or finally");
1047
- }
1048
- }
1049
- }
1050
- },
1051
-
1052
- abrupt: function(type, arg) {
1053
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1054
- var entry = this.tryEntries[i];
1055
- if (entry.tryLoc <= this.prev &&
1056
- hasOwn.call(entry, "finallyLoc") &&
1057
- this.prev < entry.finallyLoc) {
1058
- var finallyEntry = entry;
1059
- break;
1060
- }
1061
- }
1062
-
1063
- if (finallyEntry &&
1064
- (type === "break" ||
1065
- type === "continue") &&
1066
- finallyEntry.tryLoc <= arg &&
1067
- arg <= finallyEntry.finallyLoc) {
1068
- // Ignore the finally entry if control is not jumping to a
1069
- // location outside the try/catch block.
1070
- finallyEntry = null;
1071
- }
1072
-
1073
- var record = finallyEntry ? finallyEntry.completion : {};
1074
- record.type = type;
1075
- record.arg = arg;
1076
-
1077
- if (finallyEntry) {
1078
- this.method = "next";
1079
- this.next = finallyEntry.finallyLoc;
1080
- return ContinueSentinel;
1081
- }
1082
-
1083
- return this.complete(record);
1084
- },
1085
-
1086
- complete: function(record, afterLoc) {
1087
- if (record.type === "throw") {
1088
- throw record.arg;
1089
- }
1090
-
1091
- if (record.type === "break" ||
1092
- record.type === "continue") {
1093
- this.next = record.arg;
1094
- } else if (record.type === "return") {
1095
- this.rval = this.arg = record.arg;
1096
- this.method = "return";
1097
- this.next = "end";
1098
- } else if (record.type === "normal" && afterLoc) {
1099
- this.next = afterLoc;
1100
- }
1101
-
1102
- return ContinueSentinel;
1103
- },
1104
-
1105
- finish: function(finallyLoc) {
1106
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1107
- var entry = this.tryEntries[i];
1108
- if (entry.finallyLoc === finallyLoc) {
1109
- this.complete(entry.completion, entry.afterLoc);
1110
- resetTryEntry(entry);
1111
- return ContinueSentinel;
1112
- }
1113
- }
1114
- },
1115
-
1116
- "catch": function(tryLoc) {
1117
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1118
- var entry = this.tryEntries[i];
1119
- if (entry.tryLoc === tryLoc) {
1120
- var record = entry.completion;
1121
- if (record.type === "throw") {
1122
- var thrown = record.arg;
1123
- resetTryEntry(entry);
1124
- }
1125
- return thrown;
1126
- }
1127
- }
1128
-
1129
- // The context.catch method must only be called with a location
1130
- // argument that corresponds to a known catch block.
1131
- throw new Error("illegal catch attempt");
1132
- },
1133
-
1134
- delegateYield: function(iterable, resultName, nextLoc) {
1135
- this.delegate = {
1136
- iterator: values(iterable),
1137
- resultName: resultName,
1138
- nextLoc: nextLoc
1139
- };
1140
-
1141
- if (this.method === "next") {
1142
- // Deliberately forget the last sent value so that we don't
1143
- // accidentally pass it on to the delegate.
1144
- this.arg = undefined$1;
1145
- }
1146
-
1147
- return ContinueSentinel;
1148
- }
1149
- };
1150
-
1151
- // Regardless of whether this script is executing as a CommonJS module
1152
- // or not, return the runtime object so that we can declare the variable
1153
- // regeneratorRuntime in the outer scope, which allows this module to be
1154
- // injected easily by `bin/regenerator --include-runtime script.js`.
1155
- return exports;
1156
-
1157
- }(
1158
- // If this script is executing as a CommonJS module, use module.exports
1159
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1160
- // object. Either way, the resulting object will be used to initialize
1161
- // the regeneratorRuntime variable at the top of this file.
1162
- module.exports
1163
- ));
1164
-
1165
- try {
1166
- regeneratorRuntime = runtime;
1167
- } catch (accidentalStrictMode) {
1168
- // This module should not be running in strict mode, so the above
1169
- // assignment should always work unless something is misconfigured. Just
1170
- // in case runtime.js accidentally runs in strict mode, in modern engines
1171
- // we can explicitly access globalThis. In older engines we can escape
1172
- // strict mode using a global Function call. This could conceivably fail
1173
- // if a Content Security Policy forbids using Function, but in that case
1174
- // the proper solution is to fix the accidental strict mode problem. If
1175
- // you've misconfigured your bundler to force strict mode and applied a
1176
- // CSP to forbid Function, and you're not willing to fix either of those
1177
- // problems, please detail your unique predicament in a GitHub issue.
1178
- if (typeof globalThis === "object") {
1179
- globalThis.regeneratorRuntime = runtime;
1180
- } else {
1181
- Function("r", "regeneratorRuntime = r")(runtime);
1182
- }
1183
- }
1184
- });
1185
-
1186
- /**
1187
- * Does nothing.
1188
- *
1189
- * @returns Nothing.
1190
- */
1191
- function noop() {
1192
- return;
1193
- }
1194
- /**
1195
- * Halts program execution for a specified time.
1196
- *
1197
- * @param duration - The time to wait (in ms).
1198
- * @returns The halting promise.
1199
- */
1200
-
1201
- function sleep(_x) {
1202
- return _sleep.apply(this, arguments);
1203
- }
1204
-
1205
- function _sleep() {
1206
- _sleep = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(duration) {
1207
- return runtime_1.wrap(function _callee$(_context) {
1208
- while (1) {
1209
- switch (_context.prev = _context.next) {
1210
- case 0:
1211
- return _context.abrupt("return", new Promise(function (resolve) {
1212
- return setTimeout(resolve, duration);
1213
- }));
1214
-
1215
- case 1:
1216
- case "end":
1217
- return _context.stop();
1218
- }
1219
- }
1220
- }, _callee);
1221
- }));
1222
- return _sleep.apply(this, arguments);
1223
- }
1224
-
1225
- /**
1226
- * Recursively merges multiple objects into one.
1227
- *
1228
- * @param objects - The objects to merge.
1229
- * @returns The merged object.
1230
- */
1231
-
1232
- function deepMerge() {
1233
- for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
1234
- objects[_key] = arguments[_key];
1235
- }
1236
-
1237
- return objects.reduce(function (result, current) {
1238
- Object.keys(current).forEach(function (key) {
1239
- if (isArray(result[key]) && isArray(current[key])) {
1240
- result[key] = uniq(result[key].concat(current[key]));
1241
- } else if (isObject(result[key]) && isObject(current[key])) {
1242
- result[key] = deepMerge(result[key], current[key]);
1243
- } else {
1244
- result[key] = current[key];
1245
- }
1246
- });
1247
- return result;
1248
- }, {});
1249
- }
1250
-
1251
- /**
1252
- * Scrolls the page or provided container to a target element or y-coordinate.
1253
- *
1254
- * @param config - The scroll config.
1255
- * @param config.to - The scroll target.
1256
- * @param config.offset - The offset from the scroll target (in px).
1257
- * @param config.duration - The scroll duration (in ms).
1258
- * @param config.container - The container to scroll in.
1259
- */
1260
-
1261
- function scroll(_ref) {
1262
- var _window;
1263
-
1264
- var to = _ref.to,
1265
- _ref$offset = _ref.offset,
1266
- offset = _ref$offset === void 0 ? 0 : _ref$offset,
1267
- _ref$duration = _ref.duration,
1268
- duration = _ref$duration === void 0 ? 1000 : _ref$duration,
1269
- _ref$container = _ref.container,
1270
- container = _ref$container === void 0 ? null : _ref$container;
1271
- var target = isString(to) ? document.querySelector(to) : to;
1272
-
1273
- var _container = isString(container) ? document.querySelector(container) : container;
1274
-
1275
- var start = (_container == null ? void 0 : _container.scrollTop) || ((_window = window) == null ? void 0 : _window.pageYOffset) || 0;
1276
- var end = (isNumber(target) ? target : getElTop(target, start)) + offset;
1277
- var startTime = Date.now();
1278
-
1279
- function step() {
1280
- var timeElapsed = Date.now() - startTime;
1281
- var isScrolling = timeElapsed < duration;
1282
- var position = isScrolling ? getPosition(start, end, timeElapsed, duration) : end;
1283
-
1284
- if (isScrolling) {
1285
- requestAnimationFrame(step);
1286
- }
1287
-
1288
- if (_container) {
1289
- _container.scrollTop = position;
1290
- } else {
1291
- window.scrollTo(0, position);
1292
- }
1293
- }
1294
-
1295
- step();
1296
- }
1297
-
1298
- function easing(t) {
1299
- return t < 0.5 ? 4 * Math.pow(t, 3) : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
1300
- }
1301
-
1302
- function getPosition(s, e, t, d) {
1303
- return s + (e - s) * easing(t / d);
1304
- }
1305
-
1306
- function getElTop(element, start) {
1307
- return element.nodeName === 'HTML' ? -start : element.getBoundingClientRect().top + start;
1308
- }
1309
-
1310
- /**
1311
- * Capitalises the first letter of one word, or all words, in a string.
1312
- *
1313
- * @param str - The string.
1314
- * @param allWords - If all words should be capitalised.
1315
- * @returns The capitalised string.
1316
- */
1317
- function capitalise(str, allWords) {
1318
- if (allWords === void 0) {
1319
- allWords = false;
1320
- }
1321
-
1322
- if (!allWords) {
1323
- return str.charAt(0).toUpperCase() + str.slice(1);
1324
- }
1325
-
1326
- return str.split(' ').map(function (s) {
1327
- return s.charAt(0).toUpperCase() + s.slice(1);
1328
- }).join(' ');
1329
- }
1330
- /**
1331
- * Separates a string into an array of characters.
1332
- *
1333
- * @param str - The string.
1334
- * @returns The string's characters.
1335
- */
1336
-
1337
- function chars(str) {
1338
- return str.split('');
1339
- }
1340
- /**
1341
- * Identifies strings which only contain whitespace.
1342
- *
1343
- * @param str - The string.
1344
- * @returns If the string is blank.
1345
- */
1346
-
1347
- function isBlank(str) {
1348
- return str.trim().length === 0;
1349
- }
1350
- /**
1351
- * Identifies empty strings.
1352
- *
1353
- * @param str - The string.
1354
- * @returns If the string is empty.
1355
- */
1356
-
1357
- function isEmpty(str) {
1358
- return str.length === 0;
1359
- }
1360
- /**
1361
- * Converts a kebab case string to camel case.
1362
- *
1363
- * @param str - The kebab case string.
1364
- * @returns The camel case string.
1365
- */
1366
-
1367
- function toCamel(str) {
1368
- var RE = /-(\w)/g;
1369
- return str.replace(RE, function (_, c) {
1370
- return c ? c.toUpperCase() : '';
1371
- });
1372
- }
1373
- /**
1374
- * Converts a camel case string to kebab case.
1375
- *
1376
- * @param str - The camel case string.
1377
- * @returns The kebab case string.
1378
- */
1379
-
1380
- function toKebab(str) {
1381
- var RE = /\B([A-Z])/g;
1382
- return str.replace(RE, '-$1').toLowerCase();
1383
- }
1384
- /**
1385
- * Converts a string which contains a number to the number itself.
1386
- *
1387
- * @param str - The string.
1388
- * @returns The number.
1389
- */
1390
-
1391
- function toNumber(str) {
1392
- if (!str.length) {
1393
- return NaN;
1394
- }
1395
-
1396
- return Number(str.replace(/[#£€$,%]/g, ''));
1397
- }
1398
- /**
1399
- * Truncates a string to a provided length.
1400
- *
1401
- * @param str - The string.
1402
- * @param length - The length.
1403
- * @param truncateStr - The prefix to apply after truncation.
1404
- * @returns The truncated string.
1405
- */
1406
-
1407
- function truncate(str, length, truncateStr) {
1408
- if (truncateStr === void 0) {
1409
- truncateStr = '...';
1410
- }
1411
-
1412
- if (length <= 0) {
1413
- return truncateStr;
1414
- }
1415
-
1416
- return str.slice(0, length) + truncateStr;
1417
- }
1418
-
1419
- exports.capitalise = capitalise;
1420
- exports.chars = chars;
1421
- exports.debounce = debounce;
1422
- exports.deepMerge = deepMerge;
1423
- exports.drop = drop;
1424
- exports.head = head;
1425
- exports.init = init;
1426
- exports.isArray = isArray;
1427
- exports.isBlank = isBlank;
1428
- exports.isBoolean = isBoolean;
1429
- exports.isBrowser = isBrowser;
1430
- exports.isDefined = isDefined;
1431
- exports.isEmpty = isEmpty;
1432
- exports.isEven = isEven;
1433
- exports.isFunction = isFunction;
1434
- exports.isNumber = isNumber;
1435
- exports.isObject = isObject;
1436
- exports.isOdd = isOdd;
1437
- exports.isString = isString;
1438
- exports.isWindow = isWindow;
1439
- exports.last = last;
1440
- exports.max = max;
1441
- exports.memoize = memoize;
1442
- exports.min = min;
1443
- exports.modulo = modulo;
1444
- exports.noop = noop;
1445
- exports.partition = partition;
1446
- exports.randomChance = randomChance;
1447
- exports.randomNumber = randomNumber;
1448
- exports.scroll = scroll;
1449
- exports.sleep = sleep;
1450
- exports.splitAt = splitAt;
1451
- exports.sum = sum;
1452
- exports.tail = tail;
1453
- exports.take = take;
1454
- exports.throttle = throttle;
1455
- exports.toArray = toArray;
1456
- exports.toCamel = toCamel;
1457
- exports.toKebab = toKebab;
1458
- exports.toNumber = toNumber;
1459
- exports.truncate = truncate;
1460
- exports.uniq = uniq;
1461
- //# sourceMappingURL=tsu.cjs.development.js.map