first commit
This commit is contained in:
53
build/node_modules/process/browser.js
generated
vendored
Normal file
53
build/node_modules/process/browser.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// shim for using process in browser
|
||||
|
||||
var process = module.exports = {};
|
||||
|
||||
process.nextTick = (function () {
|
||||
var canSetImmediate = typeof window !== 'undefined'
|
||||
&& window.setImmediate;
|
||||
var canPost = typeof window !== 'undefined'
|
||||
&& window.postMessage && window.addEventListener
|
||||
;
|
||||
|
||||
if (canSetImmediate) {
|
||||
return function (f) { return window.setImmediate(f) };
|
||||
}
|
||||
|
||||
if (canPost) {
|
||||
var queue = [];
|
||||
window.addEventListener('message', function (ev) {
|
||||
var source = ev.source;
|
||||
if ((source === window || source === null) && ev.data === 'process-tick') {
|
||||
ev.stopPropagation();
|
||||
if (queue.length > 0) {
|
||||
var fn = queue.shift();
|
||||
fn();
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
return function nextTick(fn) {
|
||||
queue.push(fn);
|
||||
window.postMessage('process-tick', '*');
|
||||
};
|
||||
}
|
||||
|
||||
return function nextTick(fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
})();
|
||||
|
||||
process.title = 'browser';
|
||||
process.browser = true;
|
||||
process.env = {};
|
||||
process.argv = [];
|
||||
|
||||
process.binding = function (name) {
|
||||
throw new Error('process.binding is not supported');
|
||||
}
|
||||
|
||||
// TODO(shtylman)
|
||||
process.cwd = function () { return '/' };
|
||||
process.chdir = function (dir) {
|
||||
throw new Error('process.chdir is not supported');
|
||||
};
|
||||
Reference in New Issue
Block a user