@eclesia/indexer-engine 2.5.14 → 2.5.15

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.
@@ -16,6 +16,7 @@ export declare class PromiseQueue<T> {
16
16
  }
17
17
  export declare class CircularBuffer<T> {
18
18
  private items;
19
+ private enqueuer;
19
20
  private count;
20
21
  private next;
21
22
  private batcher;
@@ -25,7 +26,7 @@ export declare class CircularBuffer<T> {
25
26
  private nextAvail;
26
27
  constructor(batchSize: number);
27
28
  enqueue(item: T | PromiseLike<T>): void;
28
- dequeue(): T | PromiseLike<T>;
29
+ dequeue(): Promise<T>;
29
30
  clear(): void;
30
31
  continue(): Promise<boolean>;
31
32
  setSynced(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/promise-queue/index.ts"],"names":[],"mappings":"AAOA,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,KAAK,CAAoB;IAEjC,OAAO,CAAC,QAAQ,CAAqC;IAErD,OAAO,CAAC,OAAO,CAA0B;IAElC,MAAM,UAAS;IAEtB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,eAAe,CAAmB;gBAE9B,SAAS,EAAE,MAAM;IAY7B,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAiBhC,KAAK;IAWL,OAAO,IAMU,OAAO,CAAC,CAAC,CAAC;IAG3B,QAAQ;IAIR,SAAS;IAIT,OAAO;IAQP,IAAI;CAGL;AAED,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,CAA4B;IAEzC,OAAO,CAAC,KAAK,CAAa;IAE1B,OAAO,CAAC,IAAI,CAAa;IAEzB,OAAO,CAAC,OAAO,CAA0B;IAElC,MAAM,UAAS;IAEtB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,eAAe,CAAmB;IAE1C,OAAO,CAAC,SAAS,CAAa;gBAElB,SAAS,EAAE,MAAM;IAY7B,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAmBhC,OAAO;IAaP,KAAK;IAWL,QAAQ;IAIR,SAAS;IAIT,OAAO;IAQP,IAAI;CAGL"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/promise-queue/index.ts"],"names":[],"mappings":"AAOA,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,KAAK,CAAoB;IAEjC,OAAO,CAAC,QAAQ,CAAqC;IAErD,OAAO,CAAC,OAAO,CAA0B;IAElC,MAAM,UAAS;IAEtB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,eAAe,CAAmB;gBAE9B,SAAS,EAAE,MAAM;IAY7B,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAiBhC,KAAK;IAWL,OAAO,IAMU,OAAO,CAAC,CAAC,CAAC;IAG3B,QAAQ;IAIR,SAAS;IAIT,OAAO;IAQP,IAAI;CAGL;AAED,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAoB;IAEjC,OAAO,CAAC,QAAQ,CAAqC;IAErD,OAAO,CAAC,KAAK,CAAa;IAE1B,OAAO,CAAC,IAAI,CAAa;IAEzB,OAAO,CAAC,OAAO,CAA0B;IAElC,MAAM,UAAS;IAEtB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,eAAe,CAAmB;IAE1C,OAAO,CAAC,SAAS,CAAa;gBAElB,SAAS,EAAE,MAAM;IAsB7B,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAuBhC,OAAO;IAaP,KAAK;IAoBL,QAAQ;IAIR,SAAS;IAIT,OAAO;IAQP,IAAI;CAGL"}
@@ -82,8 +82,17 @@ class CircularBuffer {
82
82
  if (batchSize <= 1) {
83
83
  throw new Error("Batch size must be greater than 1");
84
84
  }
85
+ const nextVal = new Promise((resolve, _reject) => {
86
+ this.enqueuer = resolve;
87
+ });
85
88
  this.items = new Array(batchSize);
86
89
  this.batchSize = batchSize;
90
+ this.items[this.nextAvail] = nextVal;
91
+ this.count = 1;
92
+ this.nextAvail++;
93
+ if (this.nextAvail >= this.batchSize) {
94
+ this.nextAvail = 0;
95
+ }
87
96
  this.continuePromise = new Promise((resolve, _reject) => {
88
97
  this.batcher = resolve;
89
98
  });
@@ -91,7 +100,11 @@ class CircularBuffer {
91
100
  }
92
101
  enqueue(item) {
93
102
  try {
94
- this.items[this.nextAvail] = item;
103
+ this.enqueuer(item);
104
+ const nextVal = new Promise((resolve, _reject) => {
105
+ this.enqueuer = resolve;
106
+ });
107
+ this.items[this.nextAvail] = nextVal;
95
108
  this.count++;
96
109
  this.nextAvail++;
97
110
  if (this.nextAvail >= this.batchSize) {
@@ -122,12 +135,20 @@ class CircularBuffer {
122
135
  clear() {
123
136
  this.next = 0;
124
137
  this.nextAvail = 0;
125
- this.count = 0;
138
+ const nextVal = new Promise((resolve, _reject) => {
139
+ this.enqueuer = resolve;
140
+ });
141
+ this.items = new Array(this.batchSize);
142
+ this.items[this.nextAvail] = nextVal;
143
+ this.count = 1;
144
+ this.nextAvail++;
145
+ if (this.nextAvail >= this.batchSize) {
146
+ this.nextAvail = 0;
147
+ }
126
148
  this.continuePromise = new Promise((resolve, _reject) => {
127
149
  this.batcher = resolve;
128
150
  });
129
151
  this.batcher(true);
130
- this.items = new Array(this.batchSize);
131
152
  }
132
153
  continue() {
133
154
  return this.continuePromise;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclesia/indexer-engine",
3
- "version": "2.5.14",
3
+ "version": "2.5.15",
4
4
  "description": "Core eclesia indexer engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",