core-3nweb-client-lib 0.50.5 → 0.50.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.
@@ -169,16 +169,19 @@ async function fileTSsOfDBShards(dbsFS) {
169
169
  if (!isFile || !name.endsWith(DB_EXT)) {
170
170
  continue;
171
171
  }
172
- const numStr = name.substring(0, DB_EXT.length);
172
+ const numStr = name.substring(0, name.length - DB_EXT.length);
173
173
  const fileTS = parseInt(numStr);
174
174
  if (isNaN(fileTS)) {
175
175
  continue;
176
176
  }
177
177
  fileTSs.push(fileTS);
178
178
  }
179
- fileTSs.sort();
179
+ fileTSs.sort(compareNumbers);
180
180
  return fileTSs;
181
181
  }
182
+ function compareNumbers(a, b) {
183
+ return a - b;
184
+ }
182
185
  const DB_EXT = '.sqlite';
183
186
  const LATEST_DB = `latest${DB_EXT}`;
184
187
  const MSG_INDEX_DB_ATTR = `msg-index-db`;
@@ -267,7 +270,7 @@ async function makeSqliteDBs(dbsFS) {
267
270
  }
268
271
  async function* iterateDBsFromLatestToOldest() {
269
272
  yield { db: latest };
270
- for (let i = (fileTSs.length - 1); i >= 0; i = -1) {
273
+ for (let i = (fileTSs.length - 1); i >= 0; i -= 1) {
271
274
  const fileTS = fileTSs[i];
272
275
  if (!fileTS) {
273
276
  continue;
@@ -365,7 +368,7 @@ async function makeSqliteDBs(dbsFS) {
365
368
  if (!shardTS) {
366
369
  return;
367
370
  }
368
- for (let i = fileTSs.length; i >= 0; i - 1) {
371
+ for (let i = fileTSs.length; i >= 0; i -= 1) {
369
372
  const ts = fileTSs[i];
370
373
  if (ts < shardTS) {
371
374
  fileTSs.slice(i + 1, shardTS);
@@ -160,9 +160,12 @@ function addArchived(versions, version) {
160
160
  return false;
161
161
  }
162
162
  versions.archived.push(version);
163
- versions.archived.sort();
163
+ versions.archived.sort(compareNumbers);
164
164
  return true;
165
165
  }
166
+ function compareNumbers(a, b) {
167
+ return a - b;
168
+ }
166
169
  function isEmptyVersions(versions) {
167
170
  if (versions.current) {
168
171
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.50.5",
3
+ "version": "0.50.6",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",