Server IP : 85.214.239.14 / Your IP : 3.17.128.87 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/amp/lib/ |
Upload File : |
/** * Module dependencies. */ var Stream = require('stream').Writable; var encode = require('./encode'); /** * Expose parser. */ module.exports = Parser; /** * Initialize parser. * * @param {Options} [opts] * @api public */ function Parser(opts) { Stream.call(this, opts); this.state = 'message'; this._lenbuf = new Buffer(4); } /** * Inherit from `Stream.prototype`. */ Parser.prototype.__proto__ = Stream.prototype; /** * Write implementation. */ Parser.prototype._write = function(chunk, encoding, fn){ for (var i = 0; i < chunk.length; i++) { switch (this.state) { case 'message': var meta = chunk[i]; this.version = meta >> 4; this.argv = meta & 0xf; this.state = 'arglen'; this._bufs = [new Buffer([meta])]; this._nargs = 0; this._leni = 0; break; case 'arglen': this._lenbuf[this._leni++] = chunk[i]; // done if (4 == this._leni) { this._arglen = this._lenbuf.readUInt32BE(0); var buf = new Buffer(4); buf[0] = this._lenbuf[0]; buf[1] = this._lenbuf[1]; buf[2] = this._lenbuf[2]; buf[3] = this._lenbuf[3]; this._bufs.push(buf); this._argcur = 0; this.state = 'arg'; } break; case 'arg': // bytes remaining in the argument var rem = this._arglen - this._argcur; // consume the chunk we need to complete // the argument, or the remainder of the // chunk if it's not mixed-boundary var pos = Math.min(rem + i, chunk.length); // slice arg chunk var part = chunk.slice(i, pos); this._bufs.push(part); // check if we have the complete arg this._argcur += pos - i; var done = this._argcur == this._arglen; i = pos - 1; if (done) this._nargs++; // no more args if (this._nargs == this.argv) { this.state = 'message'; this.emit('data', Buffer.concat(this._bufs)); break; } if (done) { this.state = 'arglen'; this._leni = 0; } break; } } fn(); };