How to use the promise-polyfill.default function in promise-polyfill

To help you get started, we’ve selected a few promise-polyfill 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 observable-playground / observable-playground / src / core / mock-delayed-execution / mock-delayed-execution.js View on Github external
};
}
// }}}

// NOTE: This polyfill is needed to mock original Promise, because original is
// **async**, while we need it to be **sync** when executing code.

// This particular implementation from ["promise-polyfill":
// "8.1.0"](https://github.com/taylorhakes/promise-polyfill) stores links to
// `setTimeout` and usage of `setImmediate` in scope. and uses
// Promise._immediateFn to execute tasks.

// Substituting this method to make it sync while executing user code. source:
// https://github.com/taylorhakes/promise-polyfill/blob/master/src/index.js#L225
if (typeof window !== 'undefined') {
    glob.Promise = require('promise-polyfill').default;
    glob.Promise._immediateFn = (fn) => {
        if (isMockMode) {
            return setTimeout(fn, 0);
        }

        if (typeof setImmediate == 'function') {
            return setImmediate(fn);
        }

        return setTimeout(fn, 0);
    }
}

/**
 * Runs a function within mocked env
 * 
github texastribune / data-visuals-create / templates / __common__ / config / legacy-polyfills.js View on Github external
'use strict';

if (typeof Promise === 'undefined') {
  window.Promise = require('promise-polyfill').default;
}

// Only polyfill fetch() if we're in a browser
if (typeof window !== 'undefined') {
  require('whatwg-fetch');
}

// Will use the native implementation if it's not bad
Object.assign = require('object-assign');

// Support for...of (a commonly used syntax feature that requires Symbols)
require('core-js/es6/symbol');
// support all of Map()
require('core-js/es6/map');
// support all of Set()
require('core-js/es6/set');
github adobe / reactor-turbine / coreModulePackages / promise / index.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 ****************************************************************************************/
'use strict';

// For building Turbine we are using Rollup. For running the turbine tests we are using
// Karma + Webpack. You need to specify the default import when using promise-polyfill`
// with Webpack 2+. We need `require('promise-polyfill').default` for running the tests
// and `require('promise-polyfill')` for building Turbine.
module.exports =
  (typeof window !== 'undefined' && window.Promise) ||
  (typeof global !== 'undefined' && global.Promise) ||
  require('promise-polyfill').default ||
  require('promise-polyfill');
github paypal / paypal-card-components / vendor / braintree-web / lib / promise.js View on Github external
'use strict';

var Promise = global.Promise || require('promise-polyfill').default;

module.exports = Promise;
github preactjs / preact-cli / packages / cli / lib / lib / webpack / polyfills.js View on Github external
if (!global.Promise) global.Promise = require('promise-polyfill').default;
if (!global.fetch) global.fetch = require('isomorphic-unfetch');