@peerbit/indexer-tests 3.0.4 → 3.0.6
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/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/tests.d.ts.map +1 -1
- package/dist/src/tests.js +207 -62
- package/dist/src/tests.js.map +1 -1
- package/dist/src/tie-parity.d.ts +3 -0
- package/dist/src/tie-parity.d.ts.map +1 -0
- package/dist/src/tie-parity.js +214 -0
- package/dist/src/tie-parity.js.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/tests.ts +267 -68
- package/src/tie-parity.ts +138 -0
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/src/tests.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../src/tests.ts"],"names":[],"mappings":"AAUA,OAAO,EAQN,KAAK,OAAO,EAiBZ,MAAM,4BAA4B,CAAC;AAgHpC,eAAO,MAAM,KAAK,GACjB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAClE,MAAM,WAAW,GAAG,SAAuB,EAC3C,YAAY;IACX,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC1B,
|
|
1
|
+
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../src/tests.ts"],"names":[],"mappings":"AAUA,OAAO,EAQN,KAAK,OAAO,EAiBZ,MAAM,4BAA4B,CAAC;AAgHpC,eAAO,MAAM,KAAK,GACjB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAClE,MAAM,WAAW,GAAG,SAAuB,EAC3C,YAAY;IACX,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC1B,gBA8jJD,CAAC"}
|
package/dist/src/tests.js
CHANGED
|
@@ -912,37 +912,6 @@ export const tests = (createIndicies, type = "transient", properties) => {
|
|
|
912
912
|
expect(responses).to.be.empty;
|
|
913
913
|
});
|
|
914
914
|
});
|
|
915
|
-
describe("integer", () => {
|
|
916
|
-
it("exists", async () => {
|
|
917
|
-
await setupDefault();
|
|
918
|
-
const responses = await search(store, {
|
|
919
|
-
query: [
|
|
920
|
-
new IntegerCompare({
|
|
921
|
-
key: "data",
|
|
922
|
-
compare: Compare.Equal,
|
|
923
|
-
value: 1,
|
|
924
|
-
}),
|
|
925
|
-
],
|
|
926
|
-
});
|
|
927
|
-
expect(responses).to.have.length(1);
|
|
928
|
-
expect(responses.map((x) => x.id.primitive)).to.deep.equal([
|
|
929
|
-
"1",
|
|
930
|
-
]);
|
|
931
|
-
});
|
|
932
|
-
it("does not exist", async () => {
|
|
933
|
-
await setupDefault();
|
|
934
|
-
const responses = await search(store, {
|
|
935
|
-
query: [
|
|
936
|
-
new IntegerCompare({
|
|
937
|
-
key: "data",
|
|
938
|
-
compare: Compare.Equal,
|
|
939
|
-
value: 199,
|
|
940
|
-
}),
|
|
941
|
-
],
|
|
942
|
-
});
|
|
943
|
-
expect(responses).to.be.empty;
|
|
944
|
-
});
|
|
945
|
-
});
|
|
946
915
|
});
|
|
947
916
|
describe("fixed", () => {
|
|
948
917
|
describe("bytematch", () => {
|
|
@@ -974,37 +943,6 @@ export const tests = (createIndicies, type = "transient", properties) => {
|
|
|
974
943
|
expect(responses).to.be.empty;
|
|
975
944
|
});
|
|
976
945
|
});
|
|
977
|
-
describe("integer", () => {
|
|
978
|
-
it("exists", async () => {
|
|
979
|
-
await setupDefault();
|
|
980
|
-
const responses = await search(store, {
|
|
981
|
-
query: [
|
|
982
|
-
new IntegerCompare({
|
|
983
|
-
key: "data",
|
|
984
|
-
compare: Compare.Equal,
|
|
985
|
-
value: 1,
|
|
986
|
-
}),
|
|
987
|
-
],
|
|
988
|
-
});
|
|
989
|
-
expect(responses).to.have.length(1);
|
|
990
|
-
expect(responses.map((x) => x.id.primitive)).to.deep.equal([
|
|
991
|
-
"1",
|
|
992
|
-
]);
|
|
993
|
-
});
|
|
994
|
-
it("does not exist", async () => {
|
|
995
|
-
await setupDefault();
|
|
996
|
-
const responses = await search(store, {
|
|
997
|
-
query: [
|
|
998
|
-
new IntegerCompare({
|
|
999
|
-
key: "data",
|
|
1000
|
-
compare: Compare.Equal,
|
|
1001
|
-
value: 199,
|
|
1002
|
-
}),
|
|
1003
|
-
],
|
|
1004
|
-
});
|
|
1005
|
-
expect(responses).to.be.empty;
|
|
1006
|
-
});
|
|
1007
|
-
});
|
|
1008
946
|
});
|
|
1009
947
|
});
|
|
1010
948
|
it("bool", async () => {
|
|
@@ -4757,6 +4695,213 @@ export const tests = (createIndicies, type = "transient", properties) => {
|
|
|
4757
4695
|
}
|
|
4758
4696
|
expect(await iterator.pending()).to.eq(0);
|
|
4759
4697
|
});
|
|
4698
|
+
it("all after partial next returns only remaining sorted results", async () => {
|
|
4699
|
+
await put(0);
|
|
4700
|
+
await put(1);
|
|
4701
|
+
await put(2);
|
|
4702
|
+
const iterator = store.iterate({
|
|
4703
|
+
query: [],
|
|
4704
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4705
|
+
});
|
|
4706
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["0"]);
|
|
4707
|
+
expect((await iterator.all()).map((x) => x.value.name)).to.deep.equal([
|
|
4708
|
+
"1",
|
|
4709
|
+
"2",
|
|
4710
|
+
]);
|
|
4711
|
+
expect(iterator.done()).to.be.true;
|
|
4712
|
+
});
|
|
4713
|
+
it("deleting an already yielded sorted result does not skip the next result", async () => {
|
|
4714
|
+
await put(0);
|
|
4715
|
+
await put(1);
|
|
4716
|
+
await put(2);
|
|
4717
|
+
const iterator = store.iterate({
|
|
4718
|
+
query: [],
|
|
4719
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4720
|
+
});
|
|
4721
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["0"]);
|
|
4722
|
+
await store.del({
|
|
4723
|
+
query: new StringMatch({
|
|
4724
|
+
key: "id",
|
|
4725
|
+
value: "0",
|
|
4726
|
+
method: StringMatchMethod.exact,
|
|
4727
|
+
caseInsensitive: false,
|
|
4728
|
+
}),
|
|
4729
|
+
});
|
|
4730
|
+
expect((await iterator.next(2)).map((x) => x.value.name)).to.deep.equal(["1", "2"]);
|
|
4731
|
+
expect(iterator.done()).to.be.true;
|
|
4732
|
+
});
|
|
4733
|
+
it("inserting before an already yielded sorted result does not duplicate it", async () => {
|
|
4734
|
+
await put(1);
|
|
4735
|
+
await put(2);
|
|
4736
|
+
const iterator = store.iterate({
|
|
4737
|
+
query: [],
|
|
4738
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4739
|
+
});
|
|
4740
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["1"]);
|
|
4741
|
+
await put(0);
|
|
4742
|
+
const rest = (await iterator.next(3)).map((x) => x.value.name);
|
|
4743
|
+
expect(new Set(rest).size).to.equal(rest.length);
|
|
4744
|
+
expect(rest).to.not.include("1");
|
|
4745
|
+
expect(rest).to.include("2");
|
|
4746
|
+
});
|
|
4747
|
+
it("keeps a mutated iterator open while unseen sorted results remain", async () => {
|
|
4748
|
+
await put(0);
|
|
4749
|
+
await put(2);
|
|
4750
|
+
const iterator = store.iterate({
|
|
4751
|
+
query: [],
|
|
4752
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4753
|
+
});
|
|
4754
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["0"]);
|
|
4755
|
+
await put(1);
|
|
4756
|
+
if (properties.iteratorsMutable) {
|
|
4757
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["1"]);
|
|
4758
|
+
expect(iterator.done()).to.be.false;
|
|
4759
|
+
expect(await iterator.pending()).to.equal(1);
|
|
4760
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["2"]);
|
|
4761
|
+
}
|
|
4762
|
+
else {
|
|
4763
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["2"]);
|
|
4764
|
+
}
|
|
4765
|
+
expect(iterator.done()).to.be.true;
|
|
4766
|
+
});
|
|
4767
|
+
it("next Infinity sees inserts after an initially empty page", async () => {
|
|
4768
|
+
const iterator = store.iterate({
|
|
4769
|
+
query: [],
|
|
4770
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4771
|
+
});
|
|
4772
|
+
expect(await iterator.next(1)).to.deep.equal([]);
|
|
4773
|
+
await put(0);
|
|
4774
|
+
const rest = (await iterator.next(Infinity)).map((x) => x.value.name);
|
|
4775
|
+
expect(rest).to.deep.equal(properties.iteratorsMutable ? ["0"] : []);
|
|
4776
|
+
});
|
|
4777
|
+
it("keeps an explicitly closed iterator terminal across mutations", async () => {
|
|
4778
|
+
await put(0);
|
|
4779
|
+
const iterator = store.iterate({
|
|
4780
|
+
query: [],
|
|
4781
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4782
|
+
});
|
|
4783
|
+
await iterator.close();
|
|
4784
|
+
await put(1);
|
|
4785
|
+
expect(await iterator.next(1)).to.deep.equal([]);
|
|
4786
|
+
expect(await iterator.all()).to.deep.equal([]);
|
|
4787
|
+
expect(await iterator.pending()).to.equal(0);
|
|
4788
|
+
expect(iterator.done()).to.be.true;
|
|
4789
|
+
});
|
|
4790
|
+
it("can continue a mutable iterator after all and a later insert", async () => {
|
|
4791
|
+
await put(0);
|
|
4792
|
+
const iterator = store.iterate({
|
|
4793
|
+
query: [],
|
|
4794
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4795
|
+
});
|
|
4796
|
+
expect((await iterator.all()).map((x) => x.value.name)).to.deep.equal([
|
|
4797
|
+
"0",
|
|
4798
|
+
]);
|
|
4799
|
+
await put(1);
|
|
4800
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(properties.iteratorsMutable ? ["1"] : []);
|
|
4801
|
+
});
|
|
4802
|
+
it("refreshes pending after an exhausted mutable iterator mutates", async () => {
|
|
4803
|
+
const iterator = store.iterate({
|
|
4804
|
+
query: [],
|
|
4805
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4806
|
+
});
|
|
4807
|
+
expect(await iterator.next(1)).to.deep.equal([]);
|
|
4808
|
+
await put(0);
|
|
4809
|
+
expect(await iterator.pending()).to.equal(properties.iteratorsMutable ? 1 : 0);
|
|
4810
|
+
if (properties.iteratorsMutable) {
|
|
4811
|
+
expect(iterator.done()).to.be.false;
|
|
4812
|
+
expect((await iterator.next(1)).map((x) => x.value.name)).to.deep.equal(["0"]);
|
|
4813
|
+
}
|
|
4814
|
+
});
|
|
4815
|
+
it("can mark live results delivered outside the iterator as yielded", async () => {
|
|
4816
|
+
if (!properties.iteratorsMutable) {
|
|
4817
|
+
return;
|
|
4818
|
+
}
|
|
4819
|
+
await put(0);
|
|
4820
|
+
await put(1);
|
|
4821
|
+
const iterator = store.iterate({
|
|
4822
|
+
query: [],
|
|
4823
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
4824
|
+
});
|
|
4825
|
+
expect((await iterator.next(1)).map((x) => x.value.id)).to.deep.equal([
|
|
4826
|
+
"0",
|
|
4827
|
+
]);
|
|
4828
|
+
await put(2);
|
|
4829
|
+
expect(iterator.markYielded).to.be.a("function");
|
|
4830
|
+
await iterator.markYielded([toId("2")]);
|
|
4831
|
+
expect(await iterator.pending()).to.equal(1);
|
|
4832
|
+
expect((await iterator.next(2)).map((x) => x.value.id)).to.deep.equal([
|
|
4833
|
+
"1",
|
|
4834
|
+
]);
|
|
4835
|
+
expect(await iterator.pending()).to.equal(0);
|
|
4836
|
+
expect(iterator.done()).to.be.true;
|
|
4837
|
+
});
|
|
4838
|
+
it("tracks filtered updates without duplicates", async () => {
|
|
4839
|
+
if (!properties.iteratorsMutable) {
|
|
4840
|
+
return;
|
|
4841
|
+
}
|
|
4842
|
+
await put(0, { name: "match" });
|
|
4843
|
+
await put(1, { name: "miss" });
|
|
4844
|
+
await put(2, { name: "match" });
|
|
4845
|
+
const iterator = store.iterate({
|
|
4846
|
+
query: new StringMatch({
|
|
4847
|
+
key: "name",
|
|
4848
|
+
value: "match",
|
|
4849
|
+
method: StringMatchMethod.exact,
|
|
4850
|
+
caseInsensitive: false,
|
|
4851
|
+
}),
|
|
4852
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "number" })],
|
|
4853
|
+
});
|
|
4854
|
+
expect((await iterator.next(1)).map((x) => x.value.id)).to.deep.equal([
|
|
4855
|
+
"0",
|
|
4856
|
+
]);
|
|
4857
|
+
await put(1, { name: "match" });
|
|
4858
|
+
await put(2, { name: "miss" });
|
|
4859
|
+
await put(0, { name: "match" });
|
|
4860
|
+
await put(3, { name: "match" });
|
|
4861
|
+
expect((await iterator.all()).map((x) => x.value.id)).to.deep.equal([
|
|
4862
|
+
"1",
|
|
4863
|
+
"3",
|
|
4864
|
+
]);
|
|
4865
|
+
});
|
|
4866
|
+
it("rescans beyond 128 yielded rows after a mutation", async () => {
|
|
4867
|
+
if (!properties.iteratorsMutable) {
|
|
4868
|
+
return;
|
|
4869
|
+
}
|
|
4870
|
+
for (let i = 0; i < 140; i++) {
|
|
4871
|
+
await put(i);
|
|
4872
|
+
}
|
|
4873
|
+
const iterator = store.iterate({
|
|
4874
|
+
query: [],
|
|
4875
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "number" })],
|
|
4876
|
+
});
|
|
4877
|
+
expect(await iterator.next(130)).to.have.length(130);
|
|
4878
|
+
await store.del({
|
|
4879
|
+
query: new StringMatch({
|
|
4880
|
+
key: "id",
|
|
4881
|
+
value: "0",
|
|
4882
|
+
method: StringMatchMethod.exact,
|
|
4883
|
+
caseInsensitive: false,
|
|
4884
|
+
}),
|
|
4885
|
+
});
|
|
4886
|
+
await put(200);
|
|
4887
|
+
expect((await iterator.next(1)).map((x) => x.value.id)).to.deep.equal([
|
|
4888
|
+
"130",
|
|
4889
|
+
]);
|
|
4890
|
+
const remaining = (await iterator.all()).map((x) => x.value.id);
|
|
4891
|
+
expect(remaining).to.deep.equal([
|
|
4892
|
+
"131",
|
|
4893
|
+
"132",
|
|
4894
|
+
"133",
|
|
4895
|
+
"134",
|
|
4896
|
+
"135",
|
|
4897
|
+
"136",
|
|
4898
|
+
"137",
|
|
4899
|
+
"138",
|
|
4900
|
+
"139",
|
|
4901
|
+
"200",
|
|
4902
|
+
]);
|
|
4903
|
+
expect(new Set(remaining).size).to.equal(remaining.length);
|
|
4904
|
+
});
|
|
4760
4905
|
describe("close", () => {
|
|
4761
4906
|
it("by invoking close()", async () => {
|
|
4762
4907
|
await put(0);
|