Server IP : 68.65.120.251 / Your IP : 3.18.103.55 [ Web Server : LiteSpeed System : Linux server105.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : travtpib ( 6521) PHP Version : 7.4.33 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/alt-nodejs11/root/lib/node_modules/npm/node_modules/fstream/lib/ |
Upload File : |
// A reader for when we don't yet know what kind of thing // the thing is. module.exports = ProxyReader var Reader = require('./reader.js') var getType = require('./get-type.js') var inherits = require('inherits') var fs = require('graceful-fs') inherits(ProxyReader, Reader) function ProxyReader (props) { var self = this if (!(self instanceof ProxyReader)) { throw new Error('ProxyReader must be called as constructor.') } self.props = props self._buffer = [] self.ready = false Reader.call(self, props) } ProxyReader.prototype._stat = function () { var self = this var props = self.props // stat the thing to see what the proxy should be. var stat = props.follow ? 'stat' : 'lstat' fs[stat](props.path, function (er, current) { var type if (er || !current) { type = 'File' } else { type = getType(current) } props[type] = true props.type = self.type = type self._old = current self._addProxy(Reader(props, current)) }) } ProxyReader.prototype._addProxy = function (proxy) { var self = this if (self._proxyTarget) { return self.error('proxy already set') } self._proxyTarget = proxy proxy._proxy = self ;[ 'error', 'data', 'end', 'close', 'linkpath', 'entry', 'entryEnd', 'child', 'childEnd', 'warn', 'stat' ].forEach(function (ev) { // console.error('~~ proxy event', ev, self.path) proxy.on(ev, self.emit.bind(self, ev)) }) self.emit('proxy', proxy) proxy.on('ready', function () { // console.error("~~ proxy is ready!", self.path) self.ready = true self.emit('ready') }) var calls = self._buffer self._buffer.length = 0 calls.forEach(function (c) { proxy[c[0]].apply(proxy, c[1]) }) } ProxyReader.prototype.pause = function () { return this._proxyTarget ? this._proxyTarget.pause() : false } ProxyReader.prototype.resume = function () { return this._proxyTarget ? this._proxyTarget.resume() : false }