Skip to content

Commit

Permalink
Simplified attaching to global object
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorhakes committed Apr 1, 2015
1 parent 049ec5c commit b086fe6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
17 changes: 5 additions & 12 deletions Promise.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
(function() {
var root;

if (typeof window === 'object' && window) {
root = window;
} else if (typeof global === 'object' && global) {
root = global;
} else {
root = {};
}
(function(root) {

// Use polyfill for setImmediate for performance gains
var asap = Promise.immediateFn || root.setImmediate || function(fn) { setTimeout(fn, 1); };
var asap = Promise.immediateFn || (typeof setImmediate === 'function' && setImmediate) ||
function(fn) { setTimeout(fn, 1); };

// Polyfill for Function.prototype.bind
function bind(fn, thisArg) {
Expand Down Expand Up @@ -185,4 +177,5 @@
} else if (!root.Promise) {
root.Promise = Promise;
}
})();

})(this);
2 changes: 1 addition & 1 deletion Promise.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "promise-polyfill",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "https://github.com/taylorhakes/promise-polyfill",
"authors": [
"Taylor Hakes"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "promise-polyfill",
"version": "2.0.1",
"version": "2.0.2",
"description": "Lightweight promise polyfill. A+ compliant",
"main": "Promise.js",
"scripts": {
Expand Down

0 comments on commit b086fe6

Please sign in to comment.