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 extend = require('./extend') | |
function composer(obj) { | |
obj = obj || {} | |
return { | |
extend: function(extension) { | |
var extended = extend(obj, extension) | |
return composer(extended) | |
}, |
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
def greeter_sync | |
print(“Hello World”) | |
sleep(5000) # sleep for 5 seconds | |
print(“Goodbye World”) | |
end | |
def greeter_async | |
# sleep for 5 seconds, then print Goodbye World | |
async sleep(5000) then print(“Goodbye World”) | |
print(“Hello World”) |
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
Hello World | |
# ... 5 seconds or so | |
Goodbye World |
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 fs = require('fs') | |
, path = 'my_file.txt' | |
, file | |
file = fs.readFile(path) |
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 fs = require('fs') | |
, path = 'my_file.txt' | |
fs.readFile(path, function() { | |
console.log('done') | |
}) |
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 fs = require('fs') | |
, path = 'my_file.txt' | |
fs.readFile(path, function(err, data) { | |
if(err) { | |
console.error(err) | |
} else { | |
console.log(data) | |
} | |
}) |
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 fs = require('fs') | |
, path = 'my_file.txt' | |
function getFile(path, callback) { | |
fs.readFile(path, function(err, data) { | |
if(err){ | |
return callback(err) | |
} | |
var wrapperMessage = {coolStuff: true, data: data} |
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 fs = require('fs') | |
, path = 'my_file.txt' | |
function getFile(path, callback) { | |
try { | |
fs.readFile(path, function(err, data) { | |
if(err) throw err | |
var wrapperMessage = {coolStuff: true, data: data} | |
callback(null, wrapperMessage) | |
}) |
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
function findLikesForPostsByUsername(username, callback) { | |
findUserByUsername(username, function(err, user) { | |
if(err) return callback(err) | |
findPostsByUser(user, function(err, posts) { | |
if(err) return callback(err) | |
findLikesByPosts(posts, function(err, likes) { | |
if(err) return callback(err) | |
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
function getTweetsPostsRepos(username, callback) { | |
var count = 0 | |
, results = [] | |
function somethingFinished(err, result) { | |
count += 1 | |
results.push(result) | |
if(count === 3) { | |
callback(null, results) |