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 Fiber = require('fibers'); | |
function inc(x) { | |
while (true) { | |
x = x + 1; | |
Fiber.yield(x); | |
} | |
} | |
var list=[]; |
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 Fiber = require('fibers'); | |
var Future = require('fibers/future'), wait = Future.wait; | |
// This Client class implement a caching accessing layer (Redis or Memcached) | |
// that uses batching to optimize IO | |
function Client() { | |
this.scheduled = false; | |
this.queue = { | |
reqsArgs: [], |
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 Fiber = require('fibers'); | |
var Future = require('fibers/future'), wait = Future.wait; | |
var getByIdCb= function(id, cb) { | |
cb(null, 'foo'); | |
} | |
var getById = Future.wrap(getByIdCb); |
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
app.get('/api', function(req, res) { | |
Sync(function() { | |
// Store current request in scope | |
Sync.scope.req = req; | |
var result = foo(req); | |
res.json(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
var fs = require('fs'); | |
function UInt32(str, pos) { | |
return (str.charCodeAt(pos++)) + | |
(str.charCodeAt(pos++) << 8) + | |
(str.charCodeAt(pos++) << 16) + | |
(str.charCodeAt(pos) << 24); | |
} | |
function UInt16(str, pos) { |
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
FB.Event.subscribe('FB.init.start', | |
function(options) { | |
if (options.nativeInterface) { | |
FB._nativeInterface = options.nativeInterface; | |
FB._nativeInterface.init(FB._apiKey); | |
} | |
}); | |
FB.Event.subscribe('FB.auth.staticAuthCheck.start', |
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.trace = function() | |
{ | |
var trace = []; | |
var current = this; | |
while(current) | |
{ | |
trace.push(current.signature()); | |
current = current.caller; | |
} | |
return trace; |