Pathologic was missing because of a .git folder inside.
[yaffs-website] / node_modules / core-js / modules / _microtask.js
1 var global    = require('./_global')
2   , macrotask = require('./_task').set
3   , Observer  = global.MutationObserver || global.WebKitMutationObserver
4   , process   = global.process
5   , Promise   = global.Promise
6   , isNode    = require('./_cof')(process) == 'process';
7
8 module.exports = function(){
9   var head, last, notify;
10
11   var flush = function(){
12     var parent, fn;
13     if(isNode && (parent = process.domain))parent.exit();
14     while(head){
15       fn   = head.fn;
16       head = head.next;
17       try {
18         fn();
19       } catch(e){
20         if(head)notify();
21         else last = undefined;
22         throw e;
23       }
24     } last = undefined;
25     if(parent)parent.enter();
26   };
27
28   // Node.js
29   if(isNode){
30     notify = function(){
31       process.nextTick(flush);
32     };
33   // browsers with MutationObserver
34   } else if(Observer){
35     var toggle = true
36       , node   = document.createTextNode('');
37     new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
38     notify = function(){
39       node.data = toggle = !toggle;
40     };
41   // environments with maybe non-completely correct, but existent Promise
42   } else if(Promise && Promise.resolve){
43     var promise = Promise.resolve();
44     notify = function(){
45       promise.then(flush);
46     };
47   // for other environments - macrotask based on:
48   // - setImmediate
49   // - MessageChannel
50   // - window.postMessag
51   // - onreadystatechange
52   // - setTimeout
53   } else {
54     notify = function(){
55       // strange IE + webpack dev server bug - use .call(global)
56       macrotask.call(global, flush);
57     };
58   }
59
60   return function(fn){
61     var task = {fn: fn, next: undefined};
62     if(last)last.next = task;
63     if(!head){
64       head = task;
65       notify();
66     } last = task;
67   };
68 };