process
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -8,2 +8,4 @@ // shim for using process in browser | ||
&& window.setImmediate; | ||
var canMutationObserver = typeof window !== 'undefined' | ||
&& window.MutationObserver; | ||
var canPost = typeof window !== 'undefined' | ||
@@ -17,4 +19,25 @@ && window.postMessage && window.addEventListener | ||
var queue = []; | ||
if (canMutationObserver) { | ||
var hiddenDiv = document.createElement("div"); | ||
var observer = new MutationObserver(function () { | ||
var queueList = queue.slice(); | ||
queue.length = 0; | ||
queueList.forEach(function (fn) { | ||
fn(); | ||
}); | ||
}); | ||
observer.observe(hiddenDiv, { attributes: true }); | ||
return function nextTick(fn) { | ||
if (!queue.length) { | ||
hiddenDiv.setAttribute('yes', 'no'); | ||
} | ||
queue.push(fn); | ||
}; | ||
} | ||
if (canPost) { | ||
var queue = []; | ||
window.addEventListener('message', function (ev) { | ||
@@ -59,3 +82,3 @@ var source = ev.source; | ||
throw new Error('process.binding is not supported'); | ||
} | ||
}; | ||
@@ -62,0 +85,0 @@ // TODO(shtylman) |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
4871
73