MCPcopy Index your code
hub / github.com/nodejs/undici / createWriteStream

Method createWriteStream

lib/cache/sqlite-cache-store.js:312–341  ·  view source on GitHub ↗

* @param {import('../../types/cache-interceptor.d.ts').default.CacheKey} key * @param {import('../../types/cache-interceptor.d.ts').default.CacheValue} value * @returns {Writable | undefined}

(key, value)

Source from the content-addressed store, hash-verified

310 * @returns {Writable | undefined}
311 */
312 createWriteStream (key, value) {
313 assertCacheKey(key)
314 assertCacheValue(value)
315
316 let size = 0
317 /**
318 * @type {Buffer[] | null}
319 */
320 const body = []
321 const store = this
322
323 return new Writable({
324 decodeStrings: true,
325 write (chunk, encoding, callback) {
326 size += chunk.byteLength
327
328 if (size <= store.#maxEntrySize) {
329 body.push(chunk)
330 } else {
331 this.destroy()
332 }
333
334 callback()
335 },
336 final (callback) {
337 store.set(key, { ...value, body })
338 callback()
339 }
340 })
341 }
342
343 /**
344 * @param {import('../../types/cache-interceptor.d.ts').default.CacheKey} key

Callers

nothing calls this directly

Calls 2

assertCacheKeyFunction · 0.85
assertCacheValueFunction · 0.85

Tested by

no test coverage detected