MCPcopy Create free account
hub / github.com/nodejs/undici / assertCacheStore

Function assertCacheStore

lib/util/cache.js:683–693  ·  view source on GitHub ↗

* @param {unknown} store * @returns {asserts store is import('../../types/cache-interceptor.d.ts').default.CacheStore}

(store, name = 'CacheStore')

Source from the content-addressed store, hash-verified

681 * @returns {asserts store is import('../../types/cache-interceptor.d.ts').default.CacheStore}
682 */
683function assertCacheStore (store, name = 'CacheStore') {
684 if (typeof store !== 'object' || store === null) {
685 throw new TypeError(`expected type of ${name} to be a CacheStore, got ${store === null ? 'null' : typeof store}`)
686 }
687
688 for (const fn of ['get', 'createWriteStream', 'delete']) {
689 if (typeof store[fn] !== 'function') {
690 throw new TypeError(`${name} needs to have a \`${fn}()\` function`)
691 }
692 }
693}
694/**
695 * @param {unknown} methods
696 * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]}

Callers 1

cache.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected