Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Promise from 'promise-polyfill';
var root = typeof window === 'undefined' ? global : window;
function PromiseMock() {
Promise.apply(this, arguments);
}
PromiseMock.prototype = Object.create(Promise.prototype);
Object.keys(Promise).forEach(function (key) {
PromiseMock[key] = Promise[key];
});
// Queue of waiting callbacks
PromiseMock.waiting = [];
/**
* Execute a pending Promise
*/
PromiseMock.run = function run(count) {
var runTimes = count ? count : 1;
if (PromiseMock.waiting.length === 0) {
throw new Error('No Promises waiting. Can\'t Promise.run()')