Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1021 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.hasNextTick = exports.hasSetImmediate = undefined;
|
---|
7 | exports.fallback = fallback;
|
---|
8 | exports.wrap = wrap;
|
---|
9 |
|
---|
10 | var _slice = require('./slice');
|
---|
11 |
|
---|
12 | var _slice2 = _interopRequireDefault(_slice);
|
---|
13 |
|
---|
14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
15 |
|
---|
16 | var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
|
---|
17 | var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
|
---|
18 |
|
---|
19 | function fallback(fn) {
|
---|
20 | setTimeout(fn, 0);
|
---|
21 | }
|
---|
22 |
|
---|
23 | function wrap(defer) {
|
---|
24 | return function (fn /*, ...args*/) {
|
---|
25 | var args = (0, _slice2.default)(arguments, 1);
|
---|
26 | defer(function () {
|
---|
27 | fn.apply(null, args);
|
---|
28 | });
|
---|
29 | };
|
---|
30 | }
|
---|
31 |
|
---|
32 | var _defer;
|
---|
33 |
|
---|
34 | if (hasSetImmediate) {
|
---|
35 | _defer = setImmediate;
|
---|
36 | } else if (hasNextTick) {
|
---|
37 | _defer = process.nextTick;
|
---|
38 | } else {
|
---|
39 | _defer = fallback;
|
---|
40 | }
|
---|
41 |
|
---|
42 | exports.default = wrap(_defer); |
---|
Note:
See
TracBrowser
for help on using the repository browser.