-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathnodeify.js
26 lines (24 loc) · 866 Bytes
/
nodeify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// this xhr patch may move to {N} core some day and can be removed
require("xhr");
var xhrAddEventListenerOrig = XMLHttpRequest.prototype.addEventListener;
XMLHttpRequest.prototype.addEventListener = function(eventName, callback) {
if (eventName === "readystatechange") {
this.onreadystatechange = callback;
} else if (eventName === "progress") {
this.onprogress = callback;
} else if (eventName === "abort") {
this.abort = callback;
} else if (eventName === "timeout") {
this.ontimeout = callback;
} else {
xhrAddEventListenerOrig.call(this, eventName, callback);
}
};
if (!XMLHttpRequest.prototype.upload) {
XMLHttpRequest.prototype['upload'] = {
addEventListener: function() {}
};
}
// a few global properties node modules may rely on
global.process = require("process/browser");
global.Buffer = require("buffer").Buffer;