How to use core-js - 10 common examples

To help you get started, we’ve selected a few core-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prebid / Prebid.js / test / spec / unit / pbjs_api_spec.js View on Github external
it('marks the winning bid object as used for the given adUnitCode', function () {
      // make sure the auction has "state" and does not reload the fixtures
      const adUnitCode = '/19968336/header-bid-tag-0';
      const bidsReceived = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode);
      auction.getBidsReceived = function() { return bidsReceived.bids };

      // mark the bid and verify the state has changed to RENDERED
      const winningBid = targeting.getWinningBids(adUnitCode)[0];
      $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode });
      const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids,
        bid => bid.adId === winningBid.adId);

      expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED);
      resetAuction();
    });
github prebid / Prebid.js / test / spec / modules / eplanningAnalyticsAdapter_spec.js View on Github external
ad: 'adContent',
        auctionId: pauctionId,
        width: 300,
        height: 250
      });

      // Step 6: Send auction end event
      events.emit(constants.EVENTS.AUCTION_END, {auctionId: pauctionId});

      // Step 7: Find the request data sent (filtering other hosts)
      requests = requests.filter(req => {
        return req.url.indexOf(initOptions.host) > -1;
      });
      expect(requests.length).to.equal(1);

      expect(includes([initOptions.host + initOptions.ci], requests[0].url));
      expect(includes(['https://ads.ar.e-planning.net/hba/1/12345?d='], requests[0].url));

      let info = requests[0].url;
      let purl = parseURL(info);
      let eplData = JSON.parse(decodeURIComponent(purl.search.d));

      // Step 8 check that 6 events were sent
      expect(eplData.length).to.equal(6);

      // Step 9 verify that we only receive the parameters we need
      let expectedEventValues = [
        // AUCTION INIT
        {ec: constants.EVENTS.AUCTION_INIT,
          p: {auctionId: pauctionId, time: auctionTimestamp}},
        // BID REQ
        {ec: constants.EVENTS.BID_REQUESTED,
github microsoft / BotFramework-WebChat / packages / core / src / __tests__ / connectSaga.spec.js View on Github external
beforeEach(() => {
  const sagaMiddleware = createSagaMiddleware();

  store = createStore(
    ({ actionTypes = [] } = {}, { type }) =>
      /^DIRECT_LINE\/(DIS|RE)?CONNECT/u.test(type)
        ? // We are only interested in CONNECT_*, RECONNECT_*, and DISCONNECT_* actions.
          { actionTypes: [...actionTypes, type] }
        : { actionTypes },
    applyMiddleware(sagaMiddleware)
  );

  sagaMiddleware.run(connectSaga);

  directLine = {
    activity$: new Observable(() => () => 0),
    connectionStatus$: new Observable(observer => {
      connectionStatusObserver = observer;
      observer.next(0);
    }),
    end: () => 0,
    postActivity: () =>
      new Observable(observer => {
        observer.next({ id: '' });
      })
  };
});
github microsoft / BotFramework-WebChat / packages / core / src / __tests__ / connectSaga.spec.js View on Github external
const sagaMiddleware = createSagaMiddleware();

  store = createStore(
    ({ actionTypes = [] } = {}, { type }) =>
      /^DIRECT_LINE\/(DIS|RE)?CONNECT/u.test(type)
        ? // We are only interested in CONNECT_*, RECONNECT_*, and DISCONNECT_* actions.
          { actionTypes: [...actionTypes, type] }
        : { actionTypes },
    applyMiddleware(sagaMiddleware)
  );

  sagaMiddleware.run(connectSaga);

  directLine = {
    activity$: new Observable(() => () => 0),
    connectionStatus$: new Observable(observer => {
      connectionStatusObserver = observer;
      observer.next(0);
    }),
    end: () => 0,
    postActivity: () =>
      new Observable(observer => {
        observer.next({ id: '' });
      })
  };
});
github edu-sharing / Edu-Sharing / Frontend / src / app / common / services / cordova.service.ts View on Github external
if(this.isRunningCordova()) {
        // deviceready may not work, because cordova is already loaded, so try to set it ready after some time
        setTimeout(() => this.deviceIsReady = true, 1000);
    }
    //adding listener for cordova events
    document.addEventListener('deviceready', () => {
      this.deviceIsReady = true;
    }, false);
    document.addEventListener('pause', whenDeviceGoesBackground, false);
    document.addEventListener('resume', whenDeviceGoesForeground, false);

    // just for simulation on forced cordova mode
    if ((this.forceCordovaMode) && (!this.isReallyRunningCordova())) {
      console.log("SIMULATED deviceready event in FORCED CORDOVA MODE (just use during development)");
      setTimeout(this.whenDeviceIsReady,500+Math.random()*1000);
    } else if(this.isReallyRunningCordova()) {
      this.deviceReadyLoop(1);
    }

  }
github edu-sharing / Edu-Sharing / Frontend / src / app / common / services / cordova.service.ts View on Github external
* ignore pauses under 1 minute that appear when going into
       * a plugin (camera) or you get a permission request from the OS
       */
      if (this.appGoneBackgroundTS==null) return;
      if ((Date.now()-this.appGoneBackgroundTS)<(60*1000)) return;

      // OK - real pasuse detected
      console.log("CordovaService: App comes back from Background");

      // call listener if set
      if (this.deviceResumeCallback!=null) this.deviceResumeCallback();
    };

    if(this.isRunningCordova()) {
        // deviceready may not work, because cordova is already loaded, so try to set it ready after some time
        setTimeout(() => this.deviceIsReady = true, 1000);
    }
    //adding listener for cordova events
    document.addEventListener('deviceready', () => {
      this.deviceIsReady = true;
    }, false);
    document.addEventListener('pause', whenDeviceGoesBackground, false);
    document.addEventListener('resume', whenDeviceGoesForeground, false);

    // just for simulation on forced cordova mode
    if ((this.forceCordovaMode) && (!this.isReallyRunningCordova())) {
      console.log("SIMULATED deviceready event in FORCED CORDOVA MODE (just use during development)");
      setTimeout(this.whenDeviceIsReady,500+Math.random()*1000);
    } else if(this.isReallyRunningCordova()) {
      this.deviceReadyLoop(1);
    }
github teleport / autocomplete / js / autocomplete.js View on Github external
constructor({
    el = null, value, maxItems = 10, itemTemplate = ITEM_TEMPLATE,
    geoLocate = true, apiRoot = 'https://api.teleport.org/api', apiVersion = 1,
    embeds = 'city:country,city:admin1_division,city:timezone/tz:offsets-now,city:urban_area',
  } = {}) {
    events(this);

    const elem = (typeof el === 'string') ? document.querySelector(el) : el;
    this.setupInput(elem);

    assign(this, {
      maxItems, geoLocate, apiRoot, apiVersion, itemTemplate, embeds, results: [],
      _activeIndex: 0, _cache: {}, _query: this.el.value, value,
    });

    // Prefetch results
    if (this.value && this.value.title) {
      this.query = this.value.title;
    } else if (this.query) {
      this.fetchResults(() => {
        this.value = this.getResultByTitle(this.query);
        this.emit('change', this.value);
      });
    }

    this.getCities = debounce(this.getCities, 200);
    return this;
github microsoft / BotBuilder-Samples / samples / javascript_es6 / 01.browser-echo / src / webChatAdapter.ts View on Github external
constructor() {
        super();

        this.botConnection = {
            connectionStatus$: new Observable(observer => {
                observer.next(ConnectionStatus.Uninitialized);
                observer.next(ConnectionStatus.Connecting);
                observer.next(ConnectionStatus.Online);
            }),
            activity$: new Observable(observer => {
                this.activityObserver = observer;
            }),
            end() {
                // The React component was called to unmount:
                // https://github.com/Microsoft/BotFramework-WebChat/blob/57360e4df92e041d5b0fd4810c1abf96621b5283/src/Chat.tsx#L237-L247
                // Developers will need to decide what behavior the component should implement.
                // For this sample, this.botConnection.componentWillUnmount() and this.botConnection.end()
                // is never called.
                console.log('this.botConnection.componentWillUnmount() called.');
            },
            getSessionId: () => new Observable(observer => observer.complete()),
github microsoft / BotBuilder-Samples / samples / javascript_es6 / 01.browser-echo / src / webChatAdapter.ts View on Github external
constructor() {
        super();

        this.botConnection = {
            connectionStatus$: new Observable(observer => {
                observer.next(ConnectionStatus.Uninitialized);
                observer.next(ConnectionStatus.Connecting);
                observer.next(ConnectionStatus.Online);
            }),
            activity$: new Observable(observer => {
                this.activityObserver = observer;
            }),
            end() {
                // The React component was called to unmount:
                // https://github.com/Microsoft/BotFramework-WebChat/blob/57360e4df92e041d5b0fd4810c1abf96621b5283/src/Chat.tsx#L237-L247
                // Developers will need to decide what behavior the component should implement.
                // For this sample, this.botConnection.componentWillUnmount() and this.botConnection.end()
                // is never called.
                console.log('this.botConnection.componentWillUnmount() called.');
            },
            getSessionId: () => new Observable(observer => observer.complete()),
            postActivity: activity => {
                const id = Date.now().toString();

                return new Observable(observer => {
                    const serverActivity = {
github prebid / Prebid.js / modules / adpod.js View on Github external
let bidDuration = utils.deepAccess(bidResponse, 'video.durationSeconds');
  let videoConfig = utils.deepAccess(bidderRequest, 'mediaTypes.video');
  let adUnitRanges = videoConfig.durationRangeSec;
  adUnitRanges.sort((a, b) => a - b); // ensure the ranges are sorted in numeric order

  if (!videoConfig.requireExactDuration) {
    let max = Math.max(...adUnitRanges);
    if (bidDuration <= (max + buffer)) {
      let nextHighestRange = find(adUnitRanges, range => (range + buffer) >= bidDuration);
      bidResponse.video.durationBucket = nextHighestRange;
    } else {
      utils.logWarn(`Detected a bid with a duration value outside the accepted ranges specified in adUnit.mediaTypes.video.durationRangeSec.  Rejecting bid: `, bidResponse);
      return false;
    }
  } else {
    if (find(adUnitRanges, range => range === bidDuration)) {
      bidResponse.video.durationBucket = bidDuration;
    } else {
      utils.logWarn(`Detected a bid with a duration value not part of the list of accepted ranges specified in adUnit.mediaTypes.video.durationRangeSec.  Exact match durations must be used for this adUnit. Rejecting bid: `, bidResponse);
      return false;
    }
  }
  return true;
}