Open
Description
graceful-fs allows the user to provide a constructor function for the ReadStream class. It then modifies the function’s prototype (including modifying its base class). If no function is provided, then it provides one. This pattern should be supported as long as the provided function is assignable to the default one.
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
var fs = require('fs')
/** @type {{ a: () => void }} */
var legStreams
// from graceful-fs
function patch(process) {
if (process) {
ReadStream = legStreams.a
}
ReadStream.prototype = Object.create(fs.ReadStream)
ReadStream.prototype.open = fs$open
function ReadStream (path, options) {
if (this instanceof ReadStream) {
return fs.ReadStream.apply(this, arguments), this
}
else {
return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
}
}
function fs$open() {
}
// ReadStream should still be newable too!
function createReadStream(path, options) {
return new ReadStream(path, options)
}