@livequery/core 2.0.85 → 2.0.87

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/dist/index.js CHANGED
@@ -1242,45 +1242,56 @@ function process(asyncIterable, subscriber) {
1242
1242
  });
1243
1243
  }
1244
1244
 
1245
- // node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
1246
- function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
1247
- if (delay === undefined) {
1248
- delay = 0;
1249
- }
1250
- if (repeat === undefined) {
1251
- repeat = false;
1252
- }
1253
- var scheduleSubscription = scheduler.schedule(function() {
1254
- work();
1255
- if (repeat) {
1256
- parentSubscription.add(this.schedule(null, delay));
1257
- } else {
1258
- this.unsubscribe();
1245
+ // node_modules/rxjs/dist/esm5/internal/observable/defer.js
1246
+ function defer(observableFactory) {
1247
+ return new Observable(function(subscriber) {
1248
+ innerFrom(observableFactory()).subscribe(subscriber);
1249
+ });
1250
+ }
1251
+ // node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
1252
+ var isArray = Array.isArray;
1253
+ var getPrototypeOf = Object.getPrototypeOf;
1254
+ var objectProto = Object.prototype;
1255
+ var getKeys = Object.keys;
1256
+ function argsArgArrayOrObject(args) {
1257
+ if (args.length === 1) {
1258
+ var first_1 = args[0];
1259
+ if (isArray(first_1)) {
1260
+ return { args: first_1, keys: null };
1261
+ }
1262
+ if (isPOJO(first_1)) {
1263
+ var keys = getKeys(first_1);
1264
+ return {
1265
+ args: keys.map(function(key) {
1266
+ return first_1[key];
1267
+ }),
1268
+ keys
1269
+ };
1259
1270
  }
1260
- }, delay);
1261
- parentSubscription.add(scheduleSubscription);
1262
- if (!repeat) {
1263
- return scheduleSubscription;
1264
1271
  }
1272
+ return { args, keys: null };
1273
+ }
1274
+ function isPOJO(obj) {
1275
+ return obj && typeof obj === "object" && getPrototypeOf(obj) === objectProto;
1265
1276
  }
1266
1277
 
1267
- // node_modules/rxjs/dist/esm5/internal/util/lift.js
1268
- function hasLift(source) {
1269
- return isFunction(source === null || source === undefined ? undefined : source.lift);
1278
+ // node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
1279
+ function isScheduler(value) {
1280
+ return value && isFunction(value.schedule);
1270
1281
  }
1271
- function operate(init) {
1272
- return function(source) {
1273
- if (hasLift(source)) {
1274
- return source.lift(function(liftedSource) {
1275
- try {
1276
- return init(liftedSource, this);
1277
- } catch (err) {
1278
- this.error(err);
1279
- }
1280
- });
1281
- }
1282
- throw new TypeError("Unable to lift unknown Observable type");
1283
- };
1282
+
1283
+ // node_modules/rxjs/dist/esm5/internal/util/args.js
1284
+ function last(arr) {
1285
+ return arr[arr.length - 1];
1286
+ }
1287
+ function popResultSelector(args) {
1288
+ return isFunction(last(args)) ? args.pop() : undefined;
1289
+ }
1290
+ function popScheduler(args) {
1291
+ return isScheduler(last(args)) ? args.pop() : undefined;
1292
+ }
1293
+ function popNumber(args, defaultValue) {
1294
+ return typeof last(args) === "number" ? args.pop() : defaultValue;
1284
1295
  }
1285
1296
 
1286
1297
  // node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
@@ -1331,6 +1342,117 @@ var OperatorSubscriber = function(_super) {
1331
1342
  return OperatorSubscriber2;
1332
1343
  }(Subscriber);
1333
1344
 
1345
+ // node_modules/rxjs/dist/esm5/internal/util/lift.js
1346
+ function hasLift(source) {
1347
+ return isFunction(source === null || source === undefined ? undefined : source.lift);
1348
+ }
1349
+ function operate(init) {
1350
+ return function(source) {
1351
+ if (hasLift(source)) {
1352
+ return source.lift(function(liftedSource) {
1353
+ try {
1354
+ return init(liftedSource, this);
1355
+ } catch (err) {
1356
+ this.error(err);
1357
+ }
1358
+ });
1359
+ }
1360
+ throw new TypeError("Unable to lift unknown Observable type");
1361
+ };
1362
+ }
1363
+
1364
+ // node_modules/rxjs/dist/esm5/internal/operators/map.js
1365
+ function map(project, thisArg) {
1366
+ return operate(function(source, subscriber) {
1367
+ var index = 0;
1368
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1369
+ subscriber.next(project.call(thisArg, value, index++));
1370
+ }));
1371
+ });
1372
+ }
1373
+
1374
+ // node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
1375
+ var isArray2 = Array.isArray;
1376
+ function callOrApply(fn, args) {
1377
+ return isArray2(args) ? fn.apply(undefined, __spreadArray([], __read(args))) : fn(args);
1378
+ }
1379
+ function mapOneOrManyArgs(fn) {
1380
+ return map(function(args) {
1381
+ return callOrApply(fn, args);
1382
+ });
1383
+ }
1384
+
1385
+ // node_modules/rxjs/dist/esm5/internal/util/createObject.js
1386
+ function createObject(keys, values) {
1387
+ return keys.reduce(function(result, key, i) {
1388
+ return result[key] = values[i], result;
1389
+ }, {});
1390
+ }
1391
+
1392
+ // node_modules/rxjs/dist/esm5/internal/observable/forkJoin.js
1393
+ function forkJoin() {
1394
+ var args = [];
1395
+ for (var _i = 0;_i < arguments.length; _i++) {
1396
+ args[_i] = arguments[_i];
1397
+ }
1398
+ var resultSelector = popResultSelector(args);
1399
+ var _a = argsArgArrayOrObject(args), sources = _a.args, keys = _a.keys;
1400
+ var result = new Observable(function(subscriber) {
1401
+ var length = sources.length;
1402
+ if (!length) {
1403
+ subscriber.complete();
1404
+ return;
1405
+ }
1406
+ var values = new Array(length);
1407
+ var remainingCompletions = length;
1408
+ var remainingEmissions = length;
1409
+ var _loop_1 = function(sourceIndex2) {
1410
+ var hasValue = false;
1411
+ innerFrom(sources[sourceIndex2]).subscribe(createOperatorSubscriber(subscriber, function(value) {
1412
+ if (!hasValue) {
1413
+ hasValue = true;
1414
+ remainingEmissions--;
1415
+ }
1416
+ values[sourceIndex2] = value;
1417
+ }, function() {
1418
+ return remainingCompletions--;
1419
+ }, undefined, function() {
1420
+ if (!remainingCompletions || !hasValue) {
1421
+ if (!remainingEmissions) {
1422
+ subscriber.next(keys ? createObject(keys, values) : values);
1423
+ }
1424
+ subscriber.complete();
1425
+ }
1426
+ }));
1427
+ };
1428
+ for (var sourceIndex = 0;sourceIndex < length; sourceIndex++) {
1429
+ _loop_1(sourceIndex);
1430
+ }
1431
+ });
1432
+ return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;
1433
+ }
1434
+ // node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
1435
+ function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
1436
+ if (delay === undefined) {
1437
+ delay = 0;
1438
+ }
1439
+ if (repeat === undefined) {
1440
+ repeat = false;
1441
+ }
1442
+ var scheduleSubscription = scheduler.schedule(function() {
1443
+ work();
1444
+ if (repeat) {
1445
+ parentSubscription.add(this.schedule(null, delay));
1446
+ } else {
1447
+ this.unsubscribe();
1448
+ }
1449
+ }, delay);
1450
+ parentSubscription.add(scheduleSubscription);
1451
+ if (!repeat) {
1452
+ return scheduleSubscription;
1453
+ }
1454
+ }
1455
+
1334
1456
  // node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
1335
1457
  function observeOn(scheduler, delay) {
1336
1458
  if (delay === undefined) {
@@ -1476,16 +1598,6 @@ function scheduled(input, scheduler) {
1476
1598
  function from(input, scheduler) {
1477
1599
  return scheduler ? scheduled(input, scheduler) : innerFrom(input);
1478
1600
  }
1479
- // node_modules/rxjs/dist/esm5/internal/operators/map.js
1480
- function map(project, thisArg) {
1481
- return operate(function(source, subscriber) {
1482
- var index = 0;
1483
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1484
- subscriber.next(project.call(thisArg, value, index++));
1485
- }));
1486
- });
1487
- }
1488
-
1489
1601
  // node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
1490
1602
  function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
1491
1603
  var buffer = [];
@@ -1578,22 +1690,6 @@ var EMPTY = new Observable(function(subscriber) {
1578
1690
  return subscriber.complete();
1579
1691
  });
1580
1692
 
1581
- // node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
1582
- function isScheduler(value) {
1583
- return value && isFunction(value.schedule);
1584
- }
1585
-
1586
- // node_modules/rxjs/dist/esm5/internal/util/args.js
1587
- function last(arr) {
1588
- return arr[arr.length - 1];
1589
- }
1590
- function popScheduler(args) {
1591
- return isScheduler(last(args)) ? args.pop() : undefined;
1592
- }
1593
- function popNumber(args, defaultValue) {
1594
- return typeof last(args) === "number" ? args.pop() : defaultValue;
1595
- }
1596
-
1597
1693
  // node_modules/rxjs/dist/esm5/internal/observable/merge.js
1598
1694
  function merge() {
1599
1695
  var args = [];
@@ -1852,60 +1948,14 @@ function debounceTime(dueTime, scheduler) {
1852
1948
  }));
1853
1949
  });
1854
1950
  }
1855
- // node_modules/rxjs/dist/esm5/internal/operators/concatAll.js
1856
- function concatAll() {
1857
- return mergeAll(1);
1858
- }
1859
-
1860
- // node_modules/rxjs/dist/esm5/internal/observable/concat.js
1861
- function concat() {
1862
- var args = [];
1863
- for (var _i = 0;_i < arguments.length; _i++) {
1864
- args[_i] = arguments[_i];
1951
+ // node_modules/rxjs/dist/esm5/internal/operators/expand.js
1952
+ function expand(project, concurrent, scheduler) {
1953
+ if (concurrent === undefined) {
1954
+ concurrent = Infinity;
1865
1955
  }
1866
- return concatAll()(from(args, popScheduler(args)));
1867
- }
1868
-
1869
- // node_modules/rxjs/dist/esm5/internal/operators/take.js
1870
- function take(count) {
1871
- return count <= 0 ? function() {
1872
- return EMPTY;
1873
- } : operate(function(source, subscriber) {
1874
- var seen = 0;
1875
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1876
- if (++seen <= count) {
1877
- subscriber.next(value);
1878
- if (count <= seen) {
1879
- subscriber.complete();
1880
- }
1881
- }
1882
- }));
1883
- });
1884
- }
1885
-
1886
- // node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js
1887
- function ignoreElements() {
1956
+ concurrent = (concurrent || 0) < 1 ? Infinity : concurrent;
1888
1957
  return operate(function(source, subscriber) {
1889
- source.subscribe(createOperatorSubscriber(subscriber, noop));
1890
- });
1891
- }
1892
-
1893
- // node_modules/rxjs/dist/esm5/internal/operators/mapTo.js
1894
- function mapTo(value) {
1895
- return map(function() {
1896
- return value;
1897
- });
1898
- }
1899
-
1900
- // node_modules/rxjs/dist/esm5/internal/operators/delayWhen.js
1901
- function delayWhen(delayDurationSelector, subscriptionDelay) {
1902
- if (subscriptionDelay) {
1903
- return function(source) {
1904
- return concat(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
1905
- };
1906
- }
1907
- return mergeMap(function(value, index) {
1908
- return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value));
1958
+ return mergeInternals(source, subscriber, project, concurrent, undefined, true, scheduler);
1909
1959
  });
1910
1960
  }
1911
1961
  // node_modules/rxjs/dist/esm5/internal/operators/filter.js
@@ -1927,6 +1977,157 @@ function finalize(callback) {
1927
1977
  }
1928
1978
  });
1929
1979
  }
1980
+ // node_modules/rxjs/dist/esm5/internal/operators/groupBy.js
1981
+ function groupBy(keySelector, elementOrOptions, duration, connector) {
1982
+ return operate(function(source, subscriber) {
1983
+ var element;
1984
+ if (!elementOrOptions || typeof elementOrOptions === "function") {
1985
+ element = elementOrOptions;
1986
+ } else {
1987
+ duration = elementOrOptions.duration, element = elementOrOptions.element, connector = elementOrOptions.connector;
1988
+ }
1989
+ var groups = new Map;
1990
+ var notify = function(cb) {
1991
+ groups.forEach(cb);
1992
+ cb(subscriber);
1993
+ };
1994
+ var handleError = function(err) {
1995
+ return notify(function(consumer) {
1996
+ return consumer.error(err);
1997
+ });
1998
+ };
1999
+ var activeGroups = 0;
2000
+ var teardownAttempted = false;
2001
+ var groupBySourceSubscriber = new OperatorSubscriber(subscriber, function(value) {
2002
+ try {
2003
+ var key_1 = keySelector(value);
2004
+ var group_1 = groups.get(key_1);
2005
+ if (!group_1) {
2006
+ groups.set(key_1, group_1 = connector ? connector() : new Subject);
2007
+ var grouped = createGroupedObservable(key_1, group_1);
2008
+ subscriber.next(grouped);
2009
+ if (duration) {
2010
+ var durationSubscriber_1 = createOperatorSubscriber(group_1, function() {
2011
+ group_1.complete();
2012
+ durationSubscriber_1 === null || durationSubscriber_1 === undefined || durationSubscriber_1.unsubscribe();
2013
+ }, undefined, undefined, function() {
2014
+ return groups.delete(key_1);
2015
+ });
2016
+ groupBySourceSubscriber.add(innerFrom(duration(grouped)).subscribe(durationSubscriber_1));
2017
+ }
2018
+ }
2019
+ group_1.next(element ? element(value) : value);
2020
+ } catch (err) {
2021
+ handleError(err);
2022
+ }
2023
+ }, function() {
2024
+ return notify(function(consumer) {
2025
+ return consumer.complete();
2026
+ });
2027
+ }, handleError, function() {
2028
+ return groups.clear();
2029
+ }, function() {
2030
+ teardownAttempted = true;
2031
+ return activeGroups === 0;
2032
+ });
2033
+ source.subscribe(groupBySourceSubscriber);
2034
+ function createGroupedObservable(key, groupSubject) {
2035
+ var result = new Observable(function(groupSubscriber) {
2036
+ activeGroups++;
2037
+ var innerSub = groupSubject.subscribe(groupSubscriber);
2038
+ return function() {
2039
+ innerSub.unsubscribe();
2040
+ --activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe();
2041
+ };
2042
+ });
2043
+ result.key = key;
2044
+ return result;
2045
+ }
2046
+ });
2047
+ }
2048
+ // node_modules/rxjs/dist/esm5/internal/observable/throwError.js
2049
+ function throwError(errorOrErrorFactory, scheduler) {
2050
+ var errorFactory = isFunction(errorOrErrorFactory) ? errorOrErrorFactory : function() {
2051
+ return errorOrErrorFactory;
2052
+ };
2053
+ var init = function(subscriber) {
2054
+ return subscriber.error(errorFactory());
2055
+ };
2056
+ return new Observable(scheduler ? function(subscriber) {
2057
+ return scheduler.schedule(init, 0, subscriber);
2058
+ } : init);
2059
+ }
2060
+
2061
+ // node_modules/rxjs/dist/esm5/internal/Notification.js
2062
+ var NotificationKind;
2063
+ (function(NotificationKind2) {
2064
+ NotificationKind2["NEXT"] = "N";
2065
+ NotificationKind2["ERROR"] = "E";
2066
+ NotificationKind2["COMPLETE"] = "C";
2067
+ })(NotificationKind || (NotificationKind = {}));
2068
+ var Notification = function() {
2069
+ function Notification2(kind, value, error) {
2070
+ this.kind = kind;
2071
+ this.value = value;
2072
+ this.error = error;
2073
+ this.hasValue = kind === "N";
2074
+ }
2075
+ Notification2.prototype.observe = function(observer) {
2076
+ return observeNotification(this, observer);
2077
+ };
2078
+ Notification2.prototype.do = function(nextHandler, errorHandler, completeHandler) {
2079
+ var _a = this, kind = _a.kind, value = _a.value, error = _a.error;
2080
+ return kind === "N" ? nextHandler === null || nextHandler === undefined ? undefined : nextHandler(value) : kind === "E" ? errorHandler === null || errorHandler === undefined ? undefined : errorHandler(error) : completeHandler === null || completeHandler === undefined ? undefined : completeHandler();
2081
+ };
2082
+ Notification2.prototype.accept = function(nextOrObserver, error, complete) {
2083
+ var _a;
2084
+ return isFunction((_a = nextOrObserver) === null || _a === undefined ? undefined : _a.next) ? this.observe(nextOrObserver) : this.do(nextOrObserver, error, complete);
2085
+ };
2086
+ Notification2.prototype.toObservable = function() {
2087
+ var _a = this, kind = _a.kind, value = _a.value, error = _a.error;
2088
+ var result = kind === "N" ? of(value) : kind === "E" ? throwError(function() {
2089
+ return error;
2090
+ }) : kind === "C" ? EMPTY : 0;
2091
+ if (!result) {
2092
+ throw new TypeError("Unexpected notification kind " + kind);
2093
+ }
2094
+ return result;
2095
+ };
2096
+ Notification2.createNext = function(value) {
2097
+ return new Notification2("N", value);
2098
+ };
2099
+ Notification2.createError = function(err) {
2100
+ return new Notification2("E", undefined, err);
2101
+ };
2102
+ Notification2.createComplete = function() {
2103
+ return Notification2.completeNotification;
2104
+ };
2105
+ Notification2.completeNotification = new Notification2("C");
2106
+ return Notification2;
2107
+ }();
2108
+ function observeNotification(notification, observer) {
2109
+ var _a, _b, _c;
2110
+ var _d = notification, kind = _d.kind, value = _d.value, error = _d.error;
2111
+ if (typeof kind !== "string") {
2112
+ throw new TypeError('Invalid notification, missing "kind"');
2113
+ }
2114
+ kind === "N" ? (_a = observer.next) === null || _a === undefined || _a.call(observer, value) : kind === "E" ? (_b = observer.error) === null || _b === undefined || _b.call(observer, error) : (_c = observer.complete) === null || _c === undefined || _c.call(observer);
2115
+ }
2116
+
2117
+ // node_modules/rxjs/dist/esm5/internal/operators/materialize.js
2118
+ function materialize() {
2119
+ return operate(function(source, subscriber) {
2120
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2121
+ subscriber.next(Notification.createNext(value));
2122
+ }, function() {
2123
+ subscriber.next(Notification.createComplete());
2124
+ subscriber.complete();
2125
+ }, function(err) {
2126
+ subscriber.next(Notification.createError(err));
2127
+ subscriber.complete();
2128
+ }));
2129
+ });
2130
+ }
1930
2131
  // node_modules/rxjs/dist/esm5/internal/operators/pairwise.js
1931
2132
  function pairwise() {
1932
2133
  return operate(function(source, subscriber) {
@@ -1940,6 +2141,27 @@ function pairwise() {
1940
2141
  }));
1941
2142
  });
1942
2143
  }
2144
+ // node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js
2145
+ function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) {
2146
+ return function(source, subscriber) {
2147
+ var hasState = hasSeed;
2148
+ var state = seed;
2149
+ var index = 0;
2150
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2151
+ var i = index++;
2152
+ state = hasState ? accumulator(state, value, i) : (hasState = true, value);
2153
+ emitOnNext && subscriber.next(state);
2154
+ }, emitBeforeComplete && function() {
2155
+ hasState && subscriber.next(state);
2156
+ subscriber.complete();
2157
+ }));
2158
+ };
2159
+ }
2160
+
2161
+ // node_modules/rxjs/dist/esm5/internal/operators/scan.js
2162
+ function scan(accumulator, seed) {
2163
+ return operate(scanInternals(accumulator, seed, arguments.length >= 2, true));
2164
+ }
1943
2165
  // node_modules/rxjs/dist/esm5/internal/ReplaySubject.js
1944
2166
  var ReplaySubject = function(_super) {
1945
2167
  __extends(ReplaySubject2, _super);
@@ -2131,6 +2353,29 @@ function switchMap(project, resultSelector) {
2131
2353
  }));
2132
2354
  });
2133
2355
  }
2356
+ // node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js
2357
+ function takeUntil(notifier) {
2358
+ return operate(function(source, subscriber) {
2359
+ innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function() {
2360
+ return subscriber.complete();
2361
+ }, noop));
2362
+ !subscriber.closed && source.subscribe(subscriber);
2363
+ });
2364
+ }
2365
+ // node_modules/rxjs/dist/esm5/internal/operators/takeWhile.js
2366
+ function takeWhile(predicate, inclusive) {
2367
+ if (inclusive === undefined) {
2368
+ inclusive = false;
2369
+ }
2370
+ return operate(function(source, subscriber) {
2371
+ var index = 0;
2372
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2373
+ var result = predicate(value, index++);
2374
+ (result || inclusive) && subscriber.next(value);
2375
+ !result && subscriber.complete();
2376
+ }));
2377
+ });
2378
+ }
2134
2379
  // node_modules/rxjs/dist/esm5/internal/operators/tap.js
2135
2380
  function tap(observerOrNext, error, complete) {
2136
2381
  var tapObserver = isFunction(observerOrNext) || error || complete ? { next: observerOrNext, error, complete } : observerOrNext;
@@ -2185,6 +2430,7 @@ class LivequeryDocument extends BehaviorSubject {
2185
2430
 
2186
2431
  // src/LivequeryCollection.ts
2187
2432
  class LivequeryCollection {
2433
+ options;
2188
2434
  id = (Math.random() * 1000000000000000000).toString(36);
2189
2435
  #keys = new Map;
2190
2436
  #indexes;
@@ -2192,7 +2438,6 @@ class LivequeryCollection {
2192
2438
  #filters = new Subject;
2193
2439
  ref;
2194
2440
  collection_ref;
2195
- #items = [];
2196
2441
  items;
2197
2442
  summary;
2198
2443
  metadata;
@@ -2200,8 +2445,8 @@ class LivequeryCollection {
2200
2445
  filters;
2201
2446
  paging;
2202
2447
  error;
2203
- options;
2204
- constructor(options) {
2448
+ constructor(options = {}) {
2449
+ this.options = options;
2205
2450
  this.#indexes = new Map;
2206
2451
  this.items = new BehaviorSubject([]);
2207
2452
  this.summary = new BehaviorSubject({});
@@ -2216,8 +2461,9 @@ class LivequeryCollection {
2216
2461
  this.options = options;
2217
2462
  }
2218
2463
  }
2219
- #reindex() {
2220
- this.#indexes = this.#items.reduce((p, c, index) => {
2464
+ #commit(items) {
2465
+ this.items.next(items);
2466
+ this.#indexes = items.reduce((p, c, index) => {
2221
2467
  p.set(c.value.id, index);
2222
2468
  return p;
2223
2469
  }, new Map);
@@ -2232,7 +2478,7 @@ class LivequeryCollection {
2232
2478
  this.#core = core;
2233
2479
  const timer2 = this.options.lazy !== true && setTimeout(() => this.query(this.filters.value || {}));
2234
2480
  this.#subscription?.unsubscribe();
2235
- this.#subscription = merge(this.options.debounce ? this.#filters.pipe(debounceTime(this.options.debounce), switchMap((filters) => this.query(filters))) : EMPTY, core.watch(this.ref, this.id).pipe(finalize(() => {
2481
+ this.#subscription = merge(this.options.debounce ? merge(this.#filters.pipe(debounceTime(this.options.debounce), switchMap((filters) => this.query(filters)))) : EMPTY, core.watch(this.ref, this.id, this.options.mode || "server-first").pipe(finalize(() => {
2236
2482
  timer2 && clearTimeout(timer2);
2237
2483
  }), tap((event) => {
2238
2484
  event.summary && this.summary.next(event.summary);
@@ -2287,7 +2533,7 @@ class LivequeryCollection {
2287
2533
  const target = index != null && index >= 0 ? p[index] : null;
2288
2534
  target && target.next({ ...target.value, ...data });
2289
2535
  return p;
2290
- }, this.#items);
2536
+ }, this.items.value);
2291
2537
  const new_items = events.added.filter((a) => a.data).reduce((p, c) => {
2292
2538
  if (!p.indexes.has(c.id)) {
2293
2539
  const doc = new LivequeryDocument(this, { id: c.id, ...c.data });
@@ -2310,31 +2556,20 @@ class LivequeryCollection {
2310
2556
  ...new_items.list
2311
2557
  ]);
2312
2558
  const items = chaos ? unsort_items.sort(sorter) : unsort_items;
2313
- if (chaos) {
2314
- this.#items = items;
2315
- this.items.next(this.options.visible ? items.filter((i) => this.options.visible(i.value)) : items);
2316
- this.#reindex();
2317
- }
2559
+ chaos && this.#commit(items);
2318
2560
  event.from == "query" && this.loading.next(null);
2319
2561
  event.paging && this.paging.next(event.paging);
2320
2562
  event.from == "query" && this.loading.next(null);
2321
2563
  }))).subscribe();
2322
2564
  return this.#subscription;
2323
2565
  }
2324
- async show(visible) {
2325
- this.options.visible = visible;
2326
- this.items.next(this.options.visible ? this.#items.filter((i) => this.options.visible(i.value)) : this.#items);
2327
- }
2328
2566
  async#query(filters, flush) {
2329
2567
  if (!this.#core)
2330
2568
  return;
2331
2569
  if (!this.ref)
2332
2570
  return;
2333
2571
  this.error.next(null);
2334
- if (flush) {
2335
- this.#items = [];
2336
- this.items.next([]);
2337
- }
2572
+ flush && this.#commit([]);
2338
2573
  this.#keys = Object.entries(filters).reduce((p, [k, v]) => {
2339
2574
  if (k.endsWith(":sort")) {
2340
2575
  const field = k.split(":")[0];
@@ -2347,11 +2582,15 @@ class LivequeryCollection {
2347
2582
  const prev = filters[":before"];
2348
2583
  const loading = next && prev ? "all" : next ? "next" : prev ? "prev" : "all";
2349
2584
  this.loading.next(loading);
2350
- await this.#core.query({
2585
+ const items = await this.#core.query({
2351
2586
  ref: this.ref,
2352
2587
  filters,
2353
2588
  collection_id: this.id
2354
2589
  });
2590
+ if (items && flush && Object.keys(filters || {}).length == 0) {
2591
+ this.#commit(items.documents.map((i) => new LivequeryDocument(this, i)));
2592
+ this.loading.next(null);
2593
+ }
2355
2594
  }
2356
2595
  async query(filters) {
2357
2596
  this.loading.next("all");
@@ -2442,6 +2681,92 @@ var tryCatch = async (fn) => {
2442
2681
  }
2443
2682
  };
2444
2683
 
2684
+ // src/helpers/whenCompleted.ts
2685
+ function whenCompleted(stream) {
2686
+ return stream.pipe(materialize(), filter((n) => n.kind === "C" || n.kind === "E"), map(() => {
2687
+ return;
2688
+ }), shareReplay(1));
2689
+ }
2690
+
2691
+ // src/helpers/filterDocs.ts
2692
+ function filterDocs(documents, filters) {
2693
+ if (!filters)
2694
+ return documents;
2695
+ const normalized = filters;
2696
+ return documents.filter((doc) => matchesAllFilters(doc, normalized));
2697
+ }
2698
+ function matchesAllFilters(doc, filters) {
2699
+ for (const [key, expected] of Object.entries(filters)) {
2700
+ if (key.startsWith(":") || key.endsWith(":sort"))
2701
+ continue;
2702
+ const split = key.split(":");
2703
+ const fieldPath = split[0];
2704
+ if (!fieldPath)
2705
+ continue;
2706
+ const op = split[1] || "eq";
2707
+ const actual = getByPath(doc, fieldPath);
2708
+ if (!matchByOperator(actual, op, expected)) {
2709
+ return false;
2710
+ }
2711
+ }
2712
+ return true;
2713
+ }
2714
+ function matchByOperator(actual, op, expected) {
2715
+ switch (op) {
2716
+ case "gt":
2717
+ return asNumber(actual) > asNumber(expected);
2718
+ case "gte":
2719
+ return asNumber(actual) >= asNumber(expected);
2720
+ case "lt":
2721
+ return asNumber(actual) < asNumber(expected);
2722
+ case "lte":
2723
+ return asNumber(actual) <= asNumber(expected);
2724
+ case "eq-number":
2725
+ return asNumber(actual) === asNumber(expected);
2726
+ case "in":
2727
+ return Array.isArray(expected) ? expected.includes(actual) : false;
2728
+ case "nin":
2729
+ return Array.isArray(expected) ? !expected.includes(actual) : true;
2730
+ case "include":
2731
+ return Array.isArray(actual) ? actual.includes(expected) : false;
2732
+ case "boolean":
2733
+ return matchBoolean(actual, expected);
2734
+ case "like":
2735
+ return String(actual || "").toLowerCase().includes(String(expected || "").toLowerCase());
2736
+ case "null":
2737
+ return expected === "null-only" ? actual === null || typeof actual === "undefined" : actual !== null && typeof actual !== "undefined";
2738
+ case "eq":
2739
+ default:
2740
+ return actual === expected;
2741
+ }
2742
+ }
2743
+ function matchBoolean(actual, expected) {
2744
+ switch (expected) {
2745
+ case "true":
2746
+ return actual === true;
2747
+ case "false":
2748
+ return actual === false;
2749
+ case "not-true":
2750
+ return actual !== true;
2751
+ case "not-false":
2752
+ return actual !== false;
2753
+ default:
2754
+ return false;
2755
+ }
2756
+ }
2757
+ function getByPath(obj, path) {
2758
+ if (!path.includes("."))
2759
+ return obj[path];
2760
+ return path.split(".").reduce((acc, key) => {
2761
+ if (!acc || typeof acc !== "object")
2762
+ return;
2763
+ return acc[key];
2764
+ }, obj);
2765
+ }
2766
+ function asNumber(value) {
2767
+ return Number(value);
2768
+ }
2769
+
2445
2770
  // src/LivequeryCore.ts
2446
2771
  class LivequeryCore {
2447
2772
  config;
@@ -2453,79 +2778,80 @@ class LivequeryCore {
2453
2778
  this.config = config3;
2454
2779
  this.#start();
2455
2780
  }
2456
- #start() {
2457
- const cache = new Map;
2458
- const changes$ = new Subject;
2459
- merge(changes$.pipe(delayWhen((change) => {
2460
- if (change.type == "modified" || change.type == "removed")
2461
- return of(1);
2462
- return this.#adding.get(change.collection_ref) || of(1);
2463
- }), tap((change) => this.#sync("realtime", change))), this.#queries$.pipe(mergeMap(async ({ collection, ref, filters, headers }) => {
2464
- if (collection.document_id) {
2465
- const doc = await this.config.storage.get(collection.collection_ref, collection.document_id);
2466
- if (doc) {
2467
- collection.o.next({
2468
- from: "query",
2469
- changes: [{
2470
- type: "added",
2471
- collection_ref: collection.collection_ref,
2472
- id: doc.id,
2473
- data: doc
2474
- }]
2475
- });
2476
- return EMPTY;
2477
- }
2781
+ #cache = new Map;
2782
+ #query(e, deduplicate_key) {
2783
+ const clear = () => deduplicate_key && this.#cache.delete(deduplicate_key);
2784
+ const cached = deduplicate_key && this.#cache.get(deduplicate_key);
2785
+ if (cached)
2786
+ return Object.assign(cached, { clear });
2787
+ const $ = from(Object.values(this.config.transporters)).pipe(mergeMap((transporter) => transporter.query(e).pipe(tap((result) => {
2788
+ for (const change of result.changes || []) {
2789
+ change.type == "added" && change.data && this.config.storage.add(change.collection_ref, {
2790
+ id: change.data.id,
2791
+ ...change.data
2792
+ });
2793
+ change.type == "modified" && change.data && this.config.storage.update(change.collection_ref, change.id, change.data);
2794
+ change.type == "removed" && this.config.storage.delete(change.collection_ref, change.id);
2478
2795
  }
2479
- return from(Object.values(this.config.transporters)).pipe(map((transporter) => {
2480
- const key = `${ref}?${new URLSearchParams(filters || {}).toString()}`;
2481
- const cached = cache.get(key);
2482
- if (cached)
2483
- return cached;
2484
- const query = transporter.query({
2485
- ref,
2486
- filters,
2487
- headers
2488
- }).pipe(tap((result) => {
2489
- for (const change of result.changes || []) {
2490
- change.type == "added" && change.data && this.config.storage.add(change.collection_ref, {
2491
- id: change.data.id,
2492
- ...change.data
2493
- });
2494
- change.type == "modified" && change.data && this.config.storage.update(change.collection_ref, change.id, change.data);
2495
- change.type == "removed" && this.config.storage.delete(change.collection_ref, change.id);
2496
- }
2497
- }), map((result, index) => {
2498
- if (index == 0) {
2499
- cache.delete(key);
2500
- return { result };
2501
- }
2502
- result.changes?.forEach((change) => changes$.next(change));
2503
- }), filter(Boolean), shareReplay());
2504
- cache.set(key, query);
2505
- return query;
2506
- }), mergeMap(($) => $), map(({ result }, index) => {
2507
- collection.o.next({
2796
+ }), map((result, index) => ({ result, index })), mergeMap(({ result, index }) => {
2797
+ if (index == 0)
2798
+ return of(result);
2799
+ const changes = result.changes || [];
2800
+ if (changes.length === 0)
2801
+ return EMPTY;
2802
+ const lock$ = this.#adding.get(e.collection.collection_ref);
2803
+ if (!lock$) {
2804
+ this.#broadcast(e.collection.collection_ref, "realtime", changes);
2805
+ return EMPTY;
2806
+ }
2807
+ const ok_changes = changes.filter((c) => c.type != "added");
2808
+ const delay_changes = changes.filter((c) => c.type == "added");
2809
+ this.#broadcast(e.collection.collection_ref, "realtime", ok_changes);
2810
+ return lock$.pipe(tap(() => this.#broadcast(e.collection.collection_ref, "realtime", delay_changes)), switchMap(() => EMPTY));
2811
+ }))), finalize(clear), shareReplay());
2812
+ deduplicate_key && this.#cache.set(deduplicate_key, $);
2813
+ return Object.assign($, { clear });
2814
+ }
2815
+ #start() {
2816
+ lastValueFrom(merge(this.#queries$.pipe(filter((req) => req.collection.mode == "server-first" || req.collection.mode == "cache-first"), mergeMap((e) => {
2817
+ const deduplicate_key = `${e.collection.collection_id}:${JSON.stringify(e.filters)}`;
2818
+ return this.#query(e, deduplicate_key).pipe(takeUntil(whenCompleted(e.collection.data$)), tap((result) => {
2819
+ e.collection.data$.next({
2508
2820
  ...result,
2509
- from: index === 0 ? "query" : "realtime"
2821
+ from: "query"
2822
+ });
2823
+ }));
2824
+ })), this.#queries$.pipe(filter((req) => req.collection.mode == "local-first"), groupBy((e) => `${e.collection.collection_ref}/${e.collection.document_id || "::"}`), mergeMap(($) => $.pipe(mergeMap((e, index) => merge(of(e), index > 0 ? EMPTY : defer(() => {
2825
+ return this.#query(e).pipe(expand((res) => {
2826
+ const next = res.paging?.next;
2827
+ if (!next)
2828
+ return EMPTY;
2829
+ return this.#query({
2830
+ ...e,
2831
+ filters: { ":after": next.cursor }
2510
2832
  });
2833
+ }), tap((result) => {
2834
+ this.#broadcast(e.collection.collection_ref, "query", result.changes || []);
2511
2835
  }));
2512
- }), mergeMap(($) => $))).subscribe();
2836
+ }).pipe(switchMap(() => EMPTY)))), scan((p, c) => new Set([...p, c.collection.data$].filter(($2) => !$2.closed)), new Set), map((set) => [...set].map(($2) => whenCompleted($2))), switchMap((list) => forkJoin(list)), takeWhile(() => false))))));
2513
2837
  }
2514
- watch(ref, collection_id) {
2838
+ watch(ref, collection_id, mode) {
2515
2839
  const refs = ref.split("/");
2516
2840
  const document_id = refs.length % 2 == 0 ? refs[refs.length - 1] : undefined;
2517
2841
  const collection_ref = refs.length % 2 == 0 ? refs.slice(0, -1).join("/") : ref;
2518
2842
  const collections = this.#refs.get(collection_ref) || new Set;
2519
2843
  collections.add(collection_id);
2520
2844
  this.#refs.set(collection_ref, collections);
2521
- const o = new Subject;
2845
+ const data$ = new Subject;
2522
2846
  this.#collections.set(collection_id, {
2523
- o,
2847
+ data$,
2524
2848
  document_id,
2525
2849
  collection_id,
2526
- collection_ref
2850
+ collection_ref,
2851
+ mode,
2852
+ filters: {}
2527
2853
  });
2528
- return o.pipe(finalize(() => {
2854
+ return data$.pipe(finalize(() => {
2529
2855
  this.#collections.delete(collection_id);
2530
2856
  collections.delete(collection_id);
2531
2857
  if (collections.size === 0) {
@@ -2535,27 +2861,70 @@ class LivequeryCore {
2535
2861
  }
2536
2862
  async query(req) {
2537
2863
  const collection = this.#collections.get(req.collection_id);
2538
- collection && setTimeout(() => this.#queries$.next({ ...req, collection }));
2539
- return [];
2864
+ if (!collection)
2865
+ throw new Error(`Collection with id ${req.collection_id} not found`);
2866
+ setTimeout(() => this.#queries$.next({
2867
+ ...req,
2868
+ filters: collection.mode == "local-first" ? {} : req.filters,
2869
+ collection
2870
+ }));
2871
+ if (collection.document_id) {
2872
+ const doc = await this.config.storage.get(collection.collection_ref, collection.document_id);
2873
+ return {
2874
+ documents: doc ? [doc] : []
2875
+ };
2876
+ }
2877
+ collection.filters = req.filters || {};
2878
+ if (collection.mode == "local-first") {
2879
+ return await this.config.storage.query(req.ref, req.filters);
2880
+ }
2881
+ if (collection.mode == "cache-first") {
2882
+ const before = req.filters?.[":before"];
2883
+ const after = req.filters?.[":after"];
2884
+ const is_first_query = !before && !after;
2885
+ if (is_first_query) {
2886
+ return await this.config.storage.query(req.ref, req.filters);
2887
+ }
2888
+ }
2540
2889
  }
2541
- #sync(source, change) {
2542
- const collections = this.#refs.get(change.collection_ref) || new Set;
2890
+ #broadcast(collection_ref, from2, events) {
2891
+ const collections = this.#refs.get(collection_ref) || new Set;
2543
2892
  for (const collection_id of collections) {
2544
- const sender = this.#collections.get(collection_id);
2545
- if (!sender)
2893
+ const collection = this.#collections.get(collection_id);
2894
+ if (!collection)
2546
2895
  continue;
2547
- if (!sender.document_id || sender.document_id === change.id) {
2548
- sender.o.next({
2896
+ if (collection.document_id) {
2897
+ const change = events.find((c) => c.id == collection.document_id);
2898
+ change && collection.data$.next({
2549
2899
  changes: [change],
2550
- from: source
2900
+ from: from2
2551
2901
  });
2552
- const new_id = change.data?.id;
2553
- if (sender.document_id && new_id) {
2554
- sender.document_id = new_id;
2555
- }
2902
+ continue;
2903
+ }
2904
+ if (collection.mode == "local-first") {
2905
+ const changes = events.filter((e) => {
2906
+ if (e.type == "added")
2907
+ return e.data && matchesAllFilters(e.data, collection.filters);
2908
+ if (e.type == "modified") {
2909
+ if (!e.data)
2910
+ return false;
2911
+ if (!matchesAllFilters(e.data, collection.filters)) {
2912
+ e.type = "removed";
2913
+ }
2914
+ }
2915
+ return true;
2916
+ });
2917
+ changes.length > 0 && collection.data$.next({
2918
+ changes,
2919
+ from: from2
2920
+ });
2921
+ continue;
2556
2922
  }
2923
+ collection.data$.next({
2924
+ changes: events,
2925
+ from: from2
2926
+ });
2557
2927
  }
2558
- return change.data;
2559
2928
  }
2560
2929
  #push(collection_ref, id, doc) {
2561
2930
  const cleanDoc = Object.entries(doc).reduce((p, [k, v]) => {
@@ -2575,12 +2944,12 @@ class LivequeryCore {
2575
2944
  ...e ? { _adding_error: e } : {}
2576
2945
  };
2577
2946
  await this.config.storage.update(collection_ref, id, fnd);
2578
- this.#sync("action", {
2947
+ this.#broadcast(collection_ref, "action", [{
2579
2948
  collection_ref,
2580
2949
  type: "modified",
2581
2950
  id,
2582
2951
  data: fnd
2583
- });
2952
+ }]);
2584
2953
  }
2585
2954
  o.next();
2586
2955
  o.complete();
@@ -2594,19 +2963,19 @@ class LivequeryCore {
2594
2963
  _deleting_error: e
2595
2964
  };
2596
2965
  await this.config.storage.update(collection_ref, id, fnd);
2597
- this.#sync("action", {
2966
+ this.#broadcast(collection_ref, "action", [{
2598
2967
  collection_ref,
2599
2968
  type: "modified",
2600
2969
  id,
2601
2970
  data: fnd
2602
- });
2971
+ }]);
2603
2972
  } else {
2604
2973
  await this.config.storage.delete(collection_ref, id);
2605
- this.#sync("action", {
2974
+ this.#broadcast(collection_ref, "action", [{
2606
2975
  collection_ref,
2607
2976
  type: "removed",
2608
2977
  id
2609
- });
2978
+ }]);
2610
2979
  }
2611
2980
  }
2612
2981
  if (doc._prev && Object.keys(doc._prev).length > 0) {
@@ -2621,24 +2990,24 @@ class LivequeryCore {
2621
2990
  _updating_error: e
2622
2991
  };
2623
2992
  await this.config.storage.update(collection_ref, id, fnd);
2624
- this.#sync("action", {
2993
+ this.#broadcast(collection_ref, "action", [{
2625
2994
  collection_ref,
2626
2995
  type: "modified",
2627
2996
  id,
2628
2997
  data: fnd
2629
- });
2998
+ }]);
2630
2999
  }
2631
3000
  return EMPTY;
2632
3001
  })), { defaultValue: undefined });
2633
3002
  }
2634
3003
  async add(collection_ref, doc) {
2635
3004
  const data = await this.config.storage.add(collection_ref, { ...doc, _adding: true });
2636
- this.#sync("action", {
3005
+ this.#broadcast(collection_ref, "action", [{
3006
+ collection_ref,
2637
3007
  id: data.id,
2638
3008
  type: "added",
2639
- data,
2640
- collection_ref
2641
- });
3009
+ data
3010
+ }]);
2642
3011
  await this.#push(collection_ref, data.id, data);
2643
3012
  return data;
2644
3013
  }
@@ -2655,7 +3024,7 @@ class LivequeryCore {
2655
3024
  };
2656
3025
  }, old._prev || {});
2657
3026
  await this.config.storage.update(collection_ref, id, { _prev, _updating: true, ...data });
2658
- const doc = await this.#sync("action", {
3027
+ const doc = await this.#broadcast(collection_ref, "action", [{
2659
3028
  collection_ref,
2660
3029
  id,
2661
3030
  type: "modified",
@@ -2664,7 +3033,7 @@ class LivequeryCore {
2664
3033
  _updating: true,
2665
3034
  ...data
2666
3035
  }
2667
- });
3036
+ }]);
2668
3037
  await this.#push(collection_ref, id, { ...data, _prev, _updating: true });
2669
3038
  return doc;
2670
3039
  }
@@ -2673,108 +3042,29 @@ class LivequeryCore {
2673
3042
  const is_local_doc = id.startsWith("local:");
2674
3043
  if (!soft || is_local_doc) {
2675
3044
  await this.config.storage.delete(collection_ref, id);
2676
- await this.#sync("action", {
3045
+ await this.#broadcast(collection_ref, "action", [{
2677
3046
  collection_ref,
2678
3047
  id,
2679
3048
  type: "removed"
2680
- });
3049
+ }]);
2681
3050
  return;
2682
3051
  }
2683
3052
  await this.config.storage.update(collection_ref, id, { _deleting: true });
2684
- const doc = await this.#sync("action", {
3053
+ const doc = await this.#broadcast(collection_ref, "action", [{
2685
3054
  collection_ref,
2686
3055
  id,
2687
3056
  type: "modified",
2688
3057
  data: {
2689
3058
  _deleting: true
2690
3059
  }
2691
- });
2692
- await this.#push(collection_ref, id, { ...doc, _deleting: true });
3060
+ }]);
3061
+ await this.#push(collection_ref, id, { _deleting: true });
2693
3062
  return doc;
2694
3063
  }
2695
3064
  trigger(action) {
2696
3065
  return from(Object.values(this.config.transporters)).pipe(mergeMap((transporter) => transporter.trigger(action)));
2697
3066
  }
2698
3067
  }
2699
- // src/helpers/filterDocs.ts
2700
- function filterDocs(documents, filters) {
2701
- if (!filters)
2702
- return documents;
2703
- const normalized = filters;
2704
- return documents.filter((doc) => matchesAllFilters(doc, normalized));
2705
- }
2706
- function matchesAllFilters(doc, filters) {
2707
- for (const [key, expected] of Object.entries(filters)) {
2708
- if (key.startsWith(":") || key.endsWith(":sort"))
2709
- continue;
2710
- const split = key.split(":");
2711
- const fieldPath = split[0];
2712
- if (!fieldPath)
2713
- continue;
2714
- const op = split[1] || "eq";
2715
- const actual = getByPath(doc, fieldPath);
2716
- if (!matchByOperator(actual, op, expected)) {
2717
- return false;
2718
- }
2719
- }
2720
- return true;
2721
- }
2722
- function matchByOperator(actual, op, expected) {
2723
- switch (op) {
2724
- case "gt":
2725
- return asNumber(actual) > asNumber(expected);
2726
- case "gte":
2727
- return asNumber(actual) >= asNumber(expected);
2728
- case "lt":
2729
- return asNumber(actual) < asNumber(expected);
2730
- case "lte":
2731
- return asNumber(actual) <= asNumber(expected);
2732
- case "eq-number":
2733
- return asNumber(actual) === asNumber(expected);
2734
- case "in":
2735
- return Array.isArray(expected) ? expected.includes(actual) : false;
2736
- case "nin":
2737
- return Array.isArray(expected) ? !expected.includes(actual) : true;
2738
- case "include":
2739
- return Array.isArray(actual) ? actual.includes(expected) : false;
2740
- case "boolean":
2741
- return matchBoolean(actual, expected);
2742
- case "like":
2743
- return String(actual || "").toLowerCase().includes(String(expected || "").toLowerCase());
2744
- case "null":
2745
- return expected === "null-only" ? actual === null || typeof actual === "undefined" : actual !== null && typeof actual !== "undefined";
2746
- case "eq":
2747
- default:
2748
- return actual === expected;
2749
- }
2750
- }
2751
- function matchBoolean(actual, expected) {
2752
- switch (expected) {
2753
- case "true":
2754
- return actual === true;
2755
- case "false":
2756
- return actual === false;
2757
- case "not-true":
2758
- return actual !== true;
2759
- case "not-false":
2760
- return actual !== false;
2761
- default:
2762
- return false;
2763
- }
2764
- }
2765
- function getByPath(obj, path) {
2766
- if (!path.includes("."))
2767
- return obj[path];
2768
- return path.split(".").reduce((acc, key) => {
2769
- if (!acc || typeof acc !== "object")
2770
- return;
2771
- return acc[key];
2772
- }, obj);
2773
- }
2774
- function asNumber(value) {
2775
- return Number(value);
2776
- }
2777
-
2778
3068
  // src/LivequeryMemoryStorage.ts
2779
3069
  class LivequeryMemoryStorage {
2780
3070
  #collections = new Map;
@@ -2871,5 +3161,5 @@ export {
2871
3161
  LivequeryCollection
2872
3162
  };
2873
3163
 
2874
- //# debugId=3704685BF951B78D64756E2164756E21
3164
+ //# debugId=067B8FB03B47D24664756E2164756E21
2875
3165
  //# sourceMappingURL=index.js.map