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
// Inspired partially by Isaac's inherits: https://github.com/isaacs/inherits | |
// No descriptors involved (needs to work same way on ES3 and ES5 engines) | |
// In older browsers needs to be run aside es5-shim: https://github.com/kriskowal/es5-shim | |
var extend = (function () { | |
'use strict'; | |
var slice = Array.prototype.slice | |
, call = Function.prototype.call | |
, wantsSuper = RegExp.prototype.test.bind(/^\s*function\s*\(\s*_super\s*[,\)]/) |
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
// No function wrapper as it's CommonJS/NodeJS module | |
var slice = [].slice | |
this.events = { | |
events: {}, | |
on: function (topic, handler, context) { | |
(this.events[topic] || (this.events[topic] = [])) |
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 deferred = require('deferred') | |
, query = deferred.promisify(DbSource.query).bind(DbSource) | |
, write = deferred.promisify(DbDest.write).bind(DbDest) | |
console.log('[INFO]', 'Starting sequence'); | |
var q = 'SELECT A.* FROM BotCCServer A LIMIT 1'; | |
query(q).map(function (data, i) { | |
var row = data[0]; | |
console.log('[INFO]', 'Each'); |
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 domjs = require('domjs'); | |
var tpl = domjs.require('./template'); // DocumentFragment [<header>, <nav>, <article>, <footer>] |
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 createServer = require('http').createServer | |
, staticServer = require('node-static').Server | |
, webmake = require('webmake') | |
, rootPath = '/Users/foobar/Projects/my-project' | |
, publicPath = rootPath + '/public' | |
, jsProgramPath = rootPath + '/lib/public/main.js'; |
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
patterns.some(function (data) { | |
var match; | |
if (match = url.match(data.pattern)) { | |
location.title = data.fn(match); | |
return true; | |
} | |
}); |
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
$ node concurrent.js | |
Promise overhead (concurrent calls) x10000: | |
1: 309ms Base (plain Node.js lstat call) | |
2: 440ms When: Dedicated wrapper | |
3: 543ms Deferred: Dedicated wrapper | |
4: 625ms Deferred: Promisify (generic wrapper) | |
5: 682ms Deferred: Map + Promisify | |
6: 813ms jQuery.Deferred: Dedicated wrapper | |
7: 2965ms Q: Dedicated wrapper |
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
a.then(null, function () { | |
// A failed, patch it | |
}).then(function () { | |
// B logic | |
}).then(function () { | |
// C logic | |
}); |
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 files = [/* list of files */]; | |
var iterate = function () { | |
var file = files.shift(); | |
return file ? process(file).then(iterate) : null; | |
}; | |
var process = function (file) { | |
// ... | |
return promise; |
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
versions().invoke('reverse').reduce(function (result, version) { | |
return install(target, version, prefix)(visitor.bind(null, null), visitor); | |
}, null).cb(callback); |