This file contains 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
"use strict"; | |
var fs = require('fs'); | |
var co = require('co'); | |
co(function* () { | |
var file1 = yield readFile('demo.js'); | |
console.log(file1); | |
console.log("I am after file read even though its Async"); | |
}); |
This file contains 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 fs = require("fs"); | |
fs.readFile('async.js','utf8',fileContent); | |
function fileContent(err,data) { | |
if(!err) { | |
console.log(data); | |
} | |
} |
This file contains 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 fs = require("fs"); | |
fs.readFile('async.js','utf8',function(err,data){ | |
if(!err) { | |
console.log(data); | |
} | |
}); |
This file contains 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 fs = require("fs"); | |
var db = require('somedbfile.js'); | |
var sendEmail = require('someEmail.js'); | |
fs.readFile('async.js','utf8',function(err,data){ | |
if(!err) { | |
console.log(data); | |
} | |
db.executeQuery('SELECT * FROM test',function(err,rows) { | |
if(!err) { | |
console.log("Error",err); |
This file contains 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 fs = require("fs"); | |
fs.readFile('async.js','utf8',function(err,data){ | |
if(!err) { | |
console.log(data); | |
} | |
}); | |
console.log("something else"); |
This file contains 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 fs = require("fs"); | |
var fileContent = fs.readFileSync('sync.js','utf8'); | |
console.log(fileContent); | |
console.log("something else"); | |
//Output | |
//Same code content | |
//something else |
This file contains 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
[ | |
{ | |
"name":"The 40-Year-Old Virgin" | |
}, | |
{ | |
"name":"51 Birch Street" | |
}, | |
{ | |
"name":"The Adventures of Sharkboy and Lavagirl in 3-D" | |
}, |
NewerOlder