next-tick
Advanced tools
Comparing version 0.2.1 to 0.2.2
15
index.js
'use strict'; | ||
var callable = require('es5-ext/lib/Object/valid-callable') | ||
var callable, byObserver; | ||
, byObserver; | ||
callable = function (fn) { | ||
if (typeof fn !== 'function') throw new TypeError(fn + " is not a function"); | ||
return fn; | ||
}; | ||
byObserver = function (Observer) { | ||
var el = document.createElement('div'), queue; | ||
var node = document.createTextNode(''), queue, i = 0; | ||
new Observer(function () { | ||
@@ -19,3 +22,3 @@ var data; | ||
data.forEach(function (fn) { fn(); }); | ||
}).observe(el, { attributes: true }); | ||
}).observe(node, { characterData: true }); | ||
return function (fn) { | ||
@@ -29,3 +32,3 @@ callable(fn); | ||
queue = fn; | ||
el.setAttribute('x', 'y'); | ||
node.data = (i = ++i % 2); | ||
}; | ||
@@ -41,3 +44,3 @@ }; | ||
// MutationObserver | ||
// MutationObserver= | ||
if ((typeof document === 'object') && document) { | ||
@@ -44,0 +47,0 @@ if (typeof MutationObserver === 'function') { |
{ | ||
"name": "next-tick", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Environment agnostic nextTick polyfill", | ||
@@ -23,5 +23,2 @@ "author": "Mariusz Nowak <medykk@medikoo.com> (http://www.medikoo.com/)", | ||
}, | ||
"dependencies": { | ||
"es5-ext": "~0.9.2" | ||
}, | ||
"devDependencies": { | ||
@@ -28,0 +25,0 @@ "tad": "~0.1.21" |
@@ -1,2 +0,2 @@ | ||
# nextTick | ||
# next-tick | ||
## Environment agnostic nextTick polyfill | ||
@@ -7,3 +7,3 @@ | ||
- When run in Node.js `process.nextTick` is used | ||
- In modern browsers microtask kind resolution is guaranteed by `MutationObserver` | ||
- In modern browsers microtask resolution is guaranteed by `MutationObserver` | ||
- In other engines `setImmediate` or `setTimeout(fn, 0)` is used as fallback. | ||
@@ -10,0 +10,0 @@ - If none of the above is supported module resolves to `null` |
Sorry, the diff of this file is not supported yet
5519
0
76
- Removedes5-ext@~0.9.2
- Removedes5-ext@0.9.2(transitive)