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-streamline -c truthy_.js | |
$ node-streamline -c true_.js | |
/usr/lib/node/.npm/streamline/0.1.11/package/lib/transform.js:1549 | |
throw new Error(message); | |
^ | |
Error: error streamlining source: Missing identifier on line 5 | |
at Object.transform (/usr/lib/node/.npm/streamline/0.1.11/package/lib/transform.js:1549:10) | |
at /usr/lib/node/.npm/streamline/0.1.11/package/lib/compile.js:48:30 | |
at /usr/lib/node/.npm/streamline/0.1.11/package/lib/compile.js:43:206 |
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
// streamline.options = { "callback": "_cb" } | |
var _ = require('underscore'); | |
var array = [1, 2, 3]; | |
function process(item, _cb) { | |
// simulate async task | |
setTimeout(_cb, 1000); | |
return item; | |
} |
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
console.log('will throw error in one second...'); | |
try { | |
// simulate async step here: | |
setTimeout(_, 1000); | |
// then *synchronously* throw error here: | |
(function closure() { | |
throw new Error(); | |
})(); |
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
// here's an example third-party, out-of-my-control function. | |
// it calls the callback with multiple non-error values: | |
function addAndProfile_original(x, y, callback) { | |
var start = Date.now(); | |
return setTimeout(function () { | |
var time = Date.now() - start; | |
callback(null, x + y, time); | |
}, 1000); | |
} |
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
coffee = require 'coffee-script' | |
streamline = require 'streamline' | |
fs = require('fs') | |
if require.extensions | |
require.extensions['.coffee'] = (module, filename) -> | |
content = coffee.compile fs.readFileSync filename, 'utf8' | |
if filename.match /_\.coffee$/ | |
content = streamline.transform.transform content | |
module._compile content, filename |
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 express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(app.router); | |
}); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'html'); | |
app.register('.html', require('eco')); |
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 express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(require('./blocks')(app)); | |
app.use(app.router); | |
}); | |
app.set('views', __dirname); | |
app.set('view engine', 'html'); |
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 express = require('express'); | |
var app = express.createServer(); | |
app.set('views', __dirname); | |
app.set('view engine', 'html'); | |
app.register('.html', require('ejs')); | |
app.configure(function () { | |
app.use(express.bodyParser()); | |
app.use(express.errorHandler({ |
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 express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(express.compiler({ | |
src: __dirname, | |
enable: ['less'] | |
})); | |
app.use(express.static(__dirname)); | |
app.use(express.errorHandler({ |
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 Animal(name) { | |
this.name = name; | |
} | |
Animal.prototype.drink = function (_) { | |
console.log(this.name + " is about to grab a drink at the watering hole..."); | |
// simulate async step: | |
setTimeout(_, 1000); |
OlderNewer