-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
45 lines (38 loc) · 1.06 KB
/
main.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
const {Readable} = require('stream');
const {IncomingMessage} = require('http');
const io = require('./node');
// replace errors
class FailedIO extends Error {
constructor(xhr, options, event, message = 'Failed I/O') {
super(message);
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
this.xhr = xhr;
this.options = options;
this.event = event;
}
getData() {
return io.getData(this.xhr);
}
getHeaders() {
return io.getHeaders(this.xhr);
}
}
io.FailedIO = FailedIO;
class TimedOut extends FailedIO {
constructor(xhr, options, event) {
super(xhr, options, event, 'Timed out I/O');
}
}
io.TimedOut = TimedOut;
class BadStatus extends FailedIO {
constructor(xhr, options, event) {
super(xhr, options, event, 'Bad status I/O' + (xhr && xhr.status ? ': ' + xhr.status : ''));
}
}
io.BadStatus = BadStatus;
io.node.attach();
const passThrough = (_1, _2, data) => new io.Ignore(data);
io.dataProcessors.push(Readable, passThrough, Buffer, passThrough, IncomingMessage, passThrough);
module.exports = io;