This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var fs = require('fs'); | |
http.createServer(function(request, response){ | |
var newFile = fs.createWriteStream("big_copy.md"); //This is created automatically | |
var fileBytes = request.headers['content-length']; //Check how much bytes a file has | |
var uploadedBytes = 0;//Keep track of the bytes uploaded. | |
request.on('readable', function(){ //Each time information is read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Promise Dependencies (after promiseExplanation) | |
//In this Example first you clean the room, then remove the garbage and finally win an icecream. | |
//Here also im directly resolving the promises, real life is code and check if resolved or reject. | |
let cleanRoom = function(){ | |
return new Promise(function(resolve, reject){ | |
resolve('I Cleaned the Room'); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//First code about promises | |
let promiseToCleanTheRoom = new Promise(function(resolve, reject){ | |
//Resolve: Means I am fullfilling this promise (resolving it). | |
//Reject: Promise is not Fullfilled in given time or constraint. | |
//HERE IS CLEANING THE ROOM CODE.... | |
//After doing this, clean's value gets set. | |
let isClean = true; //Here you control resolve and reject in this example. |