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 galaxy = require('galaxy'); | |
function *waitForOne(futures) { | |
return yield galaxy.star(function(cb) { | |
for (var i = 0; i < futures.length; i++) { | |
galaxy.unstar(futures[i], 0)(function(e, r) { | |
if (cb) cb(e, r); | |
cb = null; | |
}); | |
} |
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("./build/Release/fibers").Fiber; | |
function wrap(fn, idx) { | |
function F() { | |
var cb = arguments[idx]; | |
var that = this, | |
args = arguments; | |
Fiber(function () { | |
var val, err = null; |
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 oracledb = require('oracledb'); | |
var ez = require('ez-streams'); | |
var cnx = oracledb.getConnection({ | |
user: "scott", | |
password: "oracle", | |
connectString: "localhost/ORCL", | |
}, _); | |
try { |
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"; | |
function assert(i, j) { | |
if (i !== j) throw new Error("expected " + i + ", got " + j) | |
} | |
function callbackIter(fn, n, cb) { | |
var t0 = Date.now(); | |
(function doIt(i) { | |
if (i < n) fn(i, function(err, val) { |
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
/*** Generated by streamline 0.1.22 - DO NOT EDIT ***/ | |
var __global = typeof global !== 'undefined' ? global : window; | |
function __cb(_, fn) { var ctx = __global.__context; return function(err, result) { __global.__context = ctx; if (err) return _(err); try { return fn(null, result); } catch (ex) { return __propagate(_, ex); } } } | |
function __future(fn, args, i) { var done, err, result; var cb = function(e, r) { done = true; err = e, result = r; }; args = Array.prototype.slice.call(args); args[i] = function(e, r) { cb(e, r); }; fn.apply(this, args); return function(_) { if (done) _.call(this, err, result); else cb = _.bind(this); }.bind(this); } | |
function __propagate(_, err) { try { _(err); } catch (ex) { __trap(ex); } } | |
function __trap(err) { if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } | |
(function(_) { | |
var __then = (_ = (_ || __trap)); | |
/* 1 |
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 streams = require("streamline/lib/streams/streams"); | |
var flows = require("streamline/lib/util/flows"); | |
var port = 3001; | |
// if you remove last element, test will pass! | |
var values = [1,2,3,4,5]; | |
function send(_, path, val){ | |
return streams.httpRequest({ | |
method: "put", | |
url: "http://localhost:" + port + path |
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
/*** Generated by streamline 0.1.35 - DO NOT EDIT ***/ | |
var __global = typeof global !== 'undefined' ? global : window; | |
function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); try { return fn(null, result); } catch (ex) { return __propagate(_, ex); } } } | |
function __future(fn, args, i){ var done, err, result; var cb = function(e, r){ done = true; err = e, result = r; }; args = Array.prototype.slice.call(args); args[i] = function(e, r){ cb(e, r); }; fn.apply(this, args); return function(_){ if (done) _.call(this, err, result); else cb = _.bind(this); } .bind(this); } | |
function __nt(_, fn){ var i = 0; var cb = __cb(_, fn); var safeCb = function(){ try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function(){ if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function(){ if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; } | |
function _ |
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 JSURL = require("jsurl"); | |
function bench(name, count, fn) { | |
var t0 = Date.now(); | |
for (var i = 0; i < count; i++) | |
fn(); | |
console.log(name + ": " + (Date.now() - t0)); | |
} |
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"; | |
if (!require('streamline/module')(module)) return; | |
function foo(_, i) { | |
return 2 * i; | |
} | |
function bar(_, f, i) { | |
return f.call(null, _, i); | |
} |
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
// callback wrapper for trampoline | |
var depth = 0; | |
var maxDepth = 100; | |
var marker = {}; | |
function trampo(cb) { | |
return function(e, r) { | |
var d = depth++; | |
try { | |
if (depth === maxDepth) |
OlderNewer