http://www.codewars.com/kata/unpacking-arguments
http://www.codewars.com/kata/for-the-sake-of-argument
var spyOn = require('./spy'); | |
var assert = require('assert'); | |
describe('spyOn', function () { | |
it('should be a function', function () { | |
assert(typeof spyOn === 'function', 'spyOn is not a function.'); | |
}); | |
describe('functionality', function () { |
var Promise = require('bluebird'); | |
var pipeline = function (tasksThatReturnPromises, prevValue) { | |
var first = tasksThatReturnPromises.shift(); | |
return Promise.resolve(first(prevValue)).then(function (v) { | |
if (tasksThatReturnPromises.length === 0) { | |
return v; | |
} else { |
// Running on your computer. | |
var express = require('express'); | |
var http = require('http'); | |
var fs = require('fs'); | |
var server = http.createServer(); | |
var app = express(); | |
server.on('request', app); |
http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742
Legendary book, a must-read for any Javascript programmer at least once. Goes into the basics of Javascript with the assumption that the reader is an experienced programmer already, coming from another language or already understands a fair bit about Javascript itself. Very good review of basics and more advanced concepts (like scope/closure, functions as first class objects, etc).
Promise.promisify = function (fnThatTakesCallbacks) { | |
return function () { | |
var args = [].slice.call(arguments); | |
return new Promise(function (resolve, reject) { | |
fnThatTakesCallbacks.apply(this, args.concat(function (err) { | |