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

Function assertCacheStore

lib/util/cache.js:643–653  ·  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

641 * @returns {asserts store is import('../../types/cache-interceptor.d.ts').default.CacheStore}
642 */
643function assertCacheStore (store, name = 'CacheStore') {
644 if (typeof store !== 'object' || store === null) {
645 throw new TypeError(`expected type of ${name} to be a CacheStore, got ${store === null ? 'null' : typeof store}`)
646 }
647
648 for (const fn of ['get', 'createWriteStream', 'delete']) {
649 if (typeof store[fn] !== 'function') {
650 throw new TypeError(`${name} needs to have a \`${fn}()\` function`)
651 }
652 }
653}
654/**
655 * @param {unknown} methods
656 * @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