(stream, options)
| 135 | } |
| 136 | |
| 137 | function importFd(stream, options) { |
| 138 | if (typeof options.fd === 'number') { |
| 139 | // When fd is a raw descriptor, we must keep our fingers crossed |
| 140 | // that the descriptor won't get closed, or worse, replaced with |
| 141 | // another one |
| 142 | // https://github.com/nodejs/node/issues/35862 |
| 143 | stream[kFs] = options.fs || fs; |
| 144 | return options.fd; |
| 145 | } else if (typeof options.fd === 'object' && |
| 146 | options.fd instanceof FileHandle) { |
| 147 | // When fd is a FileHandle we can listen for 'close' events |
| 148 | if (options.fs) { |
| 149 | // FileHandle is not supported with custom fs operations |
| 150 | throw new ERR_METHOD_NOT_IMPLEMENTED('FileHandle with fs'); |
| 151 | } |
| 152 | stream[kHandle] = options.fd; |
| 153 | stream[kFs] = FileHandleOperations(stream[kHandle]); |
| 154 | stream[kHandle][kRef](); |
| 155 | options.fd.on('close', FunctionPrototypeBind(stream.close, stream)); |
| 156 | return options.fd.fd; |
| 157 | } |
| 158 | |
| 159 | throw new ERR_INVALID_ARG_TYPE('options.fd', |
| 160 | ['number', 'FileHandle'], options.fd); |
| 161 | } |
| 162 | |
| 163 | function ReadStream(path, options) { |
| 164 | if (!(this instanceof ReadStream)) |
no test coverage detected
searching dependent graphs…