Skip to content

Instantly share code, notes, and snippets.

@gabmontes
Created September 29, 2015 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabmontes/6ed0ee0f1280f4e932ea to your computer and use it in GitHub Desktop.
Save gabmontes/6ed0ee0f1280f4e932ea to your computer and use it in GitHub Desktop.
Promisify require() calls
(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