blob: f532721bb074e7b46713188cdfb5f2703773294a (
plain)
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
|
const fs = require("fs");
const https = require("https");
function openFile(path)
{
return new Promise((resolve, reject) =>
{
fs.readFile(path, (err, data) =>
{
if (err)
reject(err);
resolve(data);
})
});
}
async function urlOpen(path)
{
return new Promise((resolve, reject) =>
{
let req = https.get(path, res =>
{
res.on("data", resolve);
});
});
req.on("error", e =>
{
console.error(e);
});
req.end();
}
module.exports = {
file: openFile,
url: urlOpen
};
|