cezboil 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +11 -0
  2. package/random.js +16 -0
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "cezboil",
3
+ "version": "1.0.0",
4
+ "description": "Boiler code for Node js",
5
+ "main": "random.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }
package/random.js ADDED
@@ -0,0 +1,16 @@
1
+ const http = require("http"); // or 'https' for https:// URLs
2
+ const fs = require("fs");
3
+
4
+ const file = fs.createWriteStream("file.jpg");
5
+ const request = http.get(
6
+ "http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg",
7
+ function (response) {
8
+ response.pipe(file);
9
+
10
+ // after download completed close filestream
11
+ file.on("finish", () => {
12
+ file.close();
13
+ console.log("Download Completed");
14
+ });
15
+ }
16
+ );