Created
September 29, 2015 18:14
-
-
Save gabmontes/6ed0ee0f1280f4e932ea to your computer and use it in GitHub Desktop.
Promisify require() calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global, Promise) { | |
"use strict"; | |
if (!require || !Promise) { | |
throw new Error("Could not promisify require"); | |
} | |
global.requireAsync = function (dependencies) { | |
return new Promise(function (complete, error) { | |
require(dependencies, function () { | |
complete.apply(null, arguments); | |
}, error); | |
}); | |
}; | |
})(this, window && window.Promise || WinJS && WinJS.Promise); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment