AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.124
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/wwwroot/mifepriston.org/node_modules/grouped-queue/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/wwwroot/mifepriston.org/node_modules/grouped-queue/lib/queue.js
'use strict';
var util = require('util');
var events = require('events');
var _ = require('lodash');
var SubQueue = require('./subqueue');

module.exports = Queue;

/**
 * Queue constructor
 * @param {String[]} [subQueue] The order of the sub-queues. First one will be runned first.
 */

function Queue( subQueues ) {
  subQueues = subQueues || [];
  if ( !subQueues.includes('default') ) {
    subQueues = subQueues.concat(['default']);
  }
  subQueues = _.uniq(subQueues);

  this.queueNames = subQueues;
  this.__queues__ = {};

  subQueues.forEach(function( name ) {
    this.__queues__[name] = new SubQueue();
  }.bind(this));
}

util.inherits( Queue, events.EventEmitter );

/**
 * Create a new sub-queue.
 * @param {String}   name  The sub-queue to create
 * @param {String}   [before]  Add the new sub-queue before the this sub-queue.
 *                             Otherwise the new sub-queue will be added last. 
 */

Queue.prototype.addSubQueue = function( name, before ) {
  if ( this.__queues__[name] ) {
    // Sub-queue already exists
    return;
  }

  if ( !before ) {
    // Add at last place.
    this.queueNames.push( name );
    this.__queues__[name] = new SubQueue();
    return;
  }

  if ( !this.__queues__[before] || this.queueNames.indexOf(before) === -1 ) {
    throw new Error('sub-queue ' + before + ' not found');
  }

  // Add new sub-queue into the array.
  this.queueNames.splice(this.queueNames.indexOf(before), 0, name);
  this.__queues__[name] = new SubQueue();
};

/**
 * Add a task to a queue.
 * @param {String}   [name='default']  The sub-queue to append the task
 * @param {Function} task
 * @param {Object}   [opt]             Options hash
 * @param {String}   [opt.once]        If a task with the same `once` value is inside the
 *                                     queue, don't add this task.
 * @param {Boolean}  [opt.run]         If `run` is false, don't run the task.
 */

Queue.prototype.add = function( name, task, opt ) {
  if ( typeof name !== 'string' ) {
    opt = task;
    task = name;
    name = 'default';
  }

  this.__queues__[name].push( task, opt );

  // don't run the tasks if `opt.run` is false
  if (opt && opt.run === false) return;
  setImmediate(this.run.bind(this));
};

/**
 * Start emptying the queues
 * Tasks are always run from the higher priority queue down to the lowest. After each
 * task complete, the process is re-runned from the first queue until a task is found.
 *
 * Tasks are passed a `callback` method which should be called once the task is over.
 */

Queue.prototype.run = function() {
  if ( this.running ) return;

  this.running = true;
  this._exec(function() {
    this.running = false;
    if (_(this.__queues__).map('__queue__').flatten().value().length === 0) {
      this.emit('end');
    } else {
      this.emit('paused');
    }
  }.bind(this));
};

/**
 * Pause the queue
 */

Queue.prototype.pause = function() {
  this.running = false;
};

Queue.prototype._exec = function( done ) {
  var pointer = -1;
  var names = this.queueNames;

  var next = function next() {
    if ( !this.running ) return done();

    pointer++;
    if ( pointer >= names.length ) return done();
    this.__queues__[ names[pointer] ].run( next.bind(this), this._exec.bind(this, done) );
  }.bind(this);

  next();
};

Anon7 - 2022
AnonSec Team