New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@internetarchive/collection-name-cache

Package Overview
Dependencies
Maintainers
17
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internetarchive/collection-name-cache - npm Package Compare versions

Comparing version 0.2.7-alpha.3 to 0.2.7

0

demo/app-root.ts

@@ -0,0 +0,0 @@ import { SearchService } from '@internetarchive/search-service';

@@ -0,0 +0,0 @@ import { __decorate } from "tslib";

24

dist/test/collection-name-cache.test.js

@@ -267,3 +267,27 @@ import { expect } from '@open-wc/testing';

});
it('adds known titles to the cache', async () => {
const mockSearchService = new MockSearchService();
mockSearchService.searchResult = mockSearchResponse;
const collectionNameCache = new CollectionNameCache({
searchService: mockSearchService,
loadDelay: 25,
});
// fill the cache with some already-known collection titles
await collectionNameCache.addKnownTitles({
'foo-collection': 'Foo Collection',
'bar-collection': 'Bar Collection',
'baz-collection': 'Baz Collection',
});
// should immediately have them available in the cache
expect(await collectionNameCache.collectionNameFor('foo-collection')).to.equal('Foo Collection');
expect(await collectionNameCache.collectionNameFor('bar-collection')).to.equal('Bar Collection');
expect(await collectionNameCache.collectionNameFor('baz-collection')).to.equal('Baz Collection');
await promisedSleep(50);
// should not have tried to fetch any titles
expect(mockSearchService.searchCallCount).to.equal(0);
await collectionNameCache.preloadIdentifiers(['foo-collection']);
// again, no fetch call should be made, since we already have it cached
expect(mockSearchService.searchCallCount).to.equal(0);
});
});
//# sourceMappingURL=collection-name-cache.test.js.map

4

package.json

@@ -10,3 +10,3 @@ {

"author": "Internet Archive",
"version": "0.2.7-alpha.3",
"version": "0.2.7",
"main": "dist/index.js",

@@ -27,3 +27,3 @@ "module": "dist/index.js",

"@internetarchive/local-cache": "^0.2.1",
"@internetarchive/search-service": "^0.4.7-alpha.1",
"@internetarchive/search-service": "^0.4.7",
"lit": "^2.0.2"

@@ -30,0 +30,0 @@ },

@@ -30,3 +30,3 @@ /* eslint-disable camelcase */

* without sending a request for them.
*
*
* @param identifierTitleMap

@@ -105,3 +105,5 @@ */

/** @inheritdoc */
async addKnownTitles(identifierTitleMap: Record<string, string>): Promise<void> {
async addKnownTitles(
identifierTitleMap: Record<string, string>
): Promise<void> {
if (!this.cacheLoaded) await this.loadFromCache();

@@ -108,0 +110,0 @@ Object.entries(identifierTitleMap).forEach(([identifier, title]) => {

@@ -342,2 +342,39 @@ import { expect } from '@open-wc/testing';

});
it('adds known titles to the cache', async () => {
const mockSearchService = new MockSearchService();
mockSearchService.searchResult = mockSearchResponse;
const collectionNameCache = new CollectionNameCache({
searchService: mockSearchService,
loadDelay: 25,
});
// fill the cache with some already-known collection titles
await collectionNameCache.addKnownTitles({
'foo-collection': 'Foo Collection',
'bar-collection': 'Bar Collection',
'baz-collection': 'Baz Collection',
});
// should immediately have them available in the cache
expect(
await collectionNameCache.collectionNameFor('foo-collection')
).to.equal('Foo Collection');
expect(
await collectionNameCache.collectionNameFor('bar-collection')
).to.equal('Bar Collection');
expect(
await collectionNameCache.collectionNameFor('baz-collection')
).to.equal('Baz Collection');
await promisedSleep(50);
// should not have tried to fetch any titles
expect(mockSearchService.searchCallCount).to.equal(0);
await collectionNameCache.preloadIdentifiers(['foo-collection']);
// again, no fetch call should be made, since we already have it cached
expect(mockSearchService.searchCallCount).to.equal(0);
});
});

@@ -0,0 +0,0 @@ import { ItemHit, SearchResponse } from '@internetarchive/search-service';

@@ -0,0 +0,0 @@ import { Result } from '@internetarchive/result-type';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc