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
function someAsyncFunction(data) { | |
return new Promise(function(resolve, reject) { | |
resolve([console.log(data), console.log('Resolved in someAsyncFunction!')]); | |
}); | |
} | |
var fetchData = function() { | |
return new Promise(function(resolve, reject) { | |
setTimeout(function() { | |
resolve({ |
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 promise = new Promise(function(resolve, reject) { | |
// do a thing, possibly async, then… | |
if (/* everything turned out fine */) { | |
resolve("Stuff worked!"); | |
} | |
else { | |
reject(Error("It broke")); | |
} | |
}); |
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
promise.then(function(result) { | |
console.log(result); // "Stuff worked!" | |
}, function(err) { | |
console.log(err); // Error: "It broke" | |
}); |
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
function someAsyncFunction(data) { | |
return new Promise(function(resolve, reject) { | |
resolve([console.log(data), console.log('Resolved in someAsyncFunction!')]); | |
}) | |
} | |
var fetchData = function() { | |
return new Promise(function(resolve, reject) { | |
setTimeout(function() { | |
/*resolve({ |
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
function firstAsyncFunction() { | |
return new Promise(function(resolve, reject){ | |
setTimeout(function(){ | |
resolve('First async function has been resolved!'); | |
}, 1000); | |
}); | |
} | |
function secondAsyncFunction() { | |
return new Promise(function(resolve, reject) { |
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 gulp = require('gulp'), | |
compass = require('gulp-compass'); | |
gulp.task('compass', function() { | |
return gulp.src('styles/sass/*.scss') | |
.pipe(compass({ | |
config_file: './config.rb', | |
css: './styles/css', | |
sass: './styles/sass' | |
})) |
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
Function.prototype.compose = function(prevFunc) { | |
var nextFunction = this; | |
return function() { | |
return nextFunction.call(this, prevFunc.apply(this, arguments)); | |
} | |
}; |
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 Hello = (function(){ | |
'use strict'; | |
var _name; | |
function Hello(name){ | |
_name = name; | |
} | |
Hello.prototype.sayHello = function(){ |
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 Hello = (function(){ | |
'use strict'; | |
var _name; | |
function Hello(name){ | |
_name = name; | |
} | |
Hello.prototype.sayHello = function(){ |
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 tailHeaders = $('.tail-header'); | |
for(var i = 0; i < tailHeaders.length; i++) { | |
new Waypoint({ | |
element: tailHeaders[i], | |
context: $('#container'), | |
handler: function(direction) { | |
var prevTailHeader = this.previous() ? this.previous().adapter.$element : null; | |
var nextTailHeader = this.next() ? this.next().adapter.$element : null; |
OlderNewer