Register an undrier

@author   Jelle De Loecker   <jelle@develry.be>
@since    1.0.0
@version  1.0.0

@param    {Function|String}   constructor   What constructor to listen to
@param    {Function} fnc
@param    {Object}   options
326480
function registerUndrier(constructor, fnc, options) {

	var path;

	if (typeof constructor == 'function') {
		path = constructor.name;
	} else {
		path = constructor;
	}

	undriers[path] = {
		fnc     : fnc,
		options : options || {}
	};
}
631694
function NjsCompiler(options) {
    this.nodeSequence = 0;
    this.options = options || {};
    if (!this.options.runtime) {
        this.options.runtime = 'njs';
    }
    this.parseBooleanOptions("exceptions", true);
}
1266150
function Propagator(
    constructor, transforms,
    cancellable, signalCancelled) {
  this._constructor = constructor || promise.Promise;
  this._transforms = transforms;
  this._cancellable = cancellable === true;
  this._signalCancelled = signalCancelled;

  this._state = INITIALIZED;
  this._resolved = false;
  this._cancelled = false;
  this._delegatedResolve = null;
  this._delegatedReject = null;

  this._result = null;
  this._resultThen = null;
  this._handledRejection = null;

  this._promise = null;
}
101898
function init(options) {
  options = options || {}
  var port = options.port || 6466
  global.client = global.client || socketIOClient(`http://localhost:${port}`)
  client = global.client
  log.debug(`Started global js socketIO client for ${process.env.ADAPTER} at ${port}`)
  client.emit('join', ioid) // first join for serialization
  client.on('disconnect', client.disconnect)
  client.on('take', hasher.handle) // add listener
  
  // add methods
  client.pass = pass
  client.clientPass = clientPass
  return client
}
108898
function(options)
	{
		var args = conbo.toArray(arguments);
		
		if (args[0] === undefined) 
		{
			args[0] = {};
		}
		else if (args[0] instanceof conbo.Context && conbo.is(this, conbo.IInjectable, false)) 
		{
			args[0] = args[0].addTo();
		}
		
		this.declarations.apply(this, args);
		
		if (!!args[0].context)
		{
			this.context = args[0].context;
		}
	
		if (this instanceof conbo.EventDispatcher)
		{
			this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.PREINITIALIZE));
		}

		this.preinitialize.apply(this, args);
		this.__construct.apply(this, args);
		
		if (this instanceof conbo.EventDispatcher)
		{
			this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.INITIALIZE));
		}

		this.initialize.apply(this, args);
		conbo.makeAllBindable(this, this.bindable);
		this.__postInitialize.apply(this, args);
		
		if (this instanceof conbo.EventDispatcher)
		{
			this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.INIT_COMPLETE));
		}		
	}
504565
public void registerCallback(String importer, ChannelChangeCallback callback) {
        Preconditions.checkArgument(
                importer != null && !importer.trim().isEmpty(),
                "importer is null or empty"
                );
        callback = checkNotNull(callback, "callback is null");

        if (m_done.get()) return;

        int [] stamp = new int[]{0};
        NavigableMap<String,ChannelChangeCallback> prev = null;
        NavigableMap<String,ChannelChangeCallback> next = null;
        ImmutableSortedMap.Builder<String,ChannelChangeCallback> mbldr = null;

        synchronized (m_undispatched) {
            do {
                prev = m_callbacks.get(stamp);
                mbldr = ImmutableSortedMap.naturalOrder();
                mbldr.putAll(Maps.filterKeys(prev, not(equalTo(importer))));
                mbldr.put(importer, callback);
                next = mbldr.build();
            } while (!m_callbacks.compareAndSet(prev, next, stamp[0], stamp[0]+1));

            NavigableSet<String> registered = next.navigableKeySet();
            NavigableSet<String> unregistered = m_unregistered.getReference();

            Iterator<ImporterChannelAssignment> itr = m_undispatched.iterator();
            while (itr.hasNext()) {
                final ImporterChannelAssignment assignment = itr.next();
                if (registered.contains(assignment.getImporter())) {
                    final ChannelChangeCallback dispatch = next.get(assignment.getImporter());
                    m_buses.submit(new DistributerRunnable() {
                        @Override
                        public void susceptibleRun() throws Exception {
                            dispatch.onChange(assignment);
                        }
                    });
                    itr.remove();
                } else if (unregistered.contains(assignment.getImporter())) {
                    itr.remove();
                    if (!assignment.getAdded().isEmpty()) {
                        LOG.warn("(" + m_hostId
                                + ") discarding assignment to unregistered importer "
                                + assignment);
                    }
                }
            }
        }
    }
343850
function(options)
	{
		options = conbo.defineDefaults(options, this.options);
		
		if (!!options.context) this.context = options.context;
		this.preinitialize(options);
		
		this._httpService = new conbo.HttpService(options);
		this._command = options.command;
		
		var resultHandler = function(event)
		{
			conbo.makeBindable(this, conbo.variables(event.result));
			conbo.assign(this, event.result);
			
			this.dispatchEvent(event);
		};
		
		this._httpService
			.addEventListener(conbo.ConboEvent.RESULT, resultHandler, this)
			.addEventListener(conbo.ConboEvent.FAULT, this.dispatchEvent, this);
		
		__denumerate(this);
		
		conbo.Hash.prototype.__construct.apply(this, arguments);
	}
1127436
function (memberValue, visibility) {
        _gpfAsserts({
            "Constructor must be a function": "function" === typeof memberValue,
            "Own constructor can't be overridden": null === this._definitionConstructor
        });
        if (_gpfUsesSuper(memberValue)) {
            memberValue = _gpfGenSuperMember(this._Super, memberValue);
        }
        _gpfIgnore(visibility); // TODO Handle constructor visibility
        this._definitionConstructor = memberValue;
    }
1120341
public void unregisterCallback(String importer) {
        if (   importer == null
            || !m_callbacks.getReference().containsKey(importer)
            || m_unregistered.getReference().contains(importer))
        {
            return;
        }
        if (m_done.get()) return;

        int [] rstamp = new int[]{0};
        NavigableMap<String,ChannelChangeCallback> rprev = null;
        NavigableMap<String,ChannelChangeCallback> rnext = null;

        int [] ustamp = new int[]{0};
        NavigableSet<String> uprev = null;
        NavigableSet<String> unext = null;

        synchronized(m_undispatched) {
            do {
                rprev = m_callbacks.get(rstamp);
                rnext = ImmutableSortedMap.<String,ChannelChangeCallback>naturalOrder()
                        .putAll(Maps.filterKeys(rprev, not(equalTo(importer))))
                        .build();
            } while (rprev.containsKey(importer) && !m_callbacks.compareAndSet(rprev, rnext, rstamp[0], rstamp[0]+1));

            do {
                uprev = m_unregistered.get(ustamp);
                unext = ImmutableSortedSet.<String>naturalOrder()
                        .addAll(Sets.filter(uprev, not(equalTo(importer))))
                        .add(importer)
                        .build();
            } while (!uprev.contains(importer) && m_unregistered.compareAndSet(uprev, unext, ustamp[0], ustamp[0]+1));

            Iterator<ImporterChannelAssignment> itr = m_undispatched.iterator();
            while (itr.hasNext()) {
                final ImporterChannelAssignment assignment = itr.next();
                if (unext.contains(assignment.getImporter())) {
                    itr.remove();
                }
            }
        }
    }
832064
function register (server, options, next) {
  server.ext('onPreHandler', function maybeForceGzip (request, reply) {
    if (request.query.force_gzip === 'true') {
      request.info.acceptEncoding = 'gzip'
    }
    reply.continue()
  })

  next()
}
899963
function listenUnhandledErrors(logger) {
  var _loggerType = _flowRuntime2.default.nullable(_flowRuntime2.default.ref(_nightingaleLogger2.default));

  _flowRuntime2.default.param('logger', _loggerType).assert(logger);

  if (!logger) logger = _loggerType.assert(new _nightingaleLogger2.default('nightingale.listenUnhandledErrors', 'listenUnhandledErrors'));
  process.on('uncaughtException', function (err) {
    return logger.error('uncaughtException', { err: err });
  });
  process.on('unhandledRejection', function (err) {
    return logger.error('unhandledRejection', { err: err });
  });
}
1365442
function Builder(baseURL, cfg) {
  if (typeof baseURL == 'object') {
    cfg = baseURL;
    baseURL = null;
  }

  this.loader = null;
  this.resetConfig = function() {};

  this.reset();

  if (baseURL)
    this.config({ baseURL: baseURL });

  // config passed to constructor will
  // be saved for future .reset() calls
  if (typeof cfg == 'object')
    this.config(cfg, true, !!baseURL);
  else if (typeof cfg == 'string')
    this.loadConfigSync(cfg, true, !!baseURL);
}
1088979
function bind( fn, scope ) {
    var bound, args;
    if ( fn.bind === nativeBind && nativeBind ) return nativeBind.apply( fn, Array.prototype.slice.call( arguments, 1 ) );
    args = Array.prototype.slice.call( arguments, 2 );
    // @todo: don't link this
    bound = function() {
        if ( !(this instanceof bound) ) return fn.apply( scope, args.concat( Array.prototype.slice.call( arguments ) ) );
        W.ctor.prototype = fn.prototype;
        var self = new ctor();
        var result = fn.apply( self, args.concat( Array.prototype.slice.call( arguments ) ) );
        if ( Object( result ) === result ) return result;
        return self;
    };
    return bound;
}
687993
function constructor(options) {
    Pagelet.prototype.constructor.call(this, options = options || {});

    //
    // Store the provided global dependencies.
    //
    this.dependencies = this._bigpipe._compiler.page(this).concat(
      options.dependencies
    );

    var req = options.req || {}
      , uri = req.uri || {}
      , query = req.query || {};

    //
    // Set a number of properties on the response as it is available to all pagelets.
    // This will ensure the correct amount of pagelets are processed and that the
    // entire queue is written to the client.
    //
    this._queue = [];

    //
    // Prepare several properties that are used to render the HTML fragment.
    //
    this.length = options.length || 0;
    this.child = options.child || 'root';
    this.once('contentType', this.contentTypeHeader, this);

    //
    // Set the default fallback script, see explanation above.
    //
    this.debug('Initialized in %s mode', options.mode);
    this.fallback = 'sync' === options.mode ? script : noscript.replace(
      '{path}',
      uri.pathname || 'http://localhost/'
    ).replace(
      '{query}',
      qs.stringify(this.merge({ no_pagelet_js: 1 }, query))
    );
  }
363005
function EntityInstantiator(options) {
  if (!options.store) throw new Error("Missing store");
  if (!options.Entity) throw new Error("Missing entity constructor");
  if (!options.logger) throw new Error("Missing logger");
  this.store  = options.store;
  this.Entity = options.Entity;
  this.logger = options.logger;
}
360969
function createNewDebugger(scopename, opts = {}) {
    const handler = {

        get(target, propKey, receiver) {

            return function (...args) {

                const origMethod = target[propKey];

                // Always return immediately all but the specified console methods.
                if (!propKey.match(/debug|log|info|group|groupEnd/)) {
                    if(opts.quiet) {return}
                    const result = origMethod.apply(this, args);
                    return result
                }
                
                if (typeof localStorage === "undefined") {
                    // "Your environment does not have localStorage"
                    return
                } else if (!localStorage['cth-debug']) {
                    // Returning because no cth-debug variable is set
                    return
                }

                const pattern = globToRegexp(localStorage['cth-debug'])

                if (pattern.test(scopename)) {
                    if(opts.quiet) {return}
                    const result = origMethod.apply(this, args);
                    return result
                } else {
                    // Return null when a call was rejected (mainly for unit tests)
                    return null
                }
            }
        }
    }
    return new Proxy(console, handler)
}
593294
function Logger(options) {
        var logger;

        // Default values
        var dict = {
            ssl: true,
            catchall: false,
            trace: true,
            page_info: 'never',
            print: false,
            endpoint: null,
            token: null
        };

        if (typeof options === "object")
            for (var k in options)
                dict[k] = options[k];
        else
            throw new Error("Invalid parameters for createLogStream()");

        if (dict.token === null) {
            throw new Error("Token not present.");
        } else {
            logger = new LogStream(dict);
        }

        var _log = function(msg) {
            if (logger) {
                return logger.log.apply(this, arguments);
            } else
                throw new Error("You must call LE.init(...) first.");
        };

         // The public interface
        return {
            log: function() {
                _log.apply(this, arguments).level('LOG').send();
            },
            warn: function() {
                _log.apply(this, arguments).level('WARN').send();
            },
            error: function() {
                _log.apply(this, arguments).level('ERROR').send();
            },
            info: function() {
                _log.apply(this, arguments).level('INFO').send();
            }
        };
    }