************************************************************************ Arbiter Utility Functions ************************************************************************
495704
function sub (topic, spy, options, context) {
      spy = spy || jasmine.createSpy();
      spy.token = arbiter.subscribe(topic, spy, options, context);
      return spy;
    }
520577
function renderArbitraryAST(plugin, ref, deps) {
  const { hasOwn } = deps;
  const child = t.identifier("child");
  const type = t.identifier("type");
  const func = t.identifier("func");
  const args = t.identifier("args");
  const i = t.identifier("i");
  const prop = t.identifier("prop");

  /**
   * function _renderArbitrary(child) {
   *   var type = typeof child;
   *   if (type === "number" || (type === string || type === 'object' && child instanceof String)) {
   *     text(child);
   *   } else if (Array.isArray(child)) {
   *     for (var i = 0; i < child.length; i++) {
   *       _renderArbitrary(child[i]);
   *     }
   *   } else if (type === "object") {
   *     if (child.__jsxDOMWrapper) {
   *       var func = child.func, args = child.args;
   *       if (args) {
   *         func.apply(this, args);
   *       } else {
   *         func();
   *       }
   *     } else if (String(child) === "[object Object]") {
   *       for (var prop in child) {
   *         if (_hasOwn.call(child, prop)) {
   *           renderArbitrary(child[prop])
   *         }
   *       }
   *     }
   *   }
   * }
   */
  return t.functionExpression(
    ref,
    [child],
    t.blockStatement([
      t.variableDeclaration("var", [
        t.variableDeclarator(
          type,
          t.unaryExpression("typeof", child)
        )
      ]),
      t.IfStatement(
        isTextual(type, child),
        t.blockStatement([
          t.expressionStatement(toFunctionCall(iDOMMethod("text", plugin), [child]))
        ]),
        t.ifStatement(
          isArray(child),
          t.blockStatement([
            t.forStatement(
              t.variableDeclaration("var", [t.variableDeclarator(i, t.numericLiteral(0))]),
              t.binaryExpression("<", i, t.memberExpression(child, t.identifier("length"))),
              t.updateExpression("++", i),
              t.expressionStatement(toFunctionCall(ref, [
                t.memberExpression(child, i, true)
              ]))
            )
          ]),
          t.ifStatement(
            isObject(type),
            t.blockStatement([
              t.ifStatement(
                isDOMWrapper(child),
                t.blockStatement([
                  t.variableDeclaration("var", [
                    t.variableDeclarator(func, t.memberExpression(child, func)),
                    t.variableDeclarator(args, t.memberExpression(child, args))
                  ]),
                  t.ifStatement(
                    args,
                    t.blockStatement([
                      t.expressionStatement(
                        toFunctionCall(t.memberExpression(func, t.identifier("apply")), [t.thisExpression(), args]),
                      )
                    ]),
                    t.blockStatement([
                      t.expressionStatement(toFunctionCall(func, [])),
                    ]),
                  )
                ]),
                t.ifStatement(
                  isPlainObject(child),
                  t.blockStatement([
                    t.forInStatement(
                      t.variableDeclaration("var", [t.variableDeclarator(prop)]),
                      child,
                      t.ifStatement(
                        toFunctionCall(t.memberExpression(
                          hasOwn,
                          t.identifier("call")
                        ), [child, i]),
                        t.expressionStatement(toFunctionCall(ref, [
                          t.memberExpression(child, i, true)
                        ]))
                      )
                    )
                  ])
                )
              )
            ])
          )
        )
      )
    ])
  );
}
1129678
function Araxxor() {
    /**
     * Returns araxxor's current and upcoming rotations or araxxor's rotation on a lookup date (available for `rs`)
     * @param onDate {Date} [Optional] Set date to lookup (MM/dd/YYYY)
     * @returns {Promise} Array of rotation
     * @example
     * // lookup upcoming rotation order (presorted in order)
     * api.rs.boss.araxxor.getRotation().then(function(rotation) {
     *  console.log(rotation);
     * }).catch(console.error);
     *
     * // lookup the rotation for provided date
     * api.rs.boss.araxxor.getRotation('02/03/2017').then(function(rotation) {
     *  console.log(rotation);
     * }).catch(console.error);
     */
    this.getRotation = function (onDate) {
        return new Promise(function (resolve, reject) {
            var paths = {
                top: {
                    location: 'top',
                    number: Number(1),
                    characteristic: 'Minions'
                },
                middle: {
                    location: 'middle',
                    number: Number(2),
                    characteristic: 'Acid'
                },
                bottom: {
                    location: 'bottom',
                    number: Number(3),
                    characteristic: 'Darkness'
                }
            }
            var araxxorRotations = [
                paths.top,
                paths.middle,
                paths.bottom
            ];
            var rotations = [];
            if (typeof onDate !== 'undefined') {
                var now = new Date(onDate);
                var currentRotation = Math.floor((((Math.floor(Math.floor(now / 1000) / (24 * 60 * 60))) + 3) % (4 * araxxorRotations.length)) / 4);
                var daysUntilNext = 4 - ((Math.floor((now / 1000) / (24 * 60 * 60))) + 3) % (4 * araxxorRotations.length) % 4;
                var start = new Date(onDate);
                start.setDate(start.getDate() - (4 - daysUntilNext));
                var closed = araxxorRotations[currentRotation];
                var open = araxxorRotations.filter(function(rotation) {
                    return rotation != araxxorRotations[currentRotation];
                });

                var obj = {
                    rotation: {
                        open: open,
                        closed: closed
                    },
                    daysUntilNext: daysUntilNext,
                    startDate: start
                };
                rotations.push(obj);
                resolve(rotations);
                return;
            }

            for (var i = 0; i < araxxorRotations.length; i++) {
                var now = new Date();
                var daysToAdd = 4 * i;
                now.setDate(now.getDate() + daysToAdd);

                var currentRotation = Math.floor((((Math.floor(Math.floor(now / 1000) / (24 * 60 * 60))) + 3) % (4 * araxxorRotations.length)) / 4);
                var daysUntilNext = (4 - ((Math.floor((Date.now() / 1000) / (24 * 60 * 60))) + 3) % (4 * araxxorRotations.length) % 4) + daysToAdd;

                var start = new Date();
                start.setDate(start.getDate() + (daysUntilNext - 4));

                var closed = araxxorRotations[currentRotation];
                var open = araxxorRotations.filter(function(rotation) {
                    return rotation != araxxorRotations[currentRotation];
                });

                var obj = {
                    rotation: {
                        open: open,
                        closed: closed
                    },
                    daysUntilNext: daysUntilNext,
                    startDate: start
                };
                rotations.push(obj);
            }
            resolve(rotations);
        });
    }
}
815997
function addInteraction() {
  let value = typeSelect.value;
  if (value !== 'None') {
    let geometryFunction;
    if (value === 'Square') {
      value = 'Circle';
      geometryFunction = createRegularPolygon(4);
    } else if (value === 'Box') {
      value = 'Circle';
      geometryFunction = createBox();
    } else if (value === 'Star') {
      value = 'Circle';
      geometryFunction = function(coordinates, geometry) {
        const center = coordinates[0];
        const last = coordinates[1];
        const dx = center[0] - last[0];
        const dy = center[1] - last[1];
        const radius = Math.sqrt(dx * dx + dy * dy);
        const rotation = Math.atan2(dy, dx);
        const newCoordinates = [];
        const numPoints = 12;
        for (let i = 0; i < numPoints; ++i) {
          const angle = rotation + i * 2 * Math.PI / numPoints;
          const fraction = i % 2 === 0 ? 1 : 0.5;
          const offsetX = radius * fraction * Math.cos(angle);
          const offsetY = radius * fraction * Math.sin(angle);
          newCoordinates.push([center[0] + offsetX, center[1] + offsetY]);
        }
        newCoordinates.push(newCoordinates[0].slice());
        if (!geometry) {
          geometry = new Polygon([newCoordinates]);
        } else {
          geometry.setCoordinates([newCoordinates]);
        }
        return geometry;
      };
    }
    draw = new Draw({
      source: source,
      type: value,
      geometryFunction: geometryFunction
    });
    map.addInteraction(draw);
  }
}
856063
async function main () {

    let exchanges = []

    // instantiate all exchanges
    await Promise.all (ccxt.exchanges.map (async id => {
        let exchange = new (ccxt)[id] ()
        exchanges.push (exchange)
        await test (exchange, symbol)
    }))

    let succeeded = exchanges.filter (exchange => exchange.markets ? true : false).length.toString ().bright.green
    let failed = exchanges.filter (exchange => exchange.markets ? false : true).length
    let total = ccxt.exchanges.length.toString ().bright.white
    console.log (succeeded, 'of', total, 'exchanges loaded', ('(' + failed + ' errors)').red)
}
620774
function TwoDeckStandSoft17(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options)
{
    var result;
    const overrides = [
            {hand:[4,6,6], dealer: 10, action: "hit"},
            {hand:[3,6,7], dealer: 10, action: "hit"},
            {hand:[2,6,8], dealer: 10, action: "hit"},
            {hand:[1,6,9], dealer: 10, action: "hit"},
            {hand:[3,3,10], dealer: 10, action: "hit"},
            {hand:[2,2,6,6], dealer: 10, action: "hit"},
            {hand:[1,3,6,6], dealer: 10, action: "hit"},
            {hand:[1,2,6,7], dealer: 10, action: "hit"},
            {hand:[1,1,6,8], dealer: 10, action: "hit"},
            {hand:[2,2,2,10], dealer: 10, action: "hit"},
            {hand:[1,2,3,10], dealer: 10, action: "hit"},
            {hand:[4,4,4,4], dealer: 9, action: "stand"},
            {hand:[3,4,4,5], dealer: 9, action: "stand"},
            {hand:[3,3,5,5], dealer: 9, action: "stand"},
            {hand:[2,4,5,5], dealer: 9, action: "stand"},
            {hand:[1,5,5,5], dealer: 9, action: "stand"},
            {hand:[2,2,3,3,6], dealer: 10, action: "hit"},
            {hand:[1,1,1,6,7], dealer: 10, action: "hit"},
            {hand:[1,1,2,2,10], dealer: 10, action: "hit"},
            {hand:[1,1,2,6,6], dealer: 10, action: "hit"},
            {hand:[1,3,4,4,4], dealer: 9, action: "stand"},
            {hand:[2,2,4,4,4], dealer: 9, action: "stand"},
            {hand:[2,3,3,4,4], dealer: 9, action: "stand"},
            {hand:[3,3,3,3,4], dealer: 9, action: "stand"},
            {hand:[1,2,3,5,5], dealer: 9, action: "stand"},
            {hand:[1,2,4,4,5], dealer: 9, action: "stand"},
            {hand:[1,3,3,4,5], dealer: 9, action: "stand"},
            {hand:[2,2,2,5,5], dealer: 9, action: "stand"}, 
            {hand:[2,2,3,4,5], dealer: 9, action: "stand"},
            {hand:[2,3,3,3,5], dealer: 9, action: "stand"},
            {hand:[1,1,1,1,4,4], dealer: 3, action: "stand"},
            {hand:[1,1,2,4,4,4], dealer: 7, action: "stand"},
            {hand:[1,1,3,3,4,4], dealer: 7, action: "stand"},
            {hand:[1,2,2,3,4,4], dealer: 7, action: "stand"},
            {hand:[1,2,3,3,3,4], dealer: 7, action: "stand"},
            {hand:[1,3,3,3,3,3], dealer: 7, action: "stand"},
            {hand:[2,2,2,3,3,4], dealer: 7, action: "stand"},
            {hand:[2,2,3,3,3,3], dealer: 7, action: "stand"},
            {hand:[1,3,3,3,3,3], dealer: 8, action: "stand"},
            {hand:[2,2,3,3,3,3], dealer: 8, action: "stand"},
            {hand:[1,3,3,3,3,3], dealer: 9, action: "stand"},
            {hand:[2,2,3,3,3,3], dealer: 9, action: "stand"},
            {hand:[1,1,2,4,4,4], dealer: 9, action: "stand"},
            {hand:[1,1,3,3,4,4], dealer: 9, action: "stand"},
            {hand:[1,2,2,3,4,4], dealer: 9, action: "stand"},
            {hand:[1,2,3,3,3,4], dealer: 9, action: "stand"},
            {hand:[2,2,2,2,4,4], dealer: 9, action: "stand"},
            {hand:[2,2,2,3,3,4], dealer: 9, action: "stand"},
            {hand:[1,1,1,3,5,5], dealer: 9, action: "stand"},
            {hand:[1,1,1,4,4,5], dealer: 9, action: "stand"},
            {hand:[1,1,2,2,5,5], dealer: 9, action: "stand"},
            {hand:[1,1,2,3,4,5], dealer: 9, action: "stand"},
            {hand:[1,1,3,3,3,5], dealer: 9, action: "stand"},
            {hand:[1,2,2,2,4,5], dealer: 9, action: "stand"},
            {hand:[1,2,2,3,3,5], dealer: 9, action: "stand"},
            {hand:[2,2,2,2,3,5], dealer: 9, action: "stand"},
            {hand:[1,1,1,1,6,6], dealer: 10, action: "hit"},
            {hand:[1,2,2,2,3,6], dealer: 10, action: "hit"},
            {hand:[2,2,2,2,2,6], dealer: 10, action: "hit"},
        ];

    // Special case if there are two cards
    if (playerCards.length == 2)
    {
        if ((handValue.total == 11) && (dealerCard == 1) &&
            ((playerCards[0] == 2) || (playerCards[0] == 3) || (playerCards[0] == 8) || (playerCards[0] == 9)))
        {
            return "double";            
        }
        else if ((handValue.total == 12) && (dealerCard == 4) &&
                    ((playerCards[0] == 2) || (playerCards[0] == 10)))
        {
            return "hit";
        }
    }
    else // 3 or more cards
    {
        // Ace, Ace, 6 hits against dealer Ace
        if ((playerCards.length == 3) && (handValue.total == 18) && handValue.soft && (dealerCard == 1) &&
                    ((playerCards[0] == 6) || (playerCards[1] == 6) || (playerCards[2] == 6)))
        {
            return "hit";
        }
        else if ((playerCards.length == 6) || (handValue.total == 16))
        {
            result = FindExceptionInList(playerCards, dealerCard, overrides);
            if (result)
            {
                return result;
            }
        }
    
        // Three or more cards, 16 vs 10 stands and soft 18 vs Ace stands (except as noted in table which was already checked)
        if ((handValue.total == 16) && (dealerCard == 10))
        {
            return "stand";
        }
        if ((handValue.total == 18) && (handValue.soft) && (dealerCard == 1))
        {
            return "stand";
        }
    }

    return null;
 }
809909
function setbit(key, offset, value, req) {
  var buf = this.getValueBuffer(key, req, true)
    , zeros
    , pos
    , shift
    , byte
    , bit;
  if(buf === undefined) buf = new Buffer('');
  pos = Math.floor(offset / 8);
  bit = pos >= buf.length ? 0 : this.getbit(key, offset, req);

  if(pos + 1 >= buf.length) {
    zeros = new Buffer(pos + 1 - buf.length);
    zeros.fill('\u0000');
    buf = Buffer.concat([buf, zeros], buf.length + zeros.length);
  }

  shift = 7 - (offset & 0x7);
  byte = buf[pos];
  byte &= ~(1 << shift);
  byte |= ((value & 0x01) << shift);
  buf[pos] = byte;
  this.setKey(key, buf, undefined, undefined, undefined, req);
  return bit;
}
272311
function pact(command, argv) {
  const async = require('async');
  const karma = require('karma');
  const Server = karma.Server;
  const portfinder = require('portfinder');
  const url = require('url');
  const logger = require('@blackbaud/skyux-logger');

  const configResolver = require('./utils/config-resolver');
  const tsLinter = require('./utils/ts-linter');
  const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');
  const pactServers = require('../utils/pact-servers');
  let skyPagesConfig = skyPagesConfigUtil.getSkyPagesConfig(command);
  let http = require('http');
  let httpProxy = require('http-proxy');

  argv = argv || process.argv;
  argv.command = command;

  let pactPortSeries = [];
  let consumedPorts = [];
  // get a free port for every config entry, plus one for the proxy
  if (!skyPagesConfig.skyux.pacts) {
    logger.error('skyux pact failed! pacts does not exist on configuration file.');
    process.exit();
  }

  let getAsyncFunction = (callback) => {

    // ports are not consumed until karma starts, so need to keep track of future consumed ports
    portfinder.getPortPromise(
      { port: consumedPorts.length === 0 ? 8000 : Math.max(consumedPorts) + 1 }
    )
      .then((port) => {
        consumedPorts.push(port);
        callback(null, port);
      })
      .catch((error) => {
        callback(error, null);
      });

  };

  for (let i = 0; i < skyPagesConfig.skyux.pacts.length + 1; i++) {

    pactPortSeries.push(getAsyncFunction);

  }

  // make sure ports are resolved in order
  async.series(pactPortSeries,
    (err, ports) => {
      if (err) {
        logger.error(err);
        process.exit();
      }

      for (let i = 0; i < skyPagesConfig.skyux.pacts.length; i++) {

        let serverHost = (skyPagesConfig.skyux.pacts[i].host || 'localhost');
        let serverPort = (skyPagesConfig.skyux.pacts[i].port || ports[i]);
        // saving pact server information so it can carry over into karma config
        pactServers
          .savePactServer(skyPagesConfig.skyux.pacts[i].provider, serverHost, serverPort);
      }

      let proxy = httpProxy.createProxyServer({});

      // proxy requests to pact server to contain actual host url rather than the karma url
      proxy.on('proxyReq', function (proxyReq) {
        let origin;
        origin = (skyPagesConfig.skyux.host || {}).url || 'https://host.nxt.blackbaud.com';
        proxyReq.setHeader('Origin', origin);
      });
      // revert CORS header value back to karma url so that requests are successful
      proxy.on('proxyRes', function (proxyRes, req) {
        proxyRes.headers['Access-Control-Allow-Origin'] = req.headers.origin;
      });

      http.createServer((req, res) => {

        // provider is part of path so that consuming app can make requests to multiple pact
        // servers from one proxy server.  Use that value to identify proper pact server and then
        // remove from request url.
        let provider = url.parse(req.url).pathname.split('/')[1];
        req.url = req.url.split(provider)[1];
        if (Object.keys(pactServers.getAllPactServers()).indexOf(provider) !== -1) {
          proxy.web(req, res, {
            target: pactServers.getPactServer(provider).fullUrl
          });
        } else {
          logger
            .error(`Pact proxy path is invalid.  Expected format is base/provider-name/api-path.`);
        }
      })
        .on('connect', () => {
          logger
            .info(
            `Pact proxy server successfully started on http://localhost:${ports[ports.length - 1]}`
            );
        })
        .listen(ports[ports.length - 1], 'localhost');

      // for use by consuming app
      pactServers.savePactProxyServer(`http://localhost:${ports[ports.length - 1]}`);

      const karmaConfigUtil = karma.config;
      const karmaConfigPath = configResolver.resolve(command, argv);
      const karmaConfig = karmaConfigUtil.parseConfig(karmaConfigPath);

      let lintResult;

      const onRunStart = () => {
        lintResult = tsLinter.lintSync();
      };

      const onRunComplete = () => {
        if (lintResult && lintResult.exitCode > 0) {
          // Pull the logger out of the execution stream to let it print
          // after karma's coverage reporter.
          setTimeout(() => {
            logger.error('Process failed due to linting errors:');
            lintResult.errors.forEach(error => logger.error(error));
          }, 10);
        }
      };

      const onExit = (exitCode) => {
        if (exitCode === 0) {
          if (lintResult) {
            exitCode = lintResult.exitCode;
          }
        }

        logger.info(`Karma has exited with ${exitCode}.`);
        process.exit(exitCode);
      };

      const server = new Server(karmaConfig, onExit);
      server.on('run_start', onRunStart);
      server.on('run_complete', onRunComplete);
      server.start();
    });

}
1106779
function merkle (values, digestFn) {
  if (!Array.isArray(values)) throw TypeError('Expected values Array')
  if (typeof digestFn !== 'function') throw TypeError('Expected digest Function')
  if (values.length === 1) return values.concat()

  var levels = [values]
  var level = values

  do {
    level = _derive(level, digestFn)
    levels.push(level)
  } while (level.length > 1)

  return [].concat.apply([], levels)
}
1151447
async function () {
    const oThis = this
    ;

    // validations
    if (!basicHelper.isNonZeroWeiValid(oThis.amountToStakeInWeis)) {
      logger.error('Invalid amount');
      process.exit(1);
    }

    // Format to big number
    oThis.amountToStakeInWeis = basicHelper.convertToBigNumber(oThis.amountToStakeInWeis);

    const amountToStakeForBT = ((oThis.amountToStakeInWeis.mul(0.9)).minus(oThis.amountToStakeInWeis.mul(0.9).modulo(1)))
      , amountToStakeForSTP = oThis.amountToStakeInWeis.minus(amountToStakeForBT)
      , stPrimeUuid = coreConstants.OST_OPENSTUTILITY_ST_PRIME_UUID
    ;

    // validations
    if (!basicHelper.isNonZeroWeiValid(amountToStakeForBT)) {
      logger.error('Invalid wei amount to stake for BT', amountToStakeForBT.toString(10));
      process.exit(1);
    }
    if (!basicHelper.isNonZeroWeiValid(amountToStakeForSTP)) {
      logger.error('Invalid wei amount to stake for ST Prime', amountToStakeForSTP.toString(10));
      process.exit(1);
    }

    logger.step('** Starting stake mint for branded token for beneficiary reserve of BT Reserve:', oThis.reserveAddr);

    // NOTE: In real case, Member Company transfers ST to staker and then approve is called. To simulate this, foundation
    // is transfering ST to staker.
    logger.info('* Foundation transfers ST to BT Reserve');
    await fundManager.transferST(
        foundationAddr, foundationPassphrase, stakerAddr, oThis.amountToStakeInWeis,
        {tag: 'transferSTToBTReserve', returnType: 'txReceipt'}
    );

    logger.info('* Staker approves openSTValue contract');
    const approveResponse = await (new approveService()).perform();
    if (approveResponse.isFailure()) {
      process.exit(1);
    }

    const approveTransactionHash = approveResponse.data.transaction_hash;

    logger.info('* Get approval status and keep doing so till success');
    const approveReceiptResponse =  await contractInteractHelper.waitAndGetTransactionReceipt(web3Provider, approveTransactionHash, {});
    if (!approveReceiptResponse.isSuccess()) {
      logger.error('Approval receipt error ', approveReceiptResponse);
      process.exit(1);
    }

    logger.info('* Start stake for Branded Token');
    await (new startStakeService({
      beneficiary: oThis.reserveAddr,
      to_stake_amount: amountToStakeForBT,
      uuid: oThis.brandedTokenUuid
    })).perform();

    logger.info('* Waiting for credit of Branded Token to BT Reserve');
    await oThis._waitForBrandedTokenMint();

    logger.info('* Start stake for Simple Token Prime');
    await (new startStakeService({
      beneficiary: oThis.reserveAddr,
      to_stake_amount: amountToStakeForSTP,
      uuid: stPrimeUuid
    })).perform();

    logger.info('* Waiting for credit of Simple Token Prime to BT Reserve');
    await oThis._waitForSimpleTokenPrimeMint();

    return Promise.resolve(responseHelper.successWithData({}));
  }
468850
function (scope, sender) {
/*Line 31 - 'AtomWindow.js' */                AtomBinder.setValue(this, "isOpen", false);
/*Line 32 - 'AtomWindow.js' */                var val = this._value;
/*Line 33 - 'AtomWindow.js' */                var caller = this;
/*Line 34 - 'AtomWindow.js' */                this._value = null;

/*Line 36 - 'AtomWindow.js' */                WebAtoms.dispatcher.callLater(function () {
/*Line 37 - 'AtomWindow.js' */                    AtomBinder.setValue(caller, "value", val);
/*Line 38 - 'AtomWindow.js' */                    caller.invokeAction(caller._next);
/*Line 39 - 'AtomWindow.js' */                    caller.disposeChildren(caller._element);
/*Line 40 - 'AtomWindow.js' */                });
/*Line 41 - 'AtomWindow.js' */            }
455935
function(payload, callback) {
    var alice, bob, aliceChannel, bobChannel,
      aliceCandidates = [],
      aliceOffer;
    alice = peercon();
    bob = peercon();
    bob.on('ondatachannel', function (msg) {
      bobChannel = datachan(msg.channel);
      bobChannel.setBinaryType('arraybuffer', function () {});
      bobChannel.on('onmessage', function (msg) {
        alice.close();
        bob.close();
        callback(msg);
      });
    });
    bob.on('onicecandidate', function (msg) {
      msg.candidate && alice.addIceCandidate(msg.candidate);
    });
    alice.on('onicecandidate', function (msg) {
      // firefox needs ice candidates all sent before asking for an answer.
      if (!msg.candidate) {
        bob.setRemoteDescription(aliceOffer).then(function () {
          var last;
          while (aliceCandidates.length) {
            last = bob.addIceCandidate(aliceCandidates.shift());
          }
          return last;
        }).then(function () {
          return bob.createAnswer();
        }).then(function (answer) {
          return bob.setLocalDescription(answer).then(function () {return answer; });
        }).then(function (answer) {
          return alice.setRemoteDescription(answer);
        }, function (err) {
          console.error('RTC failed: ', err);
        });
      } else {
        aliceCandidates.push(msg.candidate);
      }
    });
    alice.createDataChannel('channel').then(function (id) {
      aliceChannel = datachan(id);
      aliceChannel.on('onopen', function () {
        if (payload instanceof ArrayBuffer) {
          aliceChannel.sendBuffer(payload);
        } else {
          aliceChannel.send(payload);
        }
      });
      aliceChannel.setBinaryType('arraybuffer').then(function () {
        return alice.createOffer();
      }).then(function (offer) {
        alice.setLocalDescription(offer);
        aliceOffer = offer;
      });
    }, function (err) {
      console.error('RTC failed: ', err);
    });
  }
826153
def arbiter(**params):
    '''
    '''
    arbiter = get_actor()
    if arbiter is None:
        # Create the arbiter
        return set_actor(_spawn_actor('arbiter', None, **params))
    elif arbiter.is_arbiter():
        return arbiter
373755
function Broker(options) {
  EventEmitter.call(this);
  this._exchange = null;
  this._queues = {};
  this._ctags = {};
  
  this._options = options;
}
792426
function() {

    var _buffer = new Array();
    var _length = 0;

    var _this = {};

    _this.getBuffer = function() {
	return _buffer;
    };

    _this.getAt = function(index) {
	var bufIndex = Math.floor(index / 8);
	return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
    };

    _this.put = function(num, length) {
	for (var i = 0; i < length; i += 1) {
	    _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
	}
    };

    _this.getLengthInBits = function() {
	return _length;
    };

    _this.putBit = function(bit) {

	var bufIndex = Math.floor(_length / 8);
	if (_buffer.length <= bufIndex) {
	    _buffer.push(0);
	}

	if (bit) {
	    _buffer[bufIndex] |= (0x80 >>> (_length % 8) );
	}

	_length += 1;
    };

    return _this;
}
1108787
function baseCreateWrapper(data) {
      var func = data[0],
          bitmask = data[1],
          arity = data[2],
          thisArg = data[3],
          partialArgs = data[4],
          partialRightArgs = data[5],
          partialHolders = data[6],
          partialRightHolders = data[7];

      var isBind = bitmask & BIND_FLAG,
          isBindKey = bitmask & BIND_KEY_FLAG,
          isCurry = bitmask & CURRY_FLAG,
          isCurryBound = bitmask & CURRY_BOUND_FLAG,
          key = func;

      function bound() {
        var thisBinding = isBind ? thisArg : this;
        if (partialArgs) {
          var args = composeArgs(partialArgs, partialHolders, arguments);
        }
        if (partialRightArgs) {
          args = composeArgsRight(partialRightArgs, partialRightHolders, args || arguments);
        }
        if (isCurry) {
          var argsLength = arguments.length;
          if (argsLength < arity) {
            args || (args = slice(arguments));
            bitmask |= PARTIAL_FLAG;
            bitmask &= ~PARTIAL_RIGHT_FLAG
            if (!isCurryBound) {
              bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
            }
            var newArity = nativeMax(0, arity - argsLength);
            return baseCreateWrapper([func, bitmask, newArity, thisArg, args, null, []]);
          }
        }
        args || (args = arguments);
        if (isBindKey) {
          func = thisBinding[key];
        }
        if (this instanceof bound) {
          thisBinding = baseCreate(func.prototype);
          var result = func.apply(thisBinding, args);
          return isObject(result) ? result : thisBinding;
        }
        return func.apply(thisBinding, args);
      }
      setData(bound, data);
      return bound;
    }
378747
function ValueStatGetter(model, params, options) {
  BaseStatGetter.call(this, model, params, options);

  var OPERATORS = new Operators(options);

  var schema = Interface.Schemas.schemas[model.name];
  function getAggregate() {
    return params.aggregate.toLowerCase();
  }

  function getAggregateField() {
    // NOTICE: As MySQL cannot support COUNT(table_name.*) syntax, fieldName
    //         cannot be '*'.
    var fieldName = params['aggregate_field'] || schema.primaryKeys[0]||
      schema.fields[0].field;
    return schema.name + '.' + fieldName;
  }

  function getIncludes() {
    var includes = [];
    _.values(model.associations).forEach(function (association) {
      if (['HasOne', 'BelongsTo'].indexOf(association.associationType) > -1) {
        includes.push({
          model: association.target.unscoped(),
          as: association.associationAccessor,
          attributes: []
        });
      }
    });

    return includes;
  }

  function getIntervalDateFilterForPrevious() {
    var intervalDateFilter;

    params.filters.forEach(function (filter) {
      var operatorValueParser =
        new OperatorDateIntervalParser(filter.value, params.timezone, options);
      if (operatorValueParser.hasPreviousInterval()) {
        intervalDateFilter = filter;
      }
    });
    return intervalDateFilter;
  }

  this.perform = function () {
    var countCurrent;
    var aggregateField = getAggregateField();
    var aggregate = getAggregate();
    var filters = this.getFilters();
    var filterDateIntervalForPrevious = getIntervalDateFilterForPrevious();

    return model
      .unscoped()
      .aggregate(aggregateField, aggregate, {
        include: getIncludes(),
        where: filters
      })
      .then(function (count) {
        countCurrent = count || 0;

        // NOTICE: Search for previous interval value only if the filterType is
        //         'AND', it would not be pertinent for a 'OR' filterType.
        if (filterDateIntervalForPrevious && params.filterType === 'and') {
          var operatorValueParser = new OperatorDateIntervalParser(
            filterDateIntervalForPrevious.value, params.timezone, options
          );
          var conditions = filters[OPERATORS.AND];
          conditions.forEach(function (condition) {
            if (condition[filterDateIntervalForPrevious.field]) {
              condition[filterDateIntervalForPrevious.field] =
                operatorValueParser.getIntervalDateFilterForPreviousInterval();
            }
          });
          return model
            .unscoped()
            .aggregate(aggregateField, aggregate, {
              include: getIncludes(),
              where: filters
            })
            .then(function (count) { return count || 0; });
        }
        return undefined;
      })
      .then(function (countPrevious) {
        return {
          value: {
            countCurrent: countCurrent,
            countPrevious: countPrevious
          }
        };
      });
  };
}