1 |
|
2 |
|
3 | var process = module.exports = {};
|
4 |
|
5 | process.nextTick = (function () {
|
6 | var canSetImmediate = typeof window !== 'undefined'
|
7 | && window.setImmediate;
|
8 | var canPost = typeof window !== 'undefined'
|
9 | && window.postMessage && window.addEventListener
|
10 | ;
|
11 |
|
12 | if (canSetImmediate) {
|
13 | return function (f) { return window.setImmediate(f) };
|
14 | }
|
15 |
|
16 | if (canPost) {
|
17 | var queue = [];
|
18 | window.addEventListener('message', function (ev) {
|
19 | if (ev.source === window && ev.data === 'process-tick') {
|
20 | ev.stopPropagation();
|
21 | if (queue.length > 0) {
|
22 | var fn = queue.shift();
|
23 | fn();
|
24 | }
|
25 | }
|
26 | }, true);
|
27 |
|
28 | return function nextTick(fn) {
|
29 | queue.push(fn);
|
30 | window.postMessage('process-tick', '*');
|
31 | };
|
32 | }
|
33 |
|
34 | return function nextTick(fn) {
|
35 | setTimeout(fn, 0);
|
36 | };
|
37 | })();
|
38 |
|
39 | process.title = 'browser';
|
40 | process.browser = true;
|
41 | process.env = {};
|
42 | process.argv = [];
|
43 |
|
44 | process.binding = function (name) {
|
45 | throw new Error('process.binding is not supported');
|
46 | }
|
47 |
|
48 |
|
49 | process.cwd = function () { return '/' };
|
50 | process.chdir = function (dir) {
|
51 | throw new Error('process.chdir is not supported');
|
52 | };
|