@dereekb/rxjs 13.4.0 → 13.4.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/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isObservable, of, switchMap, combineLatest, map, delay, startWith, filter, skipWhile, EMPTY, distinctUntilChanged, mergeMap, BehaviorSubject, shareReplay, skip, defaultIfEmpty, first, finalize, merge, firstValueFrom, exhaustMap, scan, identity, throttleTime, takeWhile, timeout, tap, throwError, timer, delayWhen, asyncScheduler, from, catchError, Subject } from 'rxjs';
2
- import { getValueFromGetter, isMaybeSo, filterMaybeArrayValues, areEqualPOJOValues, convertToArray, asGetter, performTaskLoop, isMaybeNot, forEachWithArray, pushArrayItemsIntoArray, pushItemOrArrayItemsIntoArray, asArray, filterAndMapFunction, expirationDetails, objectKeysEqualityComparatorFunction, objectKeyEqualityComparatorFunction, asPromise, randomNumberFactory, mapsHaveSameKeys, mapKeysIntersectionObjectToArray, incrementingNumberFactory, filterUniqueFunction, build, cachedGetter, allKeyValueTuples, keyValueMapFactory, multiKeyValueMapFactory, timePeriodCounter, hasSameValues, compareEqualityWithValueFromItemsFunction, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, searchStringFilterFunction, reduceBooleansWithAnd, toReadableError, reduceBooleansWithOr, valuesAreBothNullishOrEquivalent, mergeObjects, objectHasKey, safeCompareEquality, hasNonNullValue, limitArray, mapFunctionOutputPair, lastValue, flattenArray, hasValueOrNotEmpty, filteredPage, invertMaybeBoolean, FIRST_PAGE, getNextPageNumber, reduceBooleansWithOrFn, MS_IN_SECOND } from '@dereekb/util';
2
+ import { getValueFromGetter, isMaybeSo, filterMaybeArrayValues, areEqualPOJOValues, convertToArray, asGetter, performTaskLoop, isMaybeNot, forEachWithArray, pushArrayItemsIntoArray, asArray, pushItemOrArrayItemsIntoArray, filterAndMapFunction, expirationDetails, objectKeysEqualityComparatorFunction, objectKeyEqualityComparatorFunction, asPromise, randomNumberFactory, mapsHaveSameKeys, mapKeysIntersectionObjectToArray, incrementingNumberFactory, filterUniqueFunction, build, cachedGetter, allKeyValueTuples, keyValueMapFactory, multiKeyValueMapFactory, timePeriodCounter, hasSameValues, compareEqualityWithValueFromItemsFunction, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, searchStringFilterFunction, reduceBooleansWithAnd, toReadableError, reduceBooleansWithOr, valuesAreBothNullishOrEquivalent, mergeObjects, objectHasKey, safeCompareEquality, hasNonNullValue, limitArray, mapFunctionOutputPair, lastValue, flattenArray, hasValueOrNotEmpty, filteredPage, invertMaybeBoolean, FIRST_PAGE, getNextPageNumber, reduceBooleansWithOrFn, MS_IN_SECOND } from '@dereekb/util';
3
3
 
4
4
  function asObservable(valueOrObs) {
5
5
  if (isObservable(valueOrObs)) {
@@ -28,7 +28,7 @@ function asObservable(valueOrObs) {
28
28
  });
29
29
  }
30
30
  function asObservableFromGetter(input, args) {
31
- var obs = getValueFromGetter(input, args);
31
+ var obs = getValueFromGetter(input, args); // eslint-disable-line @typescript-eslint/no-explicit-any
32
32
  return asObservable(obs);
33
33
  }
34
34
  /**
@@ -43,6 +43,8 @@ function asObservableFromGetter(input, args) {
43
43
  /**
44
44
  * RxJS operator that flattens an emitted Maybe<{@link ObservableOrValueGetter}> into its resolved value,
45
45
  * emitting `undefined` when the input is nullish.
46
+ *
47
+ * @returns an operator that unwraps Maybe<ObservableOrValueGetter> emissions, emitting undefined for nullish inputs
46
48
  */ function maybeValueFromObservableOrValueGetter() {
47
49
  return switchMap(function(x) {
48
50
  return x != null ? asObservableFromGetter(x) : of(undefined);
@@ -137,6 +139,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
137
139
  *
138
140
  * @param isCheckFunction - optional check function
139
141
  * @param defaultValueOnMaybe - default result for null/undefined values
142
+ * @returns a function that evaluates each value against the check function and returns it or undefined
140
143
  */ function makeReturnIfIsFunction(isCheckFunction, defaultValueOnMaybe) {
141
144
  return function(value) {
142
145
  return returnIfIs(isCheckFunction, value, defaultValueOnMaybe);
@@ -148,6 +151,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
148
151
  * @param isCheckFunction - optional check function
149
152
  * @param value - the value to check
150
153
  * @param defaultValueOnMaybe - default result for null/undefined values
154
+ * @returns an observable that emits the value if the check passes, or undefined otherwise
151
155
  */ function returnIfIs(isCheckFunction, value, defaultValueOnMaybe) {
152
156
  return checkIs(isCheckFunction, value, defaultValueOnMaybe).pipe(map(function(x) {
153
157
  return x ? value : undefined;
@@ -158,6 +162,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
158
162
  *
159
163
  * @param isCheckFunction - optional check function
160
164
  * @param defaultValueOnMaybe - default result for null/undefined values
165
+ * @returns a function that evaluates each value against the check function and returns an observable boolean
161
166
  */ function makeCheckIsFunction(isCheckFunction, defaultValueOnMaybe) {
162
167
  return function(value) {
163
168
  return checkIs(isCheckFunction, value, defaultValueOnMaybe);
@@ -171,6 +176,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
171
176
  * @param isCheckFunction - optional check function
172
177
  * @param value - the value to check
173
178
  * @param defaultValueOnMaybe - default result for null/undefined values (defaults to false)
179
+ * @returns an observable boolean indicating whether the value passes the check
174
180
  */ function checkIs(isCheckFunction, value) {
175
181
  var defaultValueOnMaybe = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
176
182
  var is = isCheckFunction ? value != null ? isCheckFunction(value) : of(defaultValueOnMaybe) : of(true);
@@ -179,6 +185,8 @@ function _unsupported_iterable_to_array$b(o, minLen) {
179
185
  // MARK: Filter
180
186
  /**
181
187
  * RxJS operator that filters out null and undefined values, only passing through defined values.
188
+ *
189
+ * @returns operator that filters out null and undefined emissions
182
190
  */ function filterMaybe() {
183
191
  return filter(isMaybeSo);
184
192
  }
@@ -187,11 +195,15 @@ function _unsupported_iterable_to_array$b(o, minLen) {
187
195
  */ var filterMaybeStrict = filterMaybe;
188
196
  /**
189
197
  * RxJS operator that filters out null/undefined elements from an emitted array, keeping only defined values.
198
+ *
199
+ * @returns operator that maps each emitted array to a version with null/undefined elements removed
190
200
  */ function filterMaybeArray() {
191
201
  return map(filterMaybeArrayValues);
192
202
  }
193
203
  /**
194
204
  * RxJS operator that skips all leading null/undefined emissions, then passes all subsequent values through.
205
+ *
206
+ * @returns operator that skips all null/undefined emissions at the start of the stream
195
207
  */ function skipAllInitialMaybe() {
196
208
  return skipWhile(function(x) {
197
209
  return x == null;
@@ -199,6 +211,8 @@ function _unsupported_iterable_to_array$b(o, minLen) {
199
211
  }
200
212
  /**
201
213
  * RxJS operator that skips only the first emission if it is null/undefined, then passes all subsequent values.
214
+ *
215
+ * @returns operator that skips the first null/undefined emission if it occurs at the start of the stream
202
216
  */ function skipInitialMaybe() {
203
217
  return skipMaybes(1);
204
218
  }
@@ -206,6 +220,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
206
220
  * RxJS operator that skips up to `maxToSkip` null/undefined emissions, then passes all subsequent values.
207
221
  *
208
222
  * @param maxToSkip - maximum number of null/undefined emissions to skip
223
+ * @returns operator that skips the first N null/undefined emissions from the stream
209
224
  */ function skipMaybes(maxToSkip) {
210
225
  return skipWhile(function(x, i) {
211
226
  return x == null && i < maxToSkip;
@@ -227,7 +242,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
227
242
  });
228
243
  }
229
244
  function switchMapToDefault(defaultObs, useDefault) {
230
- var useDefaultFn = useDefault ? useDefault : function(x) {
245
+ var useDefaultFn = useDefault !== null && useDefault !== void 0 ? useDefault : function(x) {
231
246
  return of(x == null);
232
247
  };
233
248
  return switchMap(function(x) {
@@ -243,6 +258,9 @@ function switchMapToDefault(defaultObs, useDefault) {
243
258
  /**
244
259
  * RxJS operator that resolves an observable/getter config input into a value, applying defaults
245
260
  * for `null`/`undefined`/`true` inputs and emitting `null` for `false`.
261
+ *
262
+ * @param config - configuration providing an optional default getter for null/undefined/true inputs
263
+ * @returns operator that resolves each emitted getter into a value, using the default for nullish or true inputs
246
264
  */ function switchMapObject(config) {
247
265
  var defaultGetter = config.defaultGetter;
248
266
  return switchMap(function(inputConfig) {
@@ -277,6 +295,8 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
277
295
  * RxJS operator that filters out null/undefined observables and then switches to the remaining ones.
278
296
  *
279
297
  * Combines {@link filterMaybe} and `switchMap` to only subscribe to non-nullish observables.
298
+ *
299
+ * @returns operator that filters nullish observables and subscribes to the non-nullish ones
280
300
  */ function switchMapFilterMaybe() {
281
301
  return function(source) {
282
302
  var subscriber = source.pipe(filterMaybe(), switchMap(function(x) {
@@ -287,10 +307,12 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
287
307
  }
288
308
  /**
289
309
  * RxJS operator that switches to the emitted observable if defined, or emits `undefined` when the observable is nullish.
310
+ *
311
+ * @returns operator that switches to the emitted observable or emits undefined for null/undefined inputs
290
312
  */ function switchMapMaybe() {
291
313
  return function(source) {
292
314
  var subscriber = source.pipe(switchMap(function(x) {
293
- return x != null ? x : of(undefined);
315
+ return x !== null && x !== void 0 ? x : of(undefined);
294
316
  }));
295
317
  return subscriber;
296
318
  };
@@ -315,11 +337,11 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
315
337
  });
316
338
  }
317
339
  /**
318
- * Combines both combineLatest with map values to an other value.
340
+ * Combines the source observable with another observable via `combineLatest`, then maps the pair to a result.
319
341
  *
320
- * @param combineObs
321
- * @param mapFn
322
- * @returns
342
+ * @param combineObs - the secondary observable to combine with the source
343
+ * @param mapFn - function that maps the source value and combined value to the output
344
+ * @returns operator that combines the source with `combineObs` and maps each pair using `mapFn`
323
345
  */ function combineLatestMapFrom(combineObs, mapFn) {
324
346
  return function(obs) {
325
347
  return combineLatest([
@@ -335,6 +357,11 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
335
357
  * Creates an observable that emits a starting value, then a second value after a delay.
336
358
  *
337
359
  * If the delay is not provided, or is falsy, then the second value is never emitted.
360
+ *
361
+ * @param startWith - the value to emit immediately
362
+ * @param endWith - the value to emit after the delay
363
+ * @param delayTime - optional delay in milliseconds before emitting the second value
364
+ * @returns an observable that emits `startWith` immediately and `endWith` after the delay (if provided)
338
365
  */ function emitDelayObs(startWith, endWith, delayTime) {
339
366
  var obs = of(startWith);
340
367
  if (delayTime) {
@@ -344,6 +371,10 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
344
371
  }
345
372
  /**
346
373
  * Emits a value after a given delay after every new emission.
374
+ *
375
+ * @param value - the value to emit after the delay
376
+ * @param delayTime - duration in milliseconds before emitting the value
377
+ * @returns operator that appends the given value after each source emission with the specified delay
347
378
  */ function emitAfterDelay(value, delayTime) {
348
379
  return function(obs) {
349
380
  return obs.pipe(switchMap(function(x) {
@@ -386,7 +417,7 @@ function _array_like_to_array$a(arr, len) {
386
417
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
387
418
  return arr2;
388
419
  }
389
- function _array_without_holes$5(arr) {
420
+ function _array_without_holes$6(arr) {
390
421
  if (Array.isArray(arr)) return _array_like_to_array$a(arr);
391
422
  }
392
423
  function _class_call_check$8(instance, Constructor) {
@@ -420,14 +451,14 @@ function _define_property$c(obj, key, value) {
420
451
  }
421
452
  return obj;
422
453
  }
423
- function _iterable_to_array$5(iter) {
454
+ function _iterable_to_array$6(iter) {
424
455
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
425
456
  }
426
- function _non_iterable_spread$5() {
457
+ function _non_iterable_spread$6() {
427
458
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
428
459
  }
429
- function _to_consumable_array$5(arr) {
430
- return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$5();
460
+ function _to_consumable_array$6(arr) {
461
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$6();
431
462
  }
432
463
  function _unsupported_iterable_to_array$a(o, minLen) {
433
464
  if (!o) return;
@@ -467,6 +498,8 @@ function _unsupported_iterable_to_array$a(o, minLen) {
467
498
  key: "hasSubscription",
468
499
  get: /**
469
500
  * Whether a subscription is currently being managed.
501
+ *
502
+ * @returns true if a subscription is currently active
470
503
  */ function get() {
471
504
  return Boolean(this._subscription);
472
505
  }
@@ -546,6 +579,8 @@ function _unsupported_iterable_to_array$a(o, minLen) {
546
579
  key: "hasSubscription",
547
580
  get: /**
548
581
  * Whether any subscriptions are currently being managed.
582
+ *
583
+ * @returns true if one or more subscriptions are currently active
549
584
  */ function get() {
550
585
  var _this__subscriptions;
551
586
  return Boolean((_this__subscriptions = this._subscriptions) === null || _this__subscriptions === void 0 ? void 0 : _this__subscriptions.length);
@@ -578,7 +613,7 @@ function _unsupported_iterable_to_array$a(o, minLen) {
578
613
  */ key: "addSubs",
579
614
  value: function addSubs(subs) {
580
615
  var _this__subscriptions;
581
- var nextSubscriptions = _to_consumable_array$5((_this__subscriptions = this._subscriptions) !== null && _this__subscriptions !== void 0 ? _this__subscriptions : []);
616
+ var nextSubscriptions = _to_consumable_array$6((_this__subscriptions = this._subscriptions) !== null && _this__subscriptions !== void 0 ? _this__subscriptions : []);
582
617
  convertToArray(subs).forEach(function(sub) {
583
618
  if (!nextSubscriptions.includes(sub)) {
584
619
  nextSubscriptions.push(sub);
@@ -811,24 +846,23 @@ function _unsupported_iterable_to_array$9(o, minLen) {
811
846
  key: "initFilterTakesPriority",
812
847
  value: function initFilterTakesPriority() {
813
848
  var _this = this;
814
- if (!this._initialFilterSub.subscription) {
815
- this._initialFilterSub.subscription = this._initialFilterTakesPriority.pipe(switchMap(function(clearFilterOnInitialFilterPush) {
816
- if (clearFilterOnInitialFilterPush) {
817
- return _this._initialFilter.pipe(switchMap(function(x) {
818
- return x ? x : EMPTY;
819
- }), filterMaybe(), map(function() {
820
- return true;
821
- }), skip(1) // skip the first emission
822
- );
823
- } else {
824
- return EMPTY;
825
- }
826
- }), defaultIfEmpty(false)).subscribe(function(clear) {
827
- if (clear) {
828
- _this.resetFilter();
829
- }
830
- });
831
- }
849
+ var _this__initialFilterSub, _subscription;
850
+ (_subscription = (_this__initialFilterSub = this._initialFilterSub).subscription) !== null && _subscription !== void 0 ? _subscription : _this__initialFilterSub.subscription = this._initialFilterTakesPriority.pipe(switchMap(function(clearFilterOnInitialFilterPush) {
851
+ if (clearFilterOnInitialFilterPush) {
852
+ return _this._initialFilter.pipe(switchMap(function(x) {
853
+ return x !== null && x !== void 0 ? x : EMPTY;
854
+ }), filterMaybe(), map(function() {
855
+ return true;
856
+ }), skip(1) // skip the first emission
857
+ );
858
+ } else {
859
+ return EMPTY;
860
+ }
861
+ }), defaultIfEmpty(false)).subscribe(function(clear) {
862
+ if (clear) {
863
+ _this.resetFilter();
864
+ }
865
+ });
832
866
  }
833
867
  },
834
868
  {
@@ -853,7 +887,7 @@ function _array_like_to_array$8(arr, len) {
853
887
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
854
888
  return arr2;
855
889
  }
856
- function _array_without_holes$4(arr) {
890
+ function _array_without_holes$5(arr) {
857
891
  if (Array.isArray(arr)) return _array_like_to_array$8(arr);
858
892
  }
859
893
  function _class_call_check$6(instance, Constructor) {
@@ -887,14 +921,14 @@ function _define_property$a(obj, key, value) {
887
921
  }
888
922
  return obj;
889
923
  }
890
- function _iterable_to_array$4(iter) {
924
+ function _iterable_to_array$5(iter) {
891
925
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
892
926
  }
893
- function _non_iterable_spread$4() {
927
+ function _non_iterable_spread$5() {
894
928
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
895
929
  }
896
- function _to_consumable_array$4(arr) {
897
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$4();
930
+ function _to_consumable_array$5(arr) {
931
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$5();
898
932
  }
899
933
  function _unsupported_iterable_to_array$8(o, minLen) {
900
934
  if (!o) return;
@@ -1053,6 +1087,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
1053
1087
  {
1054
1088
  /**
1055
1089
  * Sets the default filter observable for this key.
1090
+ *
1091
+ * @param filterObs - the observable to use as the default filter for this key
1056
1092
  */ key: "initWithFilter",
1057
1093
  value: function initWithFilter(filterObs) {
1058
1094
  this.dbxFilterMap.addDefaultFilterObs(this.key, filterObs);
@@ -1061,6 +1097,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
1061
1097
  {
1062
1098
  /**
1063
1099
  * Connects a filter source, adding its filter observable to this key's merged filters.
1100
+ *
1101
+ * @param filterSource - the filter source whose filter$ will be added to this key's merged stream
1064
1102
  */ key: "connectWithSource",
1065
1103
  value: function connectWithSource(filterSource) {
1066
1104
  this.dbxFilterMap.addFilterObs(this.key, filterSource.filter$);
@@ -1078,7 +1116,7 @@ var FilterMapItem = /*#__PURE__*/ function() {
1078
1116
  _define_property$a(this, "_source", new FilterSourceInstance());
1079
1117
  _define_property$a(this, "_obs", new BehaviorSubject([]));
1080
1118
  _define_property$a(this, "_obs$", this._obs.pipe(switchMap(function(x) {
1081
- return merge.apply(void 0, _to_consumable_array$4(x.map(function(y) {
1119
+ return merge.apply(void 0, _to_consumable_array$5(x.map(function(y) {
1082
1120
  return y.obs;
1083
1121
  })));
1084
1122
  }), distinctUntilChanged()));
@@ -1119,7 +1157,7 @@ var FilterMapItem = /*#__PURE__*/ function() {
1119
1157
  var deleteOnComplete = obs.pipe(finalize(function() {
1120
1158
  _this._deleteFilterObs(i);
1121
1159
  })).subscribe();
1122
- var nextObs = _to_consumable_array$4(currentObs).concat([
1160
+ var nextObs = _to_consumable_array$5(currentObs).concat([
1123
1161
  {
1124
1162
  i: i,
1125
1163
  obs: obs,
@@ -1526,17 +1564,17 @@ function _array_like_to_array$7(arr, len) {
1526
1564
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1527
1565
  return arr2;
1528
1566
  }
1529
- function _array_without_holes$3(arr) {
1567
+ function _array_without_holes$4(arr) {
1530
1568
  if (Array.isArray(arr)) return _array_like_to_array$7(arr);
1531
1569
  }
1532
- function _iterable_to_array$3(iter) {
1570
+ function _iterable_to_array$4(iter) {
1533
1571
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1534
1572
  }
1535
- function _non_iterable_spread$3() {
1573
+ function _non_iterable_spread$4() {
1536
1574
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1537
1575
  }
1538
- function _to_consumable_array$3(arr) {
1539
- return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$3();
1576
+ function _to_consumable_array$4(arr) {
1577
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$4();
1540
1578
  }
1541
1579
  function _unsupported_iterable_to_array$7(o, minLen) {
1542
1580
  if (!o) return;
@@ -1562,7 +1600,7 @@ function scanIntoArray() {
1562
1600
  return scan(function(acc, next) {
1563
1601
  if (next != null) {
1564
1602
  if (immutable) {
1565
- acc = acc.concat(next);
1603
+ acc = _to_consumable_array$4(acc).concat(_to_consumable_array$4(asArray(next)));
1566
1604
  } else {
1567
1605
  acc = pushItemOrArrayItemsIntoArray(acc, next);
1568
1606
  }
@@ -1592,7 +1630,7 @@ function scanIntoArray() {
1592
1630
  }
1593
1631
  return acc;
1594
1632
  }, seed !== null && seed !== void 0 ? seed : []), distinctUntilArrayLengthChanges(), map(function(x) {
1595
- return _to_consumable_array$3(x);
1633
+ return _to_consumable_array$4(x);
1596
1634
  }), shareReplay(1));
1597
1635
  });
1598
1636
  }
@@ -1682,7 +1720,7 @@ function scanIntoArray() {
1682
1720
  if (!acc.fromMatch || requireConsecutive) {
1683
1721
  fromMatch = isMatch(from, next);
1684
1722
  value = next;
1685
- } else if (!requireConsecutive) {
1723
+ } else {
1686
1724
  value = acc.value;
1687
1725
  }
1688
1726
  }
@@ -1716,6 +1754,8 @@ function scanIntoArray() {
1716
1754
  }
1717
1755
  /**
1718
1756
  * RxJS operator that negates each emitted boolean value.
1757
+ *
1758
+ * @returns operator that maps each boolean emission to its negated value
1719
1759
  */ function isNot() {
1720
1760
  return map(function(x) {
1721
1761
  return !x;
@@ -1723,6 +1763,8 @@ function scanIntoArray() {
1723
1763
  }
1724
1764
  /**
1725
1765
  * RxJS operator that only emits when a boolean stream transitions from `true` to `false`.
1766
+ *
1767
+ * @returns operator that filters to only true-to-false transition emissions
1726
1768
  */ function onTrueToFalse() {
1727
1769
  return onMatchDelta({
1728
1770
  from: true,
@@ -1732,6 +1774,8 @@ function scanIntoArray() {
1732
1774
  }
1733
1775
  /**
1734
1776
  * RxJS operator that only emits when a boolean stream transitions from `false` to `true`.
1777
+ *
1778
+ * @returns operator that filters to only false-to-true transition emissions
1735
1779
  */ function onFalseToTrue() {
1736
1780
  return onMatchDelta({
1737
1781
  from: false,
@@ -1750,6 +1794,7 @@ function scanIntoArray() {
1750
1794
  * @returns the inverted (or original) decision function
1751
1795
  */ function invertObservableDecision(decisionFn) {
1752
1796
  var invert = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
1797
+ // eslint-disable-line @typescript-eslint/no-explicit-any
1753
1798
  if (invert) {
1754
1799
  return function(value) {
1755
1800
  var obs = decisionFn(value);
@@ -1804,7 +1849,7 @@ function scanIntoArray() {
1804
1849
  * time relative to the current moment.
1805
1850
  *
1806
1851
  * @param expiresIn - duration in milliseconds until expiration
1807
- * @returns an operator that maps values to Expires objects
1852
+ * @returns an `OperatorFunction` that maps each emission to an {@link Expires} object
1808
1853
  */ function toExpiration(expiresIn) {
1809
1854
  return map(function() {
1810
1855
  var now = new Date();
@@ -1819,6 +1864,8 @@ function scanIntoArray() {
1819
1864
  }
1820
1865
  /**
1821
1866
  * RxJS operator that filters out emissions whose {@link Expires} value has already expired.
1867
+ *
1868
+ * @returns operator that only passes through non-expired emissions
1822
1869
  */ function skipExpired() {
1823
1870
  return filter(function(expires) {
1824
1871
  return !expirationDetails({
@@ -1830,6 +1877,7 @@ function scanIntoArray() {
1830
1877
  * RxJS operator that skips emissions until the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
1831
1878
  *
1832
1879
  * @param expiresIn - duration in milliseconds
1880
+ * @returns operator that skips emissions until the time window has elapsed
1833
1881
  */ function skipUntilExpiration(expiresIn) {
1834
1882
  return filter(function(x) {
1835
1883
  return expirationDetails({
@@ -1842,6 +1890,7 @@ function scanIntoArray() {
1842
1890
  * RxJS operator that skips emissions after the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
1843
1891
  *
1844
1892
  * @param expiresIn - duration in milliseconds
1893
+ * @returns operator that passes through emissions only within the time window
1845
1894
  */ function skipAfterExpiration(expiresIn) {
1846
1895
  return filter(function(x) {
1847
1896
  return !expirationDetails({
@@ -1855,6 +1904,7 @@ function scanIntoArray() {
1855
1904
  *
1856
1905
  * @param watch - observable whose emissions reset the time window
1857
1906
  * @param takeFor - duration in milliseconds of each time window
1907
+ * @returns operator that limits source emissions to the active time window after each watch emission
1858
1908
  */ function skipUntilTimeElapsedAfterLastEmission(watch, takeFor) {
1859
1909
  return function(observable) {
1860
1910
  return watch.pipe(switchMap(function() {
@@ -1874,6 +1924,7 @@ function scanIntoArray() {
1874
1924
  *
1875
1925
  * @param watch - observable whose emissions reset the skip window
1876
1926
  * @param skipFor - duration in milliseconds to skip after each watch emission
1927
+ * @returns an operator that delays passing values through until time has elapsed since the last watch emission
1877
1928
  */ function takeAfterTimeElapsedSinceLastEmission(watch, skipFor) {
1878
1929
  return function(observable) {
1879
1930
  return watch.pipe(switchMap(function() {
@@ -2025,7 +2076,7 @@ var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
2025
2076
  return result;
2026
2077
  }), finalize(function() {
2027
2078
  if (currentInstance) {
2028
- destroy(currentInstance);
2079
+ void destroy(currentInstance);
2029
2080
  }
2030
2081
  }));
2031
2082
  };
@@ -2101,6 +2152,8 @@ function tapLog(messageOrFunction) {
2101
2152
 
2102
2153
  /**
2103
2154
  * `distinctUntilChanged` variant that only emits when the model's `id` property changes.
2155
+ *
2156
+ * @returns operator that suppresses consecutive emissions with the same model `id`
2104
2157
  */ function distinctUntilModelIdChange() {
2105
2158
  return distinctUntilObjectKeyChange(function(x) {
2106
2159
  return x.id;
@@ -2108,6 +2161,8 @@ function tapLog(messageOrFunction) {
2108
2161
  }
2109
2162
  /**
2110
2163
  * `distinctUntilChanged` variant that only emits when the model's `key` property changes.
2164
+ *
2165
+ * @returns operator that suppresses consecutive emissions with the same model `key`
2111
2166
  */ function distinctUntilModelKeyChange() {
2112
2167
  return distinctUntilObjectKeyChange(function(x) {
2113
2168
  return x.key;
@@ -2423,6 +2478,12 @@ function _array_like_to_array$5(arr, len) {
2423
2478
  function _array_with_holes$2(arr) {
2424
2479
  if (Array.isArray(arr)) return arr;
2425
2480
  }
2481
+ function _array_without_holes$3(arr) {
2482
+ if (Array.isArray(arr)) return _array_like_to_array$5(arr);
2483
+ }
2484
+ function _iterable_to_array$3(iter) {
2485
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
2486
+ }
2426
2487
  function _iterable_to_array_limit$2(arr, i) {
2427
2488
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2428
2489
  if (_i == null) return;
@@ -2450,9 +2511,15 @@ function _iterable_to_array_limit$2(arr, i) {
2450
2511
  function _non_iterable_rest$2() {
2451
2512
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2452
2513
  }
2514
+ function _non_iterable_spread$3() {
2515
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2516
+ }
2453
2517
  function _sliced_to_array$2(arr, i) {
2454
2518
  return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$2();
2455
2519
  }
2520
+ function _to_consumable_array$3(arr) {
2521
+ return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$3();
2522
+ }
2456
2523
  function _unsupported_iterable_to_array$5(o, minLen) {
2457
2524
  if (!o) return;
2458
2525
  if (typeof o === "string") return _array_like_to_array$5(o, minLen);
@@ -2470,7 +2537,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2470
2537
  */ function combineLatestFromMapValuesObsFn(mapToObs) {
2471
2538
  var combineArrayFn = combineLatestFromArrayObsFn(mapToObs);
2472
2539
  return function(latestMap) {
2473
- var mapValues = Array.from(latestMap).map(function(y) {
2540
+ var mapValues = _to_consumable_array$3(latestMap).map(function(y) {
2474
2541
  return y[1];
2475
2542
  });
2476
2543
  return combineArrayFn(mapValues);
@@ -2520,7 +2587,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2520
2587
  var result = {};
2521
2588
  latestValues.forEach(function(param) {
2522
2589
  var _param = _sliced_to_array$2(param, 2), key = _param[0], value = _param[1];
2523
- result[key] = value;
2590
+ result[key] = value; // eslint-disable-line @typescript-eslint/no-explicit-any
2524
2591
  });
2525
2592
  return result;
2526
2593
  }));
@@ -2563,7 +2630,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2563
2630
  */ function errorOnEmissionsInPeriod(config) {
2564
2631
  var _config_period = config.period, period = _config_period === void 0 ? 1000 : _config_period, maxEmissionsPerPeriod = config.maxEmissionsPerPeriod, onError = config.onError, inputErrorFactory = config.errorFactory, inputErrorMessage = config.errorMessage, switchToObs = config.switchToObs;
2565
2632
  var errorMessage = inputErrorMessage !== null && inputErrorMessage !== void 0 ? inputErrorMessage : 'errorOnEmissionsInPeriod(): Too many emissions in time period.';
2566
- var errorFactory = inputErrorFactory ? inputErrorFactory : !switchToObs ? function() {
2633
+ var errorFactory = inputErrorFactory !== null && inputErrorFactory !== void 0 ? inputErrorFactory : !switchToObs ? function() {
2567
2634
  return new Error(errorMessage);
2568
2635
  } : undefined;
2569
2636
  return function(source) {
@@ -2623,6 +2690,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2623
2690
  }
2624
2691
  /**
2625
2692
  * `distinctUntilChanged` variant for iterables that only emits when the contained values change.
2693
+ *
2694
+ * @returns operator that suppresses consecutive iterable emissions with the same set of values
2626
2695
  */ function distinctUntilHasDifferentValues() {
2627
2696
  return distinctUntilChanged(hasSameValues);
2628
2697
  }
@@ -2876,7 +2945,8 @@ function _unsupported_iterable_to_array$4(o, minLen) {
2876
2945
  if (loading === true) {
2877
2946
  result = false;
2878
2947
  } else {
2879
- result = loading === false || Boolean(state.value || state.error) || state.value === null;
2948
+ var _state_value;
2949
+ result = loading === false || Boolean((_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : state.error) || state.value === null;
2880
2950
  }
2881
2951
  }
2882
2952
  return result;
@@ -2892,6 +2962,8 @@ function _unsupported_iterable_to_array$4(o, minLen) {
2892
2962
  * // { loading: false }
2893
2963
  * loadingStateType(state); // LoadingStateType.IDLE
2894
2964
  * ```
2965
+ *
2966
+ * @returns a loading state with `loading: false` and no value or error
2895
2967
  */ function idleLoadingState() {
2896
2968
  return {
2897
2969
  loading: false
@@ -3016,8 +3088,7 @@ function beginLoading(state) {
3016
3088
  */ function isLoadingStateWithStateType(type) {
3017
3089
  var defaultResult = type === LoadingStateType.IDLE ? true : false;
3018
3090
  return function(state) {
3019
- var result = state ? loadingStateType(state) === type : defaultResult;
3020
- return result;
3091
+ return state ? loadingStateType(state) === type : defaultResult;
3021
3092
  };
3022
3093
  }
3023
3094
  /**
@@ -3060,8 +3131,7 @@ function beginLoading(state) {
3060
3131
  * @param state - the loading state to check
3061
3132
  * @returns true if the state has a defined (non-undefined) value
3062
3133
  */ function isLoadingStateWithDefinedValue(state) {
3063
- var result = state ? state.value !== undefined : false;
3064
- return result;
3134
+ return state ? state.value !== undefined : false;
3065
3135
  }
3066
3136
  /**
3067
3137
  * Type guard that checks whether a {@link LoadingState} has a non-null error, regardless of loading status.
@@ -3075,8 +3145,7 @@ function beginLoading(state) {
3075
3145
  * @param state - the loading state to check
3076
3146
  * @returns true if the state has an error
3077
3147
  */ function isLoadingStateWithError(state) {
3078
- var result = state ? state.error != null : false;
3079
- return result;
3148
+ return state ? state.error != null : false;
3080
3149
  }
3081
3150
  /**
3082
3151
  * Type guard that checks whether a {@link LoadingState} has finished loading and has a defined value.
@@ -3084,8 +3153,7 @@ function beginLoading(state) {
3084
3153
  * @param state - the loading state to check
3085
3154
  * @returns true if finished loading with a non-undefined value
3086
3155
  */ function isLoadingStateFinishedLoadingWithDefinedValue(state) {
3087
- var result = state ? isLoadingStateFinishedLoading(state) && state.value !== undefined : false;
3088
- return result;
3156
+ return state ? isLoadingStateFinishedLoading(state) && state.value !== undefined : false;
3089
3157
  }
3090
3158
  /**
3091
3159
  * Type guard that checks whether a {@link LoadingState} has finished loading and has an error.
@@ -3093,8 +3161,7 @@ function beginLoading(state) {
3093
3161
  * @param state - the loading state to check
3094
3162
  * @returns true if finished loading with an error
3095
3163
  */ function isLoadingStateFinishedLoadingWithError(state) {
3096
- var result = state ? isLoadingStateFinishedLoading(state) && state.error != null : false;
3097
- return result;
3164
+ return state ? isLoadingStateFinishedLoading(state) && state.error != null : false;
3098
3165
  }
3099
3166
  /**
3100
3167
  * Compares the metadata (page, loading, error) of two {@link PageLoadingState} instances for equivalence.
@@ -3125,15 +3192,16 @@ function mergeLoadingStates() {
3125
3192
  args[_key] = arguments[_key];
3126
3193
  }
3127
3194
  var _loadingStates_find;
3128
- var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
3195
+ // eslint-disable-line jsdoc/require-jsdoc -- JSDoc is on the overload signatures above
3196
+ /* eslint-enable @typescript-eslint/max-params, @typescript-eslint/no-explicit-any */ var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
3129
3197
  var lastValueIsMergeFn = typeof validArgs[validArgs.length - 1] === 'function';
3130
- var loadingStates = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs;
3198
+ var loadingStates = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs; // eslint-disable-line @typescript-eslint/no-explicit-any
3131
3199
  var mergeFn = lastValueIsMergeFn ? args[validArgs.length - 1] : function() {
3132
3200
  for(var _len = arguments.length, inputArgs = new Array(_len), _key = 0; _key < _len; _key++){
3133
3201
  inputArgs[_key] = arguments[_key];
3134
3202
  }
3135
3203
  return mergeObjects(inputArgs);
3136
- };
3204
+ }; // eslint-disable-line @typescript-eslint/no-explicit-any
3137
3205
  var error = (_loadingStates_find = loadingStates.find(function(x) {
3138
3206
  return x.error;
3139
3207
  })) === null || _loadingStates_find === void 0 ? void 0 : _loadingStates_find.error; // find the first error
@@ -3141,7 +3209,7 @@ function mergeLoadingStates() {
3141
3209
  if (error) {
3142
3210
  // ignore all loading states, except for any error-prone item that is still loading
3143
3211
  var currentLoadings = loadingStates.map(function(x) {
3144
- return (x === null || x === void 0 ? void 0 : x.error) ? x.loading : false;
3212
+ return x.error ? x.loading : false;
3145
3213
  });
3146
3214
  var nonMaybeLoadings = currentLoadings.filter(function(x) {
3147
3215
  return x != null;
@@ -3227,10 +3295,10 @@ function mergeLoadingStates() {
3227
3295
  var mapValues = config.mapValues, mapState = config.mapState;
3228
3296
  var loading = isAnyLoadingStateInLoadingState(input);
3229
3297
  var error = input.map(function(x) {
3230
- return x === null || x === void 0 ? void 0 : x.error;
3231
- }).filter(function(x) {
3298
+ return x.error;
3299
+ }).find(function(x) {
3232
3300
  return Boolean(x);
3233
- })[0];
3301
+ });
3234
3302
  var result;
3235
3303
  if (!error && !loading) {
3236
3304
  if (mapValues) {
@@ -3252,7 +3320,7 @@ function mergeLoadingStates() {
3252
3320
  }
3253
3321
  function mapLoadingStateResults(input, config) {
3254
3322
  var mapValue = config.mapValue, mapState = config.mapState, _config_alwaysMapValue = config.alwaysMapValue, alwaysMapValue = _config_alwaysMapValue === void 0 ? false : _config_alwaysMapValue;
3255
- var inputValue = input === null || input === void 0 ? void 0 : input.value;
3323
+ var inputValue = input.value;
3256
3324
  var value;
3257
3325
  if ((inputValue != null || alwaysMapValue) && mapValue) {
3258
3326
  value = mapValue(inputValue, input);
@@ -3392,24 +3460,20 @@ function combineLoadingStates() {
3392
3460
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
3393
3461
  args[_key] = arguments[_key];
3394
3462
  }
3395
- var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
3463
+ // eslint-disable-line jsdoc/require-jsdoc -- JSDoc is on the overload signatures above
3464
+ /* eslint-enable @typescript-eslint/max-params, @typescript-eslint/no-explicit-any */ var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
3396
3465
  var lastValueIsMergeFn = typeof validArgs[validArgs.length - 1] === 'function';
3397
- var obsArgs = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs;
3466
+ var obsArgs = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs; // eslint-disable-line @typescript-eslint/no-explicit-any
3398
3467
  var mergeFn = lastValueIsMergeFn ? validArgs[validArgs.length - 1] : undefined;
3399
3468
  return combineLatest(obsArgs).pipe(distinctUntilChanged(function(x, y) {
3400
- if (x && y) {
3401
- var hasSameValues = x.findIndex(function(_, i) {
3402
- return x[i] !== y[i];
3403
- }) === -1;
3404
- return hasSameValues;
3405
- } else {
3406
- return x === y;
3407
- }
3469
+ return !x.some(function(_, i) {
3470
+ return x[i] !== y[i];
3471
+ });
3408
3472
  }), map(function(states) {
3409
- var result = mergeLoadingStates.apply(void 0, _to_consumable_array$1(states).concat([
3473
+ // eslint-disable-line @typescript-eslint/no-explicit-any
3474
+ return mergeLoadingStates.apply(void 0, _to_consumable_array$1(states).concat([
3410
3475
  mergeFn
3411
3476
  ]));
3412
- return result;
3413
3477
  }), shareReplay(1) // Share the result.
3414
3478
  );
3415
3479
  }
@@ -3436,6 +3500,7 @@ function combineLoadingStates() {
3436
3500
  * @param sources - An array of LoadingState observables to combine.
3437
3501
  * @returns An observable emitting a {@link LoadingState}<boolean> representing the combined status.
3438
3502
  */ function combineLoadingStatesStatus(sources) {
3503
+ // eslint-disable-line @typescript-eslint/no-explicit-any
3439
3504
  return combineLatest(sources).pipe(map(function(allLoadingStates) {
3440
3505
  var firstErrorState = allLoadingStates.find(function(x) {
3441
3506
  return x.error;
@@ -3444,7 +3509,7 @@ function combineLoadingStates() {
3444
3509
  if (firstErrorState) {
3445
3510
  result = errorResult(firstErrorState.error);
3446
3511
  } else {
3447
- var oneOrMoreStatesAreCurrentlyLoading = allLoadingStates.findIndex(isLoadingStateLoading) !== -1;
3512
+ var oneOrMoreStatesAreCurrentlyLoading = allLoadingStates.some(isLoadingStateLoading);
3448
3513
  if (oneOrMoreStatesAreCurrentlyLoading) {
3449
3514
  result = beginLoading(); // still loading
3450
3515
  } else {
@@ -3572,7 +3637,7 @@ function tapOnLoadingStateType(fn, type) {
3572
3637
  };
3573
3638
  }
3574
3639
  return tap(function(state) {
3575
- if (state != null && decisionFunction(state)) {
3640
+ if (decisionFunction(state)) {
3576
3641
  fn(state);
3577
3642
  }
3578
3643
  });
@@ -3724,6 +3789,10 @@ function distinctLoadingState(inputConfig) {
3724
3789
  *
3725
3790
  * Determines the `loading` flag based on whether an error is present, whether the value is defined,
3726
3791
  * and the `showLoadingOnUndefinedValue` setting. Loading progress is only included while loading.
3792
+ *
3793
+ * @param state - the current loading state to convert into a context event
3794
+ * @param input - configuration input controlling how the loading flag is derived
3795
+ * @returns a loading state context event derived from the given state
3727
3796
  */ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION(state, input) {
3728
3797
  var showLoadingOnUndefinedValue = input.showLoadingOnUndefinedValue;
3729
3798
  var error = state.error, value = state.value, loadingProgress = state.loadingProgress;
@@ -3794,7 +3863,7 @@ function distinctLoadingState(inputConfig) {
3794
3863
  return result;
3795
3864
  }), distinctUntilChanged(isLoadingStateEqual), shareReplay(1));
3796
3865
  var currentState$ = currentStateStream$.pipe(switchMap(function(x) {
3797
- return x ? x : of(undefined);
3866
+ return x !== null && x !== void 0 ? x : of(undefined);
3798
3867
  }));
3799
3868
  var state$ = currentState$.pipe(filterMaybe(), shareReplay(1));
3800
3869
  var loading$ = eventStream$.pipe(map(isLoadingStateLoading));
@@ -3838,7 +3907,8 @@ function distinctLoadingState(inputConfig) {
3838
3907
  * @param listLoadingState - the list loading state to check
3839
3908
  * @returns true if the value is empty or absent
3840
3909
  */ function isListLoadingStateWithEmptyValue(listLoadingState) {
3841
- return Boolean(!listLoadingState.value || !listLoadingState.value.length);
3910
+ var _listLoadingState_value;
3911
+ return Boolean(!((_listLoadingState_value = listLoadingState.value) === null || _listLoadingState_value === void 0 ? void 0 : _listLoadingState_value.length));
3842
3912
  }
3843
3913
  /**
3844
3914
  * RxJS operator that maps each emitted {@link ListLoadingState} to a boolean indicating whether the list is empty.
@@ -4120,6 +4190,8 @@ function _object_spread_props$3(target, source) {
4120
4190
  {
4121
4191
  /**
4122
4192
  * Whether the current state has a non-null error.
4193
+ *
4194
+ * @returns true if the current state contains an error
4123
4195
  */ key: "hasError",
4124
4196
  value: function hasError() {
4125
4197
  return isLoadingStateWithError(this._subject.value);
@@ -4612,55 +4684,48 @@ function itemAccumulator(itemIteration, inputMapItem) {
4612
4684
  return from(asPromise(countResults(allItems)));
4613
4685
  })).subscribe({
4614
4686
  next: function next(currentResultsCount) {
4615
- return _async_to_generator(function() {
4616
- return _ts_generator(this, function(_state) {
4617
- performTaskLoop({
4618
- initValue: currentResultsCount,
4619
- checkContinue: function checkContinue(x, i) {
4620
- return _async_to_generator(function() {
4621
- var result;
4622
- return _ts_generator(this, function(_state) {
4623
- switch(_state.label){
4624
- case 0:
4625
- return [
4626
- 4,
4627
- checkResultsLimit()
4628
- ];
4629
- case 1:
4630
- result = _state.sent();
4631
- currentResultsCount = result.currentCount;
4632
- return [
4633
- 2,
4634
- result.shouldContinue
4635
- ];
4636
- }
4637
- });
4638
- })();
4639
- },
4640
- next: function next() {
4641
- return _async_to_generator(function() {
4642
- return _ts_generator(this, function(_state) {
4687
+ performTaskLoop({
4688
+ initValue: currentResultsCount,
4689
+ checkContinue: function checkContinue(_x, _i) {
4690
+ return _async_to_generator(function() {
4691
+ var result;
4692
+ return _ts_generator(this, function(_state) {
4693
+ switch(_state.label){
4694
+ case 0:
4695
+ return [
4696
+ 4,
4697
+ checkResultsLimit()
4698
+ ];
4699
+ case 1:
4700
+ result = _state.sent();
4701
+ currentResultsCount = result.currentCount;
4643
4702
  return [
4644
4703
  2,
4645
- accumulator.itemIteration.nextPage()
4704
+ result.shouldContinue
4646
4705
  ];
4647
- });
4648
- })();
4649
- }
4650
- }).then(function(page) {
4651
- resolve({
4652
- page: page,
4653
- resultsCount: currentResultsCount
4706
+ }
4654
4707
  });
4655
- }).catch(function(error) {
4656
- reject(error);
4657
- throw error;
4658
- });
4659
- return [
4660
- 2
4661
- ];
4708
+ })();
4709
+ },
4710
+ next: function next() {
4711
+ return _async_to_generator(function() {
4712
+ return _ts_generator(this, function(_state) {
4713
+ return [
4714
+ 2,
4715
+ accumulator.itemIteration.nextPage()
4716
+ ];
4717
+ });
4718
+ })();
4719
+ }
4720
+ }).then(function(page) {
4721
+ resolve({
4722
+ page: page,
4723
+ resultsCount: currentResultsCount
4662
4724
  });
4663
- })();
4725
+ }).catch(function(error) {
4726
+ reject(error);
4727
+ throw error;
4728
+ });
4664
4729
  },
4665
4730
  error: function error(error) {
4666
4731
  reject(error);
@@ -4727,7 +4792,7 @@ function _unsupported_iterable_to_array$1(o, minLen) {
4727
4792
  return accumulator.currentAllItemPairs$.pipe(scanBuildArray(function(allItems) {
4728
4793
  var pairs = allItems;
4729
4794
  var firstLatestItemPair = lastValue(allItems);
4730
- var skipValue = firstLatestItemPair === null || firstLatestItemPair === void 0 ? void 0 : firstLatestItemPair.input;
4795
+ var skipValue = firstLatestItemPair === null || firstLatestItemPair === void 0 ? void 0 : firstLatestItemPair.input; // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- lastValue() can return undefined at runtime for empty arrays
4731
4796
  var seed = flattenArray(pairs.map(function(x) {
4732
4797
  return x.output;
4733
4798
  }));
@@ -4794,6 +4859,7 @@ function _unsupported_iterable_to_array$1(o, minLen) {
4794
4859
  * @param pageItemAccumulator - accumulator to observe the current page from
4795
4860
  * @returns observable emitting the most recently loaded page number
4796
4861
  */ function pageItemAccumulatorCurrentPage(pageItemAccumulator) {
4862
+ // eslint-disable-line @typescript-eslint/no-explicit-any
4797
4863
  return pageItemAccumulator.itemIteration.latestLoadedPage$;
4798
4864
  }
4799
4865
 
@@ -5159,11 +5225,10 @@ function _unsupported_iterable_to_array(o, minLen) {
5159
5225
  hasNextPage: invertMaybeBoolean(end)
5160
5226
  });
5161
5227
  }
5162
- var result = {
5228
+ return {
5163
5229
  n: request.n,
5164
5230
  state: state
5165
5231
  };
5166
- return result;
5167
5232
  }));
5168
5233
  }), scan(function(acc, x) {
5169
5234
  var n = x.n, curr = x.state;
@@ -5176,19 +5241,15 @@ function _unsupported_iterable_to_array(o, minLen) {
5176
5241
  lastSuccessful: acc.lastSuccessful
5177
5242
  };
5178
5243
  // If it was a replay of the previous result, change nothing.
5179
- if (acc.current !== curr) {
5180
- if (isLoadingStateFinishedLoading(curr)) {
5181
- // only set first finished once
5182
- if (!next.firstFinished) {
5183
- next.firstFinished = curr;
5184
- }
5185
- next.latestFinished = curr;
5186
- if (!isLoadingStateWithError(curr)) {
5187
- next.lastSuccessful = curr;
5188
- if (!next.firstSuccessful) {
5189
- next.firstSuccessful = curr;
5190
- }
5191
- }
5244
+ if (acc.current !== curr && isLoadingStateFinishedLoading(curr)) {
5245
+ var // only set first finished once
5246
+ _next, _firstFinished;
5247
+ (_firstFinished = (_next = next).firstFinished) !== null && _firstFinished !== void 0 ? _firstFinished : _next.firstFinished = curr;
5248
+ next.latestFinished = curr;
5249
+ if (!isLoadingStateWithError(curr)) {
5250
+ var _next1, _firstSuccessful;
5251
+ next.lastSuccessful = curr;
5252
+ (_firstSuccessful = (_next1 = next).firstSuccessful) !== null && _firstSuccessful !== void 0 ? _firstSuccessful : _next1.firstSuccessful = curr;
5192
5253
  }
5193
5254
  }
5194
5255
  return next;
@@ -5497,6 +5558,10 @@ function _type_of(obj) {
5497
5558
  * Useful for deferring an action until all locks are released, with a safety timeout to avoid waiting indefinitely.
5498
5559
  *
5499
5560
  * @param config - configuration specifying the lock set, callback, timeout, and optional delay
5561
+ * @param config.lockSet - the lock set to monitor for the next unlock event
5562
+ * @param config.fn - optional callback to invoke when the lock set unlocks or the timeout is reached
5563
+ * @param config.timeout - maximum time in milliseconds to wait before timing out
5564
+ * @param config.delayTime - optional delay in milliseconds after unlock before invoking the callback
5500
5565
  * @returns subscription that can be unsubscribed to cancel the wait
5501
5566
  *
5502
5567
  * @example
@@ -5924,14 +5989,14 @@ function _define_property(obj, key, value) {
5924
5989
  *
5925
5990
  * If the loading state returns an error, the error is forwarded.
5926
5991
  *
5927
- * @param loadingStateObs
5992
+ * @param loadingStateObs - observable of the loading state to track as the work result
5928
5993
  */ key: "startWorkingWithLoadingStateObservable",
5929
5994
  value: function startWorkingWithLoadingStateObservable(loadingStateObs) {
5930
5995
  var _this = this;
5931
5996
  var obs = preventComplete(loadingStateObs).pipe(filterMaybe(), shareReplay(1));
5932
5997
  this._sub.subscription = obs.pipe(delay(0), first()).subscribe(function() {
5933
5998
  _this.startWorkingWithObservable(obs.pipe(filter(function(x) {
5934
- return x && !isLoadingStateLoading(x);
5999
+ return !isLoadingStateLoading(x);
5935
6000
  }), map(function(x) {
5936
6001
  if (x.error) {
5937
6002
  throw x.error;
@@ -5950,11 +6015,12 @@ function _define_property(obj, key, value) {
5950
6015
  *
5951
6016
  * It is used in conjunction with startWorking() and ideal for cases where multiple observables or promises are used.
5952
6017
  *
5953
- * @param loadingStateObs
6018
+ * @param loadingStateObs - promise or observable of the loading state to track for errors
6019
+ * @returns a promise that resolves with the value from the loading state or rejects on error
5954
6020
  */ key: "performTaskWithLoadingState",
5955
6021
  value: function performTaskWithLoadingState(loadingStateObs) {
5956
6022
  var _this = this;
5957
- return promiseFromLoadingState(from(loadingStateObs).pipe(filterMaybe(), tap(function(x) {
6023
+ return promiseFromLoadingState(from(loadingStateObs).pipe(filterMaybe(), tap(function(_x) {
5958
6024
  _this._setWorking(true); // mark as working if not already marked.
5959
6025
  }))).catch(function(e) {
5960
6026
  // catch and throw any errors.
@@ -5969,7 +6035,7 @@ function _define_property(obj, key, value) {
5969
6035
  *
5970
6036
  * If an error is thrown, the error is forwarded to the reject function.
5971
6037
  *
5972
- * @param fn
6038
+ * @param fn - synchronous function that returns the result value or throws an error
5973
6039
  */ key: "performTaskWithReturnValue",
5974
6040
  value: function performTaskWithReturnValue(fn) {
5975
6041
  try {
@@ -5984,6 +6050,8 @@ function _define_property(obj, key, value) {
5984
6050
  {
5985
6051
  /**
5986
6052
  * Begins working using a promise.
6053
+ *
6054
+ * @param promise - the promise that represents the asynchronous work
5987
6055
  */ key: "startWorkingWithPromise",
5988
6056
  value: function startWorkingWithPromise(promise) {
5989
6057
  this.startWorkingWithObservable(from(promise));
@@ -5992,6 +6060,8 @@ function _define_property(obj, key, value) {
5992
6060
  {
5993
6061
  /**
5994
6062
  * Begins working using an observable.
6063
+ *
6064
+ * @param workObs - the observable that represents the asynchronous work and emits the result
5995
6065
  */ key: "startWorkingWithObservable",
5996
6066
  value: function startWorkingWithObservable(workObs) {
5997
6067
  var _this = this;
@@ -6018,6 +6088,8 @@ function _define_property(obj, key, value) {
6018
6088
  {
6019
6089
  /**
6020
6090
  * Sets success on the work.
6091
+ *
6092
+ * @param result - the successful result value to pass to the delegate
6021
6093
  */ key: "success",
6022
6094
  value: function success(result) {
6023
6095
  this._setComplete(successResult(result));
@@ -6027,6 +6099,8 @@ function _define_property(obj, key, value) {
6027
6099
  {
6028
6100
  /**
6029
6101
  * Sets rejected on the work.
6102
+ *
6103
+ * @param error - the error to pass to the delegate as the rejection reason
6030
6104
  */ key: "reject",
6031
6105
  value: function reject(error) {
6032
6106
  this._setComplete(errorResult(error));
@@ -6088,6 +6162,8 @@ function _define_property(obj, key, value) {
6088
6162
  * ```
6089
6163
  *
6090
6164
  * @param config - work function and delegate configuration
6165
+ * @param config.work - the work function to execute for each input value
6166
+ * @param config.delegate - delegate that receives lifecycle callbacks (start, success, reject)
6091
6167
  * @returns a factory function that creates WorkInstance for each input
6092
6168
  */ function workFactory(param) {
6093
6169
  var work = param.work, delegate = param.delegate;
@@ -6101,13 +6177,11 @@ function _define_property(obj, key, value) {
6101
6177
  handler.reject(e);
6102
6178
  return;
6103
6179
  }
6104
- if (!handler.isComplete) {
6105
- if (fnResult && isObservable(fnResult)) {
6106
- if (handler.hasStarted) {
6107
- throw new Error('Work already marked as begun from returned result. Either return an observable or use the handler directly.');
6108
- }
6109
- handler.startWorkingWithObservable(fnResult);
6180
+ if (!handler.isComplete && fnResult && isObservable(fnResult)) {
6181
+ if (handler.hasStarted) {
6182
+ throw new Error('Work already marked as begun from returned result. Either return an observable or use the handler directly.');
6110
6183
  }
6184
+ handler.startWorkingWithObservable(fnResult);
6111
6185
  }
6112
6186
  return handler;
6113
6187
  };