use promise polyfill

This commit is contained in:
Leo Horie 2016-06-01 15:44:08 -04:00
parent b2b0ab34dd
commit 9a396c5173
2 changed files with 96 additions and 95 deletions

View file

@ -1,5 +1,6 @@
"use strict"
var Promise = require("./promise/promise")
var m = require("./render/hyperscript")
var renderService = require("./render/render")(window)
var redrawService = require("./api/pubsub")()

View file

@ -1,8 +1,9 @@
"use strict"
{
function Promise(executor) {
if (typeof Promise === "undefined") {
var Promise = function(executor) {
if (!(this instanceof Promise)) throw new Error("Promise must be called with `new`")
if (typeof executor !== "function") throw new Error("executor must be a function")
if (typeof executor !== "function") throw new TypeError("executor must be a function")
var self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)
var instance = self._instance = {resolvers: resolvers, rejectors: rejectors}
@ -93,6 +94,5 @@ Promise.race = function(list) {
}
})
}
module.exports = Promise
}
module.exports = Promise