MCPcopy Create free account
hub / github.com/Maccoder3/MAC-MD / saveStreamToFile

Function saveStreamToFile

lib/helper.js:79–90  ·  view source on GitHub ↗
(stream, file)

Source from the content-addressed store, hash-verified

77 * @returns {Promise<void>}
78 */
79const saveStreamToFile = (stream, file) =>
80 new Promise((resolve, reject) => {
81 const writable = stream.pipe(fs.createWriteStream(file))
82 writable.once('finish', () => {
83 resolve()
84 writable.destroy()
85 })
86 writable.once('error', () => {
87 reject()
88 writable.destroy()
89 })
90 })
91
92const kDestroyed = Symbol('kDestroyed')
93const kIsReadable = Symbol('kIsReadable')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected