Register or retrieve a Service Worker that controls the page.
@param {Object} options
@returns {Promise}
966994
function register (options, __mockSelf) {
  var _self = __mockSelf || self
  var navigator = _self.navigator

  if (!('serviceWorker' in navigator)) {
    return Promise.reject(new Error('Service Workers unsupported'))
  }

  var serviceWorker = navigator.serviceWorker.controller

  return Promise.resolve()
    .then(function () {
      // Get existing service worker or get registration promise
      if (serviceWorker) return serviceWorker
      else if (!options) return navigator.serviceWorker.ready
    })
    .then(function (registration) {
      if (registration) {
        // Take this service worker that the registration returned
        serviceWorker = registration
      } else if (!registration && options) {
        // No registration but we have options to register one
        return navigator.serviceWorker
          .register(options.url, options)
          .then(function (registration) {
            options.forceUpdate && registration.update()
          })
      } else if (!registration && !options) {
        // No existing worker,
        // no registration that returned one,
        // no options to register one
        throw new Error('no active service worker or configuration passed to install one')
      }
    })
    .then(function () {
      return serviceWorker
    })
}
1244867
function createHandler(options) {
  /**
   * Client request handler
   * Data from the incoming request (plus options) is forwarded to the AWS module
   */
  return async (ctx) => {
    const { credentials, endpoint, region } = options
    const { rawBody: body, header: headers, method, url: path } = ctx.request

    console.log(chalk.cyan(method, path))

    const params = { body, credentials, endpoint, headers, method, path, region }
    const req = createSignedAWSRequest(params)
    const res = await sendAWSRequest(req)

    ctx.status = 200
    ctx.type = 'application/json'
    ctx.response.header = stripProxyResHeaders(res)
    ctx.body = res.body
  }
}
203662
function(options) {
  options    = options || {};

  var config = konfig({ path: options.configPath || process.cwd() + '/config' });

  // Default options
  options.server                = options.server || { port: process.env.PORT };
  options.debug                 = options.debug || false;
  options.discoverable          = options.discoverable || false;
  options.monitorsPath          = options.monitorsPath || 'monitors';
  options.controllersPath       = options.controllersPath || 'controllers';
  options.callerPath            = options.callerPath || path.dirname(caller(2));
  options.serviceName           = pkgInfo.name;
  options.serviceBasePath       = 'services';
  options.zookeeper             = { connectionString: 'localhost:2181', retry: { count: 5 } };
  options.partialResponseQuery  = options.partialResponseQuery || 'fields';
  options.correlationHeaderName = options.correlationHeaderName || 'X-CorrelationID';
  options.validatorOptions      = options.validatorOptions || null;

  // Feature Flags
  options.enableBodyParsing     = options.enableBodyParsing || true;
  options.enableEtag            = options.enableEtag || false;
  options.enableRequestTracing  = options.enableRequestTracing || false;

  // Return now if we have no config
  if (!config.app) {
    return options;
  }

  // Overlay config file options
  options.server              = config.app.server || { port: process.env.PORT };
  options.serviceName         = config.app.microservice.server.name || pkgInfo.name;
  options.serviceBasePath     = config.app.microservice.basePath || 'services';
  options.networkInterfaces   = (config.app.microservice.server.registrationNetworkInterfacePriority) ? config.app.microservice.server.registrationNetworkInterfacePriority : null;
  options.serviceDependencies = (config.app.microservice.server.dependencies) ? config.app.microservice.server.dependencies.split(',') : null;
  options.zookeeper           = config.app.zookeeper || { connectionString: 'localhost:2181', retry: { count: 5 } };

  return options;
}
984285
function startWorkerPoolServer(options, listenCallback)
{
	var workerPool = createWorkerPool();
	var server = createServer(options);
	var logConnection = getOption(options, 'logConnection', true);
	var port = getOption(options, 'port', 0);

	server.on('client', (client) => {
		
		client.on('RGST', (msg) => {
			workerPool.addClient(client);
		});
		
		client.on('error', (e) => {
			workerPool.deleteClient(client);
		});
		
		client.on('close', () => {
			workerPool.deleteClient(client);
		});
	});
	
	server.listen({port: port}, () => {
		if ( logConnection )
		{
			console.log('LISTEN ' + port);
		}
		if ( listenCallback )
		{
			listenCallback(server);
		}
	});
	
	return workerPool;
}
647571
function Console (options = {}, handlers) {
  this.config = Object.assign({}, defaultOptions, options)
  this.history = []
  this.handlers = {}

  this.log(this.config.welcome)

  if (handlers) {
    for (let cmd in handlers) {
      this.register(cmd, handlers[cmd], handlers[cmd].config)
    }
  }

  this._render()

  return this
}
933463
function(options) {

    var self = this;

    return {
      subscribe: function (handler) {
        return self._getAuth().isAuthenticated()
        .then(function() {
          // Perform subscription and return Faye Subscription Object
          return self._getFayeClient(options).subscribe(options.channel, handler);
        });
      }
    }
  }
217231
function() {
    if (typeof window.Worker === 'undefined' || typeof window.URL === 'undefined') {
        return false;
    }

    try {
        /* eslint-disable no-new */
        new Worker(window.URL.createObjectURL(
            new Blob([''], { type: 'text/javascript' })
        ));
        /* eslint-enable no-new */
    } catch (e) {
        return false;
    }

    return true;
}
1004767
function registerCommands(icli) {
      return Promise.all([
        require('./cli/create-policy')(icli),
        require('./cli/create-role')(icli),
        require('./cli/deploy-policies')(icli),
        require('./cli/deploy-roles')(icli)
      ])
      .then(() => {
        return Promise.resolve([]);
      });
    }
1327572
function(options, zookeeperOptions) {
    EventEmitter.call(this);

    this.modules = {};
    this.middlewares = [];

    this.options = options || {};
    this.zookeeperOptions = zookeeperOptions || {};

    this.zookeeper = undefined;
    if(this.zookeeperOptions && Object.keys(this.zookeeperOptions).length) {
        this.zookeeper = new Zookeeper(
            this.zookeeperOptions.connectString,
            this.zookeeperOptions,
            this.zookeeperOptions.root,
            this.zookeeperOptions.prefix);
    }

    this.server = helper.createServer(options, this._onClientConnected.bind(this));
}
686451
function(options)
    {
        return new Promise( (resolve, reject) =>
        {
            if (options)
            {
                options.logger.info('[PROGENIC] Starting "%s" daemon with %s workers...', options.name, options.workers);
                options.logger.info('[PROGENIC] [from "%s"]', options.main);

                // Write the PID file:
                helpers.writePidFile(options.name, options.devMode, options.logger);

                cluster.setupMaster(
                {
                    exec: path.join(__dirname, 'worker.js'),
                    args: [options.main, process.env.INSTANCE_NAME],
                    silent: true
                });

                const promises = [];

                let count = options.workers;

                while (count-- > 0)
                {
                    options.logger.info('[PROGENIC] Creating  worker #%s...', (options.workers - count));

                    promises.push(helpers.forkWorker(options.name, options.devMode, options.logger, options.logsBasePath, options.checkPingsEnabled));
                }

                Promise.all(promises)
                .then(resolve)
                .catch(reject);
            }
            else
            {
                reject(new Error('Missing options'));
            }
        });
    }
1235790
function (param, options, callback) {
              embedProcessor.log(param.worker + ' started with parameters = ', param);
              param.status = true;
              param.duration = false;
              param.duration_formatted = false;
              param.thumbnail_url = false;
              param.favicon_url = '';
              param.service_name = '';
              param.provider_url = '';
              param.html = false;
              param.views = false;
              if (embedProcessor._sources[param.source] && embedProcessor._sources[param.source].prepareEmbedCode) {
                param = embedProcessor._sources[param.source].prepareEmbedCode(param);
              }
              param = embedProcessor._paramEmbedCodeNormalizer(param);
              embedProcessor.log(param.worker + ' receive parameters = ', param);
              callback(param);
            }
1117144
function WebServer(options) {
  EventEmitter.call(this);

  this._options = options;

  this._username = options['username'];
  this._ip = options['ip'];
  this._port = options['port'];
  this._secret = options['secret'];
  this._triggerString = options['trigger_string'];

  this._server = null;
}
21650
function(options) {
    var self = this

    options = options || {}

    return self
      .callInterceptors('beforeDestroy', [self, options])
      .then(function() {
        return new Promise(function(resolve, reject) {
          self.model.definition.store.connection.del(
            self.dn,
            options.controls || [],
            function(err) {
              if (err)
                return reject(
                  self.definition.store.convertLdapErrorToValidationError(
                    self,
                    err
                  )
                )

              resolve(self.callInterceptors('afterDestroy', [self, options]))
            }
          )
        })
      })
      .then(function(record) {
        record.__exists = false
        return record
      })
  }
912983
function(options) {
    var self = this;

    options = options || {};

    var error = options.error;

    var fns = [
      _.bind(self.preFetch, self, options),
      _.bind(PromisedModel.prototype.fetch, self, options),
      _.bind(self.afterFetch, self, options)
    ];
    return sequence(fns).then(function () {
      self.fetchStatus = 'fetched';
      return self;
    }, function (err) {
      if (error) error.call(options, self, err);
      return failWithError(options, err);
    });
  }
275632
function webWorkerSearchFactory($q, $rootScope, NG_PAGES) {

    console.log('Using WebWorker Search Index')

    var searchIndex = $q.defer();
    var results;

    var worker = new Worker('js/search-worker.js');

    // The worker will send us a message in two situations:
    // - when the index has been built, ready to run a query
    // - when it has completed a search query and the results are available
    worker.onmessage = function(oEvent) {
      $rootScope.$apply(function() {

        switch(oEvent.data.e) {
          case 'index-ready':
            searchIndex.resolve();
            break;
          case 'query-ready':
            var pages = oEvent.data.d.map(function(path) {
              return NG_PAGES[path];
            });
            results.resolve(pages);
            break;
        }
      });
    };

    // The actual service is a function that takes a query string and
    // returns a promise to the search results
    return function(q) {

      // We only run the query once the index is ready
      return searchIndex.promise.then(function() {

        results = $q.defer();
        worker.postMessage({ q: q });
        return results.promise;
      });
    };
  }
1073738
function Supervisor(sigInst, options) {
    var _this = this,
        workerFn = sigInst.getForceAtlas2Worker &&
          sigInst.getForceAtlas2Worker();

    options = options || {};

    // _root URL Polyfill
    _root.URL = _root.URL || _root.webkitURL;

    // Properties
    this.sigInst = sigInst;
    this.graph = this.sigInst.graph;
    this.ppn = 10;
    this.ppe = 3;
    this.config = {};
    this.shouldUseWorker =
      options.worker === false ? false : true && webWorkers;
    this.workerUrl = options.workerUrl;

    // State
    this.started = false;
    this.running = false;

    // Web worker or classic DOM events?
    if (this.shouldUseWorker) {
      if (!this.workerUrl) {
        var blob = this.makeBlob(workerFn);
        this.worker = new Worker(URL.createObjectURL(blob));
      }
      else {
        this.worker = new Worker(this.workerUrl);
      }

      // Post Message Polyfill
      this.worker.postMessage =
        this.worker.webkitPostMessage || this.worker.postMessage;
    }
    else {

      eval(workerFn);
    }

    // Worker message receiver
    this.msgName = (this.worker) ? 'message' : 'newCoords';
    this.listener = function(e) {

      // Retrieving data
      _this.nodesByteArray = new Float32Array(e.data.nodes);

      // If ForceAtlas2 is running, we act accordingly
      if (_this.running) {

        // Applying layout
        _this.applyLayoutChanges();

        // Send data back to worker and loop
        _this.sendByteArrayToWorker();

        // Rendering graph
        _this.sigInst.refresh();
      }
    };

    (this.worker || document).addEventListener(this.msgName, this.listener);

    // Filling byteArrays
    this.graphToByteArrays();

    // Binding on kill to properly terminate layout when parent is killed
    sigInst.bind('kill', function() {
      sigInst.killForceAtlas2();
    });
  }
1047098
function (options) {
    options = options || {};
    this.id = options['id'];
    this.strict = options['strict'] || false;
    this.meta = DataTable.createMetaItems(options['meta']);
    this.enable = options['enable'] || DataTable.DEFAULTS.enable;
    this.pageSize = ko.observable(options['pageSize'] || DataTable.DEFAULTS.pageSize)
    this.pageIndex = ko.observable(options['pageIndex'] || DataTable.DEFAULTS.pageIndex)
    this.totalPages = ko.observable(options['totalPages'] || DataTable.DEFAULTS.totalPages)
    this.totalRow = ko.observable()
    this.pageCache = options['pageCache'] === undefined ? DataTable.DEFAULTS.pageCache : options['pageCache']
    this.rows = ko.observableArray([])
    this.selectedIndices = ko.observableArray([])
    this._oldCurrentIndex = -1;
    this.focusIndex = ko.observable(-1)
    this.cachedPages = []
    this.metaChange = {};
    this.valueChange = {};//ko.observable(1);
    this.currentRowChange = ko.observable(1);
    this.enableChange = ko.observable(1);
    this.params = options['params'] || {};
    this.master = options['master'] || '';
    this.allSelected = ko.observable(false);
    if (options['root']){
        this.root = options['root']
    }else{
        this.root = this;
    }
    if (options['ns']){
        this.ns = options['ns'];
    }else{
        this.ns = '';
    }
}