@internetarchive/collection-name-cache
Advanced tools
Comparing version 0.0.1-alpha.2 to 0.0.1-alpha.3
@@ -12,3 +12,3 @@ /* eslint-disable camelcase */ | ||
this.defaultLoadInterval = 250; // ms | ||
this.pendingIdentifierQueue = []; | ||
this.pendingIdentifierQueue = new Set(); | ||
this.pendingPromises = {}; | ||
@@ -42,3 +42,3 @@ this.collectionNameCache = {}; | ||
var _a; | ||
this.pendingIdentifierQueue.push(lowercaseIdentifier); | ||
this.pendingIdentifierQueue.add(lowercaseIdentifier); | ||
const currentPromises = (_a = this.pendingPromises[lowercaseIdentifier]) !== null && _a !== void 0 ? _a : []; | ||
@@ -60,3 +60,3 @@ const resultHandler = async (name) => { | ||
continue; | ||
this.pendingIdentifierQueue.push(identifier); | ||
this.pendingIdentifierQueue.add(identifier); | ||
} | ||
@@ -77,3 +77,3 @@ await this.loadPendingIdentifiers(); | ||
await this.loadFromCache(); | ||
const pendingIdentifiers = this.pendingIdentifierQueue.splice(0, 100); | ||
const pendingIdentifiers = Array.from(this.pendingIdentifierQueue).splice(0, 100); | ||
if (pendingIdentifiers.length === 0) | ||
@@ -102,2 +102,3 @@ return; | ||
}; | ||
this.pendingIdentifierQueue.delete(lowercaseIdentifier); | ||
const currentPromises = this.pendingPromises[lowercaseIdentifier]; | ||
@@ -104,0 +105,0 @@ if (currentPromises) { |
@@ -10,3 +10,3 @@ { | ||
"author": "Internet Archive", | ||
"version": "0.0.1-alpha.2", | ||
"version": "0.0.1-alpha.3", | ||
"main": "dist/index.js", | ||
@@ -13,0 +13,0 @@ "module": "dist/index.js", |
@@ -65,3 +65,3 @@ /* eslint-disable camelcase */ | ||
return new Promise(resolve => { | ||
this.pendingIdentifierQueue.push(lowercaseIdentifier); | ||
this.pendingIdentifierQueue.add(lowercaseIdentifier); | ||
const currentPromises = this.pendingPromises[lowercaseIdentifier] ?? []; | ||
@@ -86,3 +86,3 @@ const resultHandler: CollectionNameResolver = async ( | ||
if (this.collectionNameCache[identifier]) continue; | ||
this.pendingIdentifierQueue.push(identifier); | ||
this.pendingIdentifierQueue.add(identifier); | ||
} | ||
@@ -92,3 +92,3 @@ await this.loadPendingIdentifiers(); | ||
private pendingIdentifierQueue: string[] = []; | ||
private pendingIdentifierQueue: Set<string> = new Set<string>(); | ||
@@ -141,3 +141,6 @@ private pendingPromises: { [identifier: string]: CollectionNameResolver[] } = | ||
await this.loadFromCache(); | ||
const pendingIdentifiers = this.pendingIdentifierQueue.splice(0, 100); | ||
const pendingIdentifiers = Array.from(this.pendingIdentifierQueue).splice( | ||
0, | ||
100 | ||
); | ||
if (pendingIdentifiers.length === 0) return; | ||
@@ -170,2 +173,3 @@ | ||
}; | ||
this.pendingIdentifierQueue.delete(lowercaseIdentifier); | ||
const currentPromises = this.pendingPromises[lowercaseIdentifier]; | ||
@@ -172,0 +176,0 @@ if (currentPromises) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124993
1231