You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
543 B
JavaScript
14 lines
543 B
JavaScript
"use strict";
|
|
|
|
const warn = require("./warn");
|
|
|
|
module.exports = function destroyStream(stream) {
|
|
// TODO: Do we need to detach any event handlers prior to destroying streams? ref. https://www.npmjs.com/package/yauzl:
|
|
// "You must unpipe() the readStream from any destination before calling readStream.destroy()."
|
|
if (typeof stream.destroy === "function") {
|
|
stream.destroy();
|
|
} else {
|
|
warn("The stream you are converting does not have a 'destroy' method, and could therefore not be destroyed. This may cause resource leaks!");
|
|
}
|
|
};
|