Async function required for us to use await
332820
async function runExample() {
	let browser;
	let pages;
	try {

		// Launch our own browser
		browser = await puppeteer.launch();

		// Create a page for the test runs
		// (Pages cannot be used in multiple runs)
		pages = [
			await browser.newPage(),
			await browser.newPage()
		];

		// Test http://example.com/ with our shared browser
		const result1 = await pa11y('http://example.com/', {
			browser: browser,
			page: pages[0]
		});

		// Test http://example.com/otherpage/ with our shared browser
		const result2 = await pa11y('http://example.com/otherpage/', {
			browser: browser,
			page: pages[1]
		});

		// Output the raw result objects
		console.log(result1);
		console.log(result2);

		// Close the browser instance and pages now we're done with it
		for (const page of pages) {
			await page.close();
		}
		await browser.close();

	} catch (error) {

		// Output an error if it occurred
		console.error(error.message);

		// Close the browser instance and pages if theys exist
		if (pages) {
			for (const page of pages) {
				await page.close();
			}
		}
		if (browser) {
			await browser.close();
		}

	}
}
89578
async function() {
    const oThis = this
    ;
    logger.step("** Starting BT proposal");
    logger.info("* Name:", oThis.btName, "Symbol:", oThis.btSymbol, "Conversion Factor:", oThis.btConversionFactor);
    const proposeBTObj = new proposeBrandedToken(
      {name: oThis.btName, symbol: oThis.btSymbol, conversion_factor: oThis.btConversionFactor}
    );
    const proposeBTResponse = await proposeBTObj.perform();
    if (proposeBTResponse.isFailure()) {
      logger.error("* Proposal failed with error:", proposeBTResponse);
      process.exit(1);
    }
    return Promise.resolve(proposeBTResponse);
  }
207320
async function (events) {
    const oThis = this
      , promiseArray = []
    ;

    // nothing to do
    if (!events || events.length === 0) {
      oThis.updateIntercomDataFile();
      return Promise.resolve();
    }

    //TODO: last processed transaction index.
    for (var i = 0; i < events.length; i++) {
      const eventObj = events[i]
        , j = i
      ;

      // await oThis.processEventObj(eventObj);

      if (oThis.parallelProcessingAllowed()) {
        promiseArray.push(new Promise(function (onResolve, onReject) {
          setTimeout(function () {
            oThis.processEventObj(eventObj)
              .then(onResolve)
              .catch(function (error) {
                logger.error('##### inside catch block #####: ', error);
                return onResolve();
              });
          }, (j * 1000 + 100));
        }));
      } else {
        await oThis.processEventObj(eventObj)
          .catch(function (error) {
            logger.error('inside catch block: ', error);
            return Promise.resolve();
          });
      }
    }

    if (oThis.parallelProcessingAllowed()) {
      await Promise.all(promiseArray);
    }

    oThis.updateIntercomDataFile();
    return Promise.resolve();
  }
765448
function asyncMap(array, iterator, done) {
  if (!array || !array.length) {
    return done(null, [])
  }

  var error
    , out = []
    , todo = array.length

  array.forEach(exec)

  function exec(item) {
    process.nextTick(function tick() {
      iterator(item, add)
    })
  }

  function add(err, data) {
    if (error) {
      return
    }
    else if (err) {
      error = true
      return done(err)
    }

    out.push(data)

    if (--todo === 0) {
      done(null, out)
    }
  }
}
1100852
function wait(ms = 0) {
  return function(val) {
    return new Promise(resolve => setTimeout(_ => resolve(val), ms));
  };
}
668764
async function () {
    const oThis = this
    ;

    try {

      // validations
      if (!basicHelper.isTxHashValid(oThis.transactionHash)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_t_gr_1',
          api_error_identifier: 'invalid_transaction_hash',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }

      const web3Provider = web3ProviderFactory.getProvider(oThis.chain, web3ProviderFactory.typeWS);
      if (!web3Provider) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_t_gr_2',
          api_error_identifier: 'invalid_chain',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }

      const txReceipt = await web3Provider.eth.getTransactionReceipt(oThis.transactionHash);

      if (!txReceipt) {
        return Promise.resolve(responseHelper.successWithData({}));
      } else {
        const web3EventsDecoderResponse = web3EventsDecoder.perform(txReceipt, oThis.addressToNameMap);
        return Promise.resolve(web3EventsDecoderResponse);
      }

    } catch (err) {
      let errObj = responseHelper.error({
        internal_error_identifier: 's_t_gr_4',
        api_error_identifier: 'something_went_wrong',
        error_config: basicHelper.fetchErrorConfig()
      });
      return Promise.resolve(errObj);
    }
  }
767832
function awaitFunctionCall() {
                let func;
                const promise = new Promise((resolve, reject) => {
                    func = function(...args) {
                        resolve(args);
                        return new Promise((resolve, reject) => {
                            // give us some time to process the result before
                            // continuing
                            global.setTimeout(resolve, 1);
                        });
                    };
                });
                return {func, promise};
            }
164079
function getLatencyAndWait() {
      var result = null;

      if (isDestroyed) {
        return Promise.resolve(result);
      }

      return getLatency(slave)
          .then(function (latency) { result = latency })  // store the retrieved latency
          .catch(function (err)    { console.log(err) })  // just log failed requests
          .then(function () { return util.wait(DELAY) })  // wait 1 sec
          .then(function () { return result});            // return the retrieved latency
    }
149190
async function init () {
  try {
    await sequelize.sync()
  } catch (err) {
    console.log(err)
    process.exit(-1)
  }
}
743814
async function () {
    const oThis = this
    ;

    //Validations
    if (!basicHelper.isAddressValid(oThis.erc20Address)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 's_a_bt_2',
        api_error_identifier: 'invalid_address',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.reject(errObj);
    }

    if (!basicHelper.isAddressValid(oThis.approverAddress)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 's_a_bt_3',
        api_error_identifier: 'invalid_address',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.reject(errObj);
    }

    if (oThis.toApproveAmount.lessThan(0)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 's_a_bt_4',
        api_error_identifier: 'invalid_amount',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.reject(errObj);
    }

    return Promise.resolve(responseHelper.successWithData({}));
  }
392900
async function(symbol = false) {
            let parameters = symbol ? {symbol:symbol} : {};
            return await request('/v3/openOrders', parameters, {type: 'SIGNED'});
        }
791565
function async(callback)
{
  var isAsync = false;

  // check if async happened
  defer(function() { isAsync = true; });

  return function async_callback(err, result)
  {
    if (isAsync)
    {
      callback(err, result);
    }
    else
    {
      defer(function nextTick_callback()
      {
        callback(err, result);
      });
    }
  };
}
526987
async function () {
    const oThis = this
    ;

    try {
      const stakerAddress = coreAddresses.getAddressForUser('staker')
        , stakerPassphrase = coreAddresses.getPassphraseForUser('staker');

      // Validations
      if (!basicHelper.isAddressValid(stakerAddress) || !stakerPassphrase) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_1',
          api_error_identifier: 'invalid_staker_details',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }
      if (!basicHelper.isAddressValid(oThis.beneficiary)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_2',
          api_error_identifier: 'invalid_beneficiary_details',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }
      if (!basicHelper.isUuidValid(oThis.uuid)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_3',
          api_error_identifier: 'invalid_branded_token_uuid',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }
      if (!basicHelper.isNonZeroWeiValid(oThis.toStakeAmount)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_4',
          api_error_identifier: 'invalid_amount',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }

      // Format wei
      oThis.toStakeAmount = basicHelper.formatWeiToString(oThis.toStakeAmount);

      const stakeTransactionHash = await openSTValueContractInteract.stake(stakerAddress, stakerPassphrase, oThis.uuid,
        oThis.toStakeAmount, oThis.beneficiary, true);

      return Promise.resolve(responseHelper.successWithData({
        transaction_uuid: uuid.v4(),
        transaction_hash: stakeTransactionHash
      }));

    } catch (err) {
      let errObj = responseHelper.error({
        internal_error_identifier: 's_sam_ss_5',
        api_error_identifier: 'something_went_wrong',
        error_config: basicHelper.fetchErrorConfig()
      });
      return Promise.resolve(errObj);
    }
  }
531918
function sync() {
    // retrieve latency, then wait 1 sec
    function getLatencyAndWait() {
      var result = null;

      if (isDestroyed) {
        return Promise.resolve(result);
      }

      return getLatency(slave)
          .then(function (latency) { result = latency })  // store the retrieved latency
          .catch(function (err)    { console.log(err) })  // just log failed requests
          .then(function () { return util.wait(DELAY) })  // wait 1 sec
          .then(function () { return result});            // return the retrieved latency
    }

    return util
        .repeat(getLatencyAndWait, REPEAT)
        .then(function (all) {
          debug('latencies', all);

          // filter away failed requests
          var latencies = all.filter(function (latency) {
            return latency !== null;
          });

          // calculate the limit for outliers
          var limit = stat.median(latencies) + stat.std(latencies);

          // filter away outliers: all latencies largereq than the mean+std
          var filtered = latencies.filter(function (latency) {
            return latency < limit;
          });

          // return the mean latency
          return (filtered.length > 0) ? stat.mean(filtered) : null;
        })
        .then(function (latency) {
          if (isDestroyed) {
            return Promise.resolve(null);
          }
          else {
            return slave.request('time').then(function (timestamp) {
              var time = timestamp + latency;
              slave.emit('change', time);
              return time;
            });
          }
        })
        .catch(function (err) {
          slave.emit('error', err)
        });
  }
101459
async function () {
    const oThis = this
      , brandedToken = new BrandedTokenKlass({ERC20: oThis.erc20Address})
      , isTxHashOnlyNeeded = (oThis.returnType === 'txHash')
    ;

    const r = await brandedToken.approve(
      oThis.approverAddress,
      oThis.approverPassphrase,
      oThis.approveeAddress,
      oThis.toApproveAmount,
      isTxHashOnlyNeeded // we need this to be done in async and not to wait for the tx to get mined.
    );

    return Promise.resolve(r);
  }
817301
function async(fn) {
  return function asynced(done) {
    var err, ret;
    try {
      ret = fn();
    } catch (e) {
      err = e;
    } finally {
      if (err) {
        done(err);
      } else {
        done(null, ret);
      }
    }
  };
}
1034275
function asyncFunction(a, b, callback) {
    process.nextTick(function(){
        callback(null, a + b);
    })
}