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
{ | |
"targets": [ | |
{ | |
"conditions": [ | |
["OS=='mac'", { | |
"xcode_settings": { | |
"GCC_ENABLE_CPP_EXCEPTIONS": "YES" | |
} | |
}], | |
], |
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
require('colors'); | |
function* genFibo() { | |
var f1 = 0, f2 = 1; | |
while (true) { | |
console.log(("genFibo loop: " + f1).green) | |
yield f1; | |
var f = f1 + f2; | |
f1 = f2; | |
f2 = f; |
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 isGenerator(val) { | |
return Object.prototype.toString.call(val) === "[object Generator]"; | |
} | |
var PENDING = {}; | |
function run(fn, args, idx) { | |
var cb = args[idx], | |
g; |
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 fs = require('fs'); | |
function fib(n) { | |
return n <= 1 ? 1 : fib(n - 1) + fib(n - 2); | |
} | |
function rawBench(n, loop, modulo, asyncFn, callback) { | |
var count = 0; | |
var l = loop; |
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 fs = require('fs'); | |
function testgen(_) { | |
console.log(fs.readFile(__filename, _)); | |
console.log("Sleeping for 2000ms..."); | |
setTimeout(_, 2000); | |
console.log("Done"); | |
} | |
testgen(_); |
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
// Wrapping asynchronous functions | |
// This wrapper is implemented with callbacks | |
// i is the index of the callback in the parameter list | |
// isFuture is a reserved parameter - do not pass it | |
function wrapper1(fn, i, isFuture) { | |
return function wrapped() { | |
var cb = arguments[i]; | |
if (!isFuture) console.log("WRAPPER1 BEFORE CALL: " + fn.name); | |
if (cb == null) return wrapper1(fn.apply(this, arguments), 0, true); | |
arguments[i] = function(err, result) { |
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 wrappers = require('./wrappers'); | |
var http = require('http'); | |
var zlib = require('zlib'); | |
var util = require('util'); | |
var fs = require('fs'); | |
http.createServer(function(request, response) { | |
response.writeHead(200, { | |
'Content-Type': 'text/plain; charset=utf8', |
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 g = 3; | |
function hackGlobal(fn) { | |
return function() { | |
var saveG = g; | |
try { | |
g = 5; | |
fn.apply(this, arguments); | |
} finally { | |
g = saveG; |
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 count = 1000000; | |
function bench(fn, cb) { | |
var total = 0; | |
function loop(i) { | |
if (i === count) { | |
cb(null, total); | |
} else { |
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() { | |
var GENERATOR_PROTO = Object.getPrototypeOf((function() { | |
yield; | |
})()); | |
function isGenerator(val) { | |
return typeof val === 'object' && Object.getPrototypeOf(val) === GENERATOR_PROTO; | |
} | |
var PENDING = {}; |