|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
441 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | module.exports = defer;
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Runs provided function on next iteration of the event loop
|
|---|
| 5 | *
|
|---|
| 6 | * @param {function} fn - function to run
|
|---|
| 7 | */
|
|---|
| 8 | function defer(fn)
|
|---|
| 9 | {
|
|---|
| 10 | var nextTick = typeof setImmediate == 'function'
|
|---|
| 11 | ? setImmediate
|
|---|
| 12 | : (
|
|---|
| 13 | typeof process == 'object' && typeof process.nextTick == 'function'
|
|---|
| 14 | ? process.nextTick
|
|---|
| 15 | : null
|
|---|
| 16 | );
|
|---|
| 17 |
|
|---|
| 18 | if (nextTick)
|
|---|
| 19 | {
|
|---|
| 20 | nextTick(fn);
|
|---|
| 21 | }
|
|---|
| 22 | else
|
|---|
| 23 | {
|
|---|
| 24 | setTimeout(fn, 0);
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.