serializable-bptree 6.2.0 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cjs/index.cjs +8 -8
- package/dist/esm/index.mjs +8 -8
- package/dist/types/base/BPTree.d.ts +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ tree.where({ gt: 1 }) // Map([{ key: 'c', value: 3 }])
|
|
|
64
64
|
tree.where({ lt: 2 }) // Map([{ key: 'a', value: 1 }])
|
|
65
65
|
tree.where({ gt: 0, lt: 4 }) // Map([{ key: 'a', value: 1 }, { key: 'c', value: 3 }])
|
|
66
66
|
tree.where({ or: [3, 1] }) // Map([{ key: 'a', value: 1 }, { key: 'c', value: 3 }])
|
|
67
|
+
tree.where({ like: 'user_%' }) // Matches values matching the pattern
|
|
67
68
|
|
|
68
69
|
tree.clear()
|
|
69
70
|
```
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -494,20 +494,20 @@ var BPTree = class _BPTree {
|
|
|
494
494
|
primaryOr: (nv, v) => this.ensureValues(v).some((v2) => this.comparator.isPrimarySame(nv, v2)),
|
|
495
495
|
like: (nv, v) => {
|
|
496
496
|
const nodeValue = this.comparator.match(nv);
|
|
497
|
-
const value =
|
|
497
|
+
const value = v;
|
|
498
498
|
const cache = this._cachedRegexp.cache(value);
|
|
499
499
|
const regexp = cache.raw;
|
|
500
500
|
return regexp.test(nodeValue);
|
|
501
501
|
}
|
|
502
502
|
};
|
|
503
503
|
verifierStartNode = {
|
|
504
|
-
gt: (v) => this.
|
|
505
|
-
gte: (v) => this.
|
|
506
|
-
lt: (v) => this.
|
|
507
|
-
lte: (v) => this.
|
|
508
|
-
equal: (v) => this.
|
|
504
|
+
gt: (v) => this.insertableNodeByPrimary(v),
|
|
505
|
+
gte: (v) => this.insertableNodeByPrimary(v),
|
|
506
|
+
lt: (v) => this.insertableNodeByPrimary(v),
|
|
507
|
+
lte: (v) => this.insertableRightestNodeByPrimary(v),
|
|
508
|
+
equal: (v) => this.insertableNodeByPrimary(v),
|
|
509
509
|
notEqual: (v) => this.leftestNode(),
|
|
510
|
-
or: (v) => this.
|
|
510
|
+
or: (v) => this.insertableNodeByPrimary(this.lowestPrimaryValue(this.ensureValues(v))),
|
|
511
511
|
primaryGt: (v) => this.insertableNodeByPrimary(v),
|
|
512
512
|
primaryGte: (v) => this.insertableNodeByPrimary(v),
|
|
513
513
|
primaryLt: (v) => this.insertableNodeByPrimary(v),
|
|
@@ -532,7 +532,7 @@ var BPTree = class _BPTree {
|
|
|
532
532
|
primaryGte: (v) => null,
|
|
533
533
|
primaryLt: (v) => null,
|
|
534
534
|
primaryLte: (v) => null,
|
|
535
|
-
primaryEqual: (v) =>
|
|
535
|
+
primaryEqual: (v) => this.insertableRightestEndNodeByPrimary(v),
|
|
536
536
|
primaryNotEqual: (v) => null,
|
|
537
537
|
primaryOr: (v) => this.insertableRightestEndNodeByPrimary(
|
|
538
538
|
this.highestPrimaryValue(this.ensureValues(v))
|
package/dist/esm/index.mjs
CHANGED
|
@@ -460,20 +460,20 @@ var BPTree = class _BPTree {
|
|
|
460
460
|
primaryOr: (nv, v) => this.ensureValues(v).some((v2) => this.comparator.isPrimarySame(nv, v2)),
|
|
461
461
|
like: (nv, v) => {
|
|
462
462
|
const nodeValue = this.comparator.match(nv);
|
|
463
|
-
const value =
|
|
463
|
+
const value = v;
|
|
464
464
|
const cache = this._cachedRegexp.cache(value);
|
|
465
465
|
const regexp = cache.raw;
|
|
466
466
|
return regexp.test(nodeValue);
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
469
|
verifierStartNode = {
|
|
470
|
-
gt: (v) => this.
|
|
471
|
-
gte: (v) => this.
|
|
472
|
-
lt: (v) => this.
|
|
473
|
-
lte: (v) => this.
|
|
474
|
-
equal: (v) => this.
|
|
470
|
+
gt: (v) => this.insertableNodeByPrimary(v),
|
|
471
|
+
gte: (v) => this.insertableNodeByPrimary(v),
|
|
472
|
+
lt: (v) => this.insertableNodeByPrimary(v),
|
|
473
|
+
lte: (v) => this.insertableRightestNodeByPrimary(v),
|
|
474
|
+
equal: (v) => this.insertableNodeByPrimary(v),
|
|
475
475
|
notEqual: (v) => this.leftestNode(),
|
|
476
|
-
or: (v) => this.
|
|
476
|
+
or: (v) => this.insertableNodeByPrimary(this.lowestPrimaryValue(this.ensureValues(v))),
|
|
477
477
|
primaryGt: (v) => this.insertableNodeByPrimary(v),
|
|
478
478
|
primaryGte: (v) => this.insertableNodeByPrimary(v),
|
|
479
479
|
primaryLt: (v) => this.insertableNodeByPrimary(v),
|
|
@@ -498,7 +498,7 @@ var BPTree = class _BPTree {
|
|
|
498
498
|
primaryGte: (v) => null,
|
|
499
499
|
primaryLt: (v) => null,
|
|
500
500
|
primaryLte: (v) => null,
|
|
501
|
-
primaryEqual: (v) =>
|
|
501
|
+
primaryEqual: (v) => this.insertableRightestEndNodeByPrimary(v),
|
|
502
502
|
primaryNotEqual: (v) => null,
|
|
503
503
|
primaryOr: (v) => this.insertableRightestEndNodeByPrimary(
|
|
504
504
|
this.highestPrimaryValue(this.ensureValues(v))
|
|
@@ -21,7 +21,6 @@ export type BPTreeCondition<V> = Partial<{
|
|
|
21
21
|
/** Searches for pairs that satisfy at least one of the conditions. */
|
|
22
22
|
or: Partial<V>[];
|
|
23
23
|
/** Searches for values matching the given pattern. '%' matches zero or more characters, and '_' matches exactly one character. */
|
|
24
|
-
like: Partial<V>;
|
|
25
24
|
/**
|
|
26
25
|
* Searches for pairs where the primary field equals the given value.
|
|
27
26
|
* Uses `primaryAsc` method for comparison, which compares only the primary sorting field.
|
|
@@ -40,6 +39,12 @@ export type BPTreeCondition<V> = Partial<{
|
|
|
40
39
|
primaryNotEqual: Partial<V>;
|
|
41
40
|
/** Searches for pairs where the primary field matches at least one of the given values. */
|
|
42
41
|
primaryOr: Partial<V>[];
|
|
42
|
+
/**
|
|
43
|
+
* Searches for values matching the given pattern on the primary field.
|
|
44
|
+
* Uses `match` method for getting string representation.
|
|
45
|
+
* '%' matches zero or more characters, and '_' matches exactly one character.
|
|
46
|
+
*/
|
|
47
|
+
like: string;
|
|
43
48
|
}>;
|
|
44
49
|
export type BPTreePair<K, V> = Map<K, V>;
|
|
45
50
|
export type BPTreeUnknownNode<K, V> = BPTreeInternalNode<K, V> | BPTreeLeafNode<K, V>;
|