@internetarchive/collection-name-cache
Advanced tools
Comparing version 0.2.7-alpha.2 to 0.2.7-alpha.3
@@ -23,7 +23,8 @@ import type { SearchServiceInterface } from '@internetarchive/search-service'; | ||
/** | ||
* Adds known identifier-title mappings to the cache. | ||
* Adds a set of known identifier-title mappings to the cache, | ||
* without sending a request for them. | ||
* | ||
* @param identifierTitleMap | ||
*/ | ||
addKnownTitles(identifierTitleMap: Record<string, string>): void; | ||
addKnownTitles(identifierTitleMap: Record<string, string>): Promise<void>; | ||
} | ||
@@ -43,3 +44,3 @@ export declare class CollectionNameCache implements CollectionNameCacheInterface { | ||
/** @inheritdoc */ | ||
addKnownTitles(identifierTitleMap: Record<string, string>): void; | ||
addKnownTitles(identifierTitleMap: Record<string, string>): Promise<void>; | ||
private pendingIdentifierQueue; | ||
@@ -46,0 +47,0 @@ private pendingPromises; |
@@ -67,3 +67,5 @@ export class CollectionNameCache { | ||
/** @inheritdoc */ | ||
addKnownTitles(identifierTitleMap) { | ||
async addKnownTitles(identifierTitleMap) { | ||
if (!this.cacheLoaded) | ||
await this.loadFromCache(); | ||
Object.entries(identifierTitleMap).forEach(([identifier, title]) => { | ||
@@ -76,2 +78,3 @@ const lowercaseIdentifier = identifier.toLowerCase(); | ||
}); | ||
await this.persistCache(); | ||
} | ||
@@ -78,0 +81,0 @@ async startPendingIdentifierTimer() { |
@@ -10,3 +10,3 @@ { | ||
"author": "Internet Archive", | ||
"version": "0.2.7-alpha.2", | ||
"version": "0.2.7-alpha.3", | ||
"main": "dist/index.js", | ||
@@ -13,0 +13,0 @@ "module": "dist/index.js", |
@@ -28,7 +28,8 @@ /* eslint-disable camelcase */ | ||
/** | ||
* Adds known identifier-title mappings to the cache. | ||
* Adds a set of known identifier-title mappings to the cache, | ||
* without sending a request for them. | ||
* | ||
* @param identifierTitleMap | ||
*/ | ||
addKnownTitles(identifierTitleMap: Record<string, string>): void; | ||
addKnownTitles(identifierTitleMap: Record<string, string>): Promise<void>; | ||
} | ||
@@ -104,3 +105,4 @@ | ||
/** @inheritdoc */ | ||
addKnownTitles(identifierTitleMap: Record<string, string>): void { | ||
async addKnownTitles(identifierTitleMap: Record<string, string>): Promise<void> { | ||
if (!this.cacheLoaded) await this.loadFromCache(); | ||
Object.entries(identifierTitleMap).forEach(([identifier, title]) => { | ||
@@ -113,2 +115,4 @@ const lowercaseIdentifier = identifier.toLowerCase(); | ||
}); | ||
await this.persistCache(); | ||
} | ||
@@ -115,0 +119,0 @@ |
Sorry, the diff of this file is not supported yet
155496
1584