blob: 45ddd7a8303eecf939614c23f859a02c9a0b2df2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import {get} from 'http';
import {ISource} from './ISource';
export class HttpSource implements ISource {
private _uri: string;
constructor(path: string) {
this._uri = path;
}
getData(): Promise<string> {
return new Promise<string>((resolve, reject) => {
get(this._uri, (res) => {
let data = '';
res.on('error', reject);
res.on('data', chunk => data += chunk);
res.on('end', () => resolve(data));
});
});
}
}
|