From dfc2a9f807d1fe41f57f2d1de2b5db7a29c0efe8 Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Sat, 14 Mar 2015 21:15:26 +0100 Subject: [PATCH] issue #254 - bumped version to 0.12.0 and recompiled --- lib/callbacks/builtins.js | 2 +- lib/callbacks/compile.js | 2 +- lib/callbacks/flows.js | 2 +- lib/callbacks/runtime-all.js | 6 +- lib/callbacks/transform-all.js | 8 +- lib/fibers-fast/builtins.js | 2 +- lib/fibers-fast/flows.js | 2 +- lib/fibers/builtins.js | 2 +- lib/fibers/flows.js | 2 +- lib/generators-fast/builtins.js | 2 +- lib/generators-fast/flows.js | 2 +- lib/generators/builtins.js | 2 +- lib/generators/flows.js | 2 +- lib/generators/runtime-all.js | 553 +++++++++++++++++++++++- lib/generators/transform-all.js | 555 ++++++++++++++++++++++++- lib/streams/client/streams.js | 2 +- lib/version.js | 2 +- package.json | 2 +- test/common/callbacks/eval-test.js | 2 +- test/common/callbacks/flows-test.js | 2 +- test/common/callbacks/futures-test.js | 2 +- test/common/callbacks/stack-test.js | 2 +- test/common/generators/eval-test.js | 2 +- test/common/generators/flows-test.js | 2 +- test/common/generators/futures-test.js | 2 +- test/common/generators/stack-test.js | 2 +- 26 files changed, 1130 insertions(+), 36 deletions(-) diff --git a/lib/callbacks/builtins.js b/lib/callbacks/builtins.js index e752558e..2f3c6ce3 100644 --- a/lib/callbacks/builtins.js +++ b/lib/callbacks/builtins.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; diff --git a/lib/callbacks/compile.js b/lib/callbacks/compile.js index 23ef02c0..ab42bd01 100644 --- a/lib/callbacks/compile.js +++ b/lib/callbacks/compile.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; diff --git a/lib/callbacks/flows.js b/lib/callbacks/flows.js index 85e010cc..d12d1f92 100644 --- a/lib/callbacks/flows.js +++ b/lib/callbacks/flows.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; diff --git a/lib/callbacks/runtime-all.js b/lib/callbacks/runtime-all.js index 04b9c0cf..7f6ec842 100644 --- a/lib/callbacks/runtime-all.js +++ b/lib/callbacks/runtime-all.js @@ -63,13 +63,13 @@ function require(str) { /// /// * `fn = globals.withContext(fn, cx)` - /// wraps a function so that it executes with context `cx` (or with a new empty context if `cx` is falsy). + /// wraps a function so that it executes with context `cx` (or a wrapper around current context if `cx` is falsy). /// The previous context will be restored when the function returns (or throws). /// returns the wrapped function. g.withContext = function(fn, cx) { return function() { var oldContext = g.context; - g.context = cx || {}; + g.context = cx || Object.create(oldContext); try { return fn.apply(this, arguments) } finally { @@ -422,7 +422,7 @@ function require(str) { exports.stackTraceEnabled = true; })(typeof exports !== 'undefined' ? exports : (Streamline.runtime = Streamline.runtime || {})); require && require("../callbacks/builtins"); -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; diff --git a/lib/callbacks/transform-all.js b/lib/callbacks/transform-all.js index 5805ff5a..7ea02c14 100644 --- a/lib/callbacks/transform-all.js +++ b/lib/callbacks/transform-all.js @@ -7731,7 +7731,7 @@ function require(str) { })(); "use strict"; (function(exports) { - exports.version = "0.10.17"; + exports.version = "0.12.0"; })(typeof exports !== 'undefined' ? exports : (Streamline.version = Streamline.version || {})); "use strict"; (function() { @@ -9912,13 +9912,13 @@ if (typeof exports !== 'undefined') { /// /// * `fn = globals.withContext(fn, cx)` - /// wraps a function so that it executes with context `cx` (or with a new empty context if `cx` is falsy). + /// wraps a function so that it executes with context `cx` (or a wrapper around current context if `cx` is falsy). /// The previous context will be restored when the function returns (or throws). /// returns the wrapped function. g.withContext = function(fn, cx) { return function() { var oldContext = g.context; - g.context = cx || {}; + g.context = cx || Object.create(oldContext); try { return fn.apply(this, arguments) } finally { @@ -10271,7 +10271,7 @@ if (typeof exports !== 'undefined') { exports.stackTraceEnabled = true; })(typeof exports !== 'undefined' ? exports : (Streamline.runtime = Streamline.runtime || {})); require && require("../callbacks/builtins"); -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; diff --git a/lib/fibers-fast/builtins.js b/lib/fibers-fast/builtins.js index 1a76e923..771a3b05 100644 --- a/lib/fibers-fast/builtins.js +++ b/lib/fibers-fast/builtins.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (fibers-fast) --aggressive - DO NOT EDIT ***/var fstreamline__ = require("../fibers-fast/runtime");(function(){})(); fstreamline__.create(function(_) { /** +/*** Generated by streamline 0.12.0 (fibers-fast) --aggressive - DO NOT EDIT ***/var fstreamline__ = require("../fibers-fast/runtime");(function(){})(); fstreamline__.create(function(_) { /** * Copyright (c) 2012 Bruno Jouhier * MIT License */ diff --git a/lib/fibers-fast/flows.js b/lib/fibers-fast/flows.js index 976863d5..4ecf505e 100644 --- a/lib/fibers-fast/flows.js +++ b/lib/fibers-fast/flows.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (fibers-fast) --aggressive - DO NOT EDIT ***/var fstreamline__ = require("../fibers-fast/runtime");(function(){})(); fstreamline__.create(function(_) { /** +/*** Generated by streamline 0.12.0 (fibers-fast) --aggressive - DO NOT EDIT ***/var fstreamline__ = require("../fibers-fast/runtime");(function(){})(); fstreamline__.create(function(_) { /** * Copyright (c) 2011 Bruno Jouhier * * Permission is hereby granted, free of charge, to any person diff --git a/lib/fibers/builtins.js b/lib/fibers/builtins.js index 4042c4c4..95ebe981 100644 --- a/lib/fibers/builtins.js +++ b/lib/fibers/builtins.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (fibers) - DO NOT EDIT ***/var fstreamline__ = require("../fibers/runtime"); (function(){})();(fstreamline__.create(function(_) { /** +/*** Generated by streamline 0.12.0 (fibers) - DO NOT EDIT ***/var fstreamline__ = require("../fibers/runtime"); (function(){})();(fstreamline__.create(function(_) { /** * Copyright (c) 2012 Bruno Jouhier * MIT License */ diff --git a/lib/fibers/flows.js b/lib/fibers/flows.js index 07c710ae..79c9ef38 100644 --- a/lib/fibers/flows.js +++ b/lib/fibers/flows.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (fibers) - DO NOT EDIT ***/var fstreamline__ = require("../fibers/runtime"); (function(){})();(fstreamline__.create(function(_) { /** +/*** Generated by streamline 0.12.0 (fibers) - DO NOT EDIT ***/var fstreamline__ = require("../fibers/runtime"); (function(){})();(fstreamline__.create(function(_) { /** * Copyright (c) 2011 Bruno Jouhier * * Permission is hereby granted, free of charge, to any person diff --git a/lib/generators-fast/builtins.js b/lib/generators-fast/builtins.js index d422a242..d601ec91 100644 --- a/lib/generators-fast/builtins.js +++ b/lib/generators-fast/builtins.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators-fast) - DO NOT EDIT ***/var galaxy = require("../generators-fast/runtime");(function(){})();galaxy.unstar(function*(_) { /** +/*** Generated by streamline 0.12.0 (generators-fast) - DO NOT EDIT ***/var galaxy = require("../generators-fast/runtime");(function(){})();galaxy.unstar(function*(_) { /** * Copyright (c) 2012 Bruno Jouhier * MIT License */ diff --git a/lib/generators-fast/flows.js b/lib/generators-fast/flows.js index 262e121f..a9c0a0f8 100644 --- a/lib/generators-fast/flows.js +++ b/lib/generators-fast/flows.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators-fast) - DO NOT EDIT ***/var galaxy = require("../generators-fast/runtime");(function(){})();galaxy.unstar(function*(_) { /** +/*** Generated by streamline 0.12.0 (generators-fast) - DO NOT EDIT ***/var galaxy = require("../generators-fast/runtime");(function(){})();galaxy.unstar(function*(_) { /** * Copyright (c) 2011 Bruno Jouhier * * Permission is hereby granted, free of charge, to any person diff --git a/lib/generators/builtins.js b/lib/generators/builtins.js index 097d8777..c6a4ae89 100644 --- a/lib/generators/builtins.js +++ b/lib/generators/builtins.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** * Copyright (c) 2012 Bruno Jouhier * MIT License */ diff --git a/lib/generators/flows.js b/lib/generators/flows.js index 75e0fac1..1d2da850 100644 --- a/lib/generators/flows.js +++ b/lib/generators/flows.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** * Copyright (c) 2011 Bruno Jouhier * * Permission is hereby granted, free of charge, to any person diff --git a/lib/generators/runtime-all.js b/lib/generators/runtime-all.js index 869b6487..2d8ddc82 100644 --- a/lib/generators/runtime-all.js +++ b/lib/generators/runtime-all.js @@ -17,7 +17,554 @@ function require(str) { else if (str == "galaxy-stack") return null; else alert("cannot require " + str) } +"use strict"; +/** + * Copyright (c) 2013 Bruno Jouhier + * MIT License + */ +(function(exports) { + + /// + /// # Main galaxy module + /// + /// `var galaxy = require('galaxy');` + /// + + function link(src, name, dst) { + Object.defineProperty(src, name, { + configurable: false, + writable: true, + enumerable: false, + value: dst + }); + return dst; + } + + + function makeArgs(i) { + if (i <= 0) return ""; + return i > 1 ? makeArgs(i - 1) + ', a' + i : "a1"; + } + + // glob is the hidden global in which we store the context. + // it must be unique, even if we have several versions of the galaxy module. + var glob = (function() { + var gl = typeof global === "object" ? global : window; + // share the secret with streamline's global module. + var secret = "_20c7abceb95c4eb88b7ca1895b1170d1"; + return gl[secret] || link(gl, secret, { context: {} }); + })(); + + if (typeof glob.yielded === "undefined") glob.yielded = true; + glob.PENDING = glob.PENDING || {}; + + var stackHelper, stackHelperError; + try { + stackHelper = require('galaxy-stack'); + } catch (ex) { + stackHelperError = ex.message; + } + + function future(fn, args, i) { + var err, result, done, q = [], + self = this; + args = Array.prototype.slice.call(args); + args[i] = function(e, r) { + //if (arguments.length > 2) r = Array.prototype.slice.call(arguments, 1); + err = e, result = r, done = true; + q && q.forEach(function(f) { + f.call(self, e, r); + }); + q = null; + }; + fn.apply(this, args); + return function F(cb) { + if (typeof cb !== 'function') { + if (cb !== false) throw new Error("invalid argument #0: you must pass _ or !_"); + return F; + } + if (done) cb.call(self, err, result); + else q.push(cb); + } + } + + + function isGenerator(val) { + return Object.prototype.toString.call(val) === "[object Generator]"; + } + + function Frame(g) { + this.g = g; + this.prev = glob.frame; + g.frame = this; + this._info = null; + this.recurse = 0; + this.yielded = 0; + } + + Object.defineProperty(Frame.prototype, "info", { + get: function() { + return this._info || stackHelper.getStackFrame(this.g); + } + }); + + Object.defineProperty(Frame.prototype, "name", { + get: function() { return this.info.functionName; } + }); + + Object.defineProperty(Frame.prototype, "file", { + get: function() { return this.info.scriptName; } + }); + + Object.defineProperty(Frame.prototype, "line", { + get: function() { return this.info.lineNumber; } + }); + + function pushFrame(g) { + glob.frame = g.frame = g.frame || new Frame(g); + glob.emitter.emit('enter', g.frame); + } + + function popFrame(g) { + if (!glob.frame) return; + glob.emitter.emit('exit', g.frame); + glob.frame = glob.frame.prev; + } + + function run(g, cb, options) { + var rsm = glob.resume; + var emit = glob.emitter && stackHelper && function(ev, g) { + g.frame = g.frame || new Frame(g); + glob.emitter.emit(ev, g.frame); + } + + try { + glob.resume = function(err, val) { + if (emit && glob.yielded) { + emit("resume", g); + glob.yielded = false; + } + while (g) { + if (options && options.interrupt && options.interrupt()) return; + try { + // ES6 is deprecating send in favor of next. Following line makes us compatible with both. + var send = g.send || g.next; + var v = err ? g.throw (err) : send.call(g, val); + val = v.value; + err = null; + // if we get PENDING, the current call completed with a pending I/O + // resume will be called again when the I/O completes. So just save the context and return here. + if (val === glob.PENDING) { + if (emit && !glob.yielded) { + emit("yield", g); + glob.yielded = true; + } + return; + } + // if we get [PENDING, e, r], the current call invoked its callback synchronously + // we just loop to send/throw what the callback gave us. + if (val && val[0] === glob.PENDING) { + err = val[1]; + val = val[2]; + if (err) err = wrapError(err, g, glob.resume); + } + // else, if g is done we unwind it we send val to the parent generator (or through cb if we are at the top) + else if (v.done) { + //g.close(); + if (emit) popFrame(g); + g = g.prev; + } + // else if val is not a generator we have an error. Yield was not applied to a generators + else { + if (!isGenerator(val)) { + // but we accept an array of generators, and we parallelize in this case + if (!Array.isArray(val)) throw new Error("invalid value was yielded. Expected a generator, got " + val); + val = val.mapStar(-1, function*(elt) { + if (!isGenerator(elt)) throw new Error("invalid array element was yielded. Expected a generator, got " + elt); + return yield elt; + }); + } + // we got a new generator which means that g called another generator function + // the new generator become current and we loop with g.send(undefined) (equiv to g.next()) + val.prev = g; + g = val; + if (emit) pushFrame(g); + val = undefined; + } + } catch (ex) { + // the send/throw call failed. + // we unwind the current generator and we rethrow into the parent generator (or through cb if at the top) + //g.close(); + err = wrapError(ex, g, glob.resume); + if (emit) popFrame(g); + g = g.prev; + val = undefined; + } + } + // we have exhausted the stack of generators. + // return the result or error through the callback. + cb(err, val); + } + + // start the resume loop + glob.resume(); + } finally { + // restore resume global + glob.resume = rsm; + } + } + + function mapResults(options, args) { + if (options && typeof options === "object") { + if (options.returnArray) return args; + if (options.returnObject) return options.returnObject.reduce(function(res, key, i) { + res[key] = args[i]; + return res; + }, {}); + } + return args[0]; + } + function getTag(options, idx) { + if (options && typeof options === "object") { + if (options.returnArray) return "A" + idx; + if (options.returnObject) return "O" + options.returnObject.join('/') + idx; + } + return idx; + } + + function invoke(that, fn, args, idx, options) { + if (fn['__unstarred__' + idx]) throw new Error("cannot invoke starred function: " + fn['__unstarred__' + idx]); + // Set things up so that call returns: + // * PENDING if it completes with a pending I/O (and cb will be called later) + // * [PENDING, e, r] if the callback is called synchronously. + var result = glob.PENDING, + sync = true; + var rsm = glob.resume; + + // convert args to array so that args.length gets correctly set if idx is args.length + args = Array.prototype.slice.call(args, 0); + var cx = glob.context; + args[idx == null ? args.length : idx] = function(e, r) { + var oldContext = glob.context; + var oldResume = glob.resume; + try { + if (options) r = mapResults(options, Array.prototype.slice.call(arguments, 1)); + glob.context = cx; + glob.resume = rsm; + if (sync) { + result = [glob.PENDING, e, r]; + } else { + glob.resume(e, r); + } + } finally { + glob.context = oldContext; + glob.resume = oldResume; + } + } + fn.apply(that, args); + sync = false; + return result; + } + + function convertAPI(converter, api, idx) { + if (typeof idx === 'string') { + var fn = api[idx]; + if (typeof fn !== 'function') throw new Error("not a function: " + idx); + return converter(fn.bind(api)); + } + return Object.keys(api).reduce(function(result, key) { + var fn = api[key]; + result[key] = (typeof fn === 'function' && !/Sync$/.test(fn.name)) ? converter(fn, idx) : fn; + return result; + }, {}); + } + + /// + /// ## API wrappers + /// + /// * `var genFn = galaxy.star(asyncFn, cbIndex)` + /// This function turns an asynchronous function into a generator function. + /// `asyncFn` is the asynchronous function. + /// `cbIndex` is the index of the callback parameter. It is optional. + /// If omitted the callback is assumed to be the last parameter of `asyncFn`. + var starTemplate = function star(fn, options) { + if (typeof fn === 'object') return convertAPI(exports.star, fn, options); + + var idx = (options && typeof options === 'object') ? options.callbackIndex : options; + var idx2 = idx < 0 ? -(idx + 1) : idx; + var tag = getTag(options, idx); + + var key = '__starred__' + tag; + if (fn[key]) return fn[key]; + + //if (idx == null) idx = fn.length - 1; + + var F = function *() { + if (idx < 0) Array.prototype.splice.call(arguments, idx2, 0, null); + return (yield invoke(this, fn, arguments, idx2, options)); + }; + link(F, '__unstarred__' + tag, fn); + link(fn, key, F); + return F; + } + + var starBody = starTemplate.toString(); + starBody = starBody.substring(starBody.indexOf('{')); + var starrors = []; + + function makeStarror(i) { + return eval("(function(fn, options)" + starBody.replace(/function\s*\*\s*\(\)/, "function*(" + makeArgs(i) + ")") + ")"); + } + + exports.star = function(fn, idx) { + var i = fn.length; + var starror = starrors[i] || (starrors[i] = makeStarror(i)); + return starror(fn, idx); + } + + /// * `var asyncFn = galaxy.unstar(genFn, cbIndex)` + /// This function converts in the other direction. It allows you to turn a generator function into an asynchronous function. + /// `genFn` is the generator function. + /// `cbIndex` is the index of the callback parameter. It is optional. If omitted the callback is added at the end of the parameter list of `genFn`. + /// + /// As previously mentioned these calls may also be applied to a whole module, or to any object containing functions. + /// `Sync` calls are skipped. + // entering is undocumented streamline parameter for future. + var unstarTemplate = function unstar(fn, options, entering) { + if (typeof fn === 'object') return convertAPI(exports.unstar, fn, options); + + var idx = (options && typeof options === 'object') ? options.callbackIndex : options; + if (idx == null) idx = fn.length; + var idx2 = idx < 0 ? -(idx + 1) : idx; + + var key = '__unstarred__' + idx; + if (fn[key]) return fn[key]; + + var F = function() { + var cb = arguments[idx2]; + if (idx < 0) Array.prototype.splice.call(arguments, idx2, 1); + // preserve streamline future semantics in unstarred space. + if (typeof cb !== 'function') { + if (entering && !cb) cb = arguments[idx2] = function(err) { if (err) throw err; }; + return ((options && options.promise) || future).call(this, F, arguments, idx2); + } + var g = fn.apply(this, arguments); + run.call(this, g, cb); + }; + link(F, '__starred__' + idx, fn); + link(fn, key, F); + return F; + } + + var unstarBody = unstarTemplate.toString(); + unstarBody = unstarBody.substring(unstarBody.indexOf('{')); + var unstarrors = []; + + function makeUnstarror(i) { + return eval("(function(fn, options, entering)" + unstarBody.replace(/function\s*\(\)/, "function(" + makeArgs(i) + ")") + ")"); + } + + exports.unstar = function(fn, idx, entering) { + var i = idx == null ? fn.length + 1 : fn.length; + var unstarror = unstarrors[i] || (unstarrors[i] = makeUnstarror(i)); + return unstarror(fn, idx, entering); + } + + + /// + /// ## Parallelizing + /// + /// * `var genFn = galaxy.spin(generator)` + /// Start spinning a generator that you obtained by calling a starred function (without yield). + /// The generator will execute in parallel with other code, at the points where the code yields. + /// The returned value is a generator function on which you can yield later to obtain the result of the computation. + exports.spin = function(g, options) { + if (!isGenerator(g)) throw new Error("Invalid spin call, expected a generator, got " + g); + var that = this; + // use starTemplate rather than galaxy.star because future has arity of 1 and we want arity of 0 + return starTemplate(future(function(cb) { + run.call(that, g, cb, options); + }, [], 0), 0); + } + + /// * `fun = galaxy.funnel(max)` + /// limits the number of concurrent executions of a given code block. + /// + /// The `funnel` function is typically used with the following pattern: + /// + /// ``` javascript + /// // somewhere + /// var myFunnel = galaxy.funnel(10); // create a funnel that only allows 10 concurrent executions. + /// + /// // elsewhere + /// var result = yield myFunnel(function* () { /* code with at most 10 concurrent executions */ }); + /// ``` + /// + /// The `funnel` function can also be used to implement critical sections. Just set funnel's `max` parameter to 1. + /// + /// If `max` is set to 0, a default number of parallel executions is allowed. + /// This default number can be read and set via `galaxy.funnel.defaultSize`. + /// If `max` is negative, the funnel does not limit the level of parallelism. + /// + /// The funnel can be closed with `fun.close()`. + /// When a funnel is closed, the operations that are still in the funnel will continue but their callbacks + /// won't be called, and no other operation will enter the funnel. + exports.funnel = function(max) { + max = max == null ? -1 : max; + if (max === 0) max = funnel.defaultSize; + if (typeof max !== "number") throw new Error("bad max number: " + max); + var queue = [], + active = 0, + closed = false; + + var fun = exports.star(function(fnStar, callback) { + var fn = exports.unstar(fnStar); + if (max < 0 || max == Infinity) return fn(callback); + + queue.push({ + fn: fn, + cb: callback + }); + + function _doOne() { + var current = queue.splice(0, 1)[0]; + if (!current.cb) return current.fn(); + active++; + current.fn(function(err, result) { + active--; + if (!closed) { + current.cb(err, result); + while (active < max && queue.length > 0) _doOne(); + } + }); + } + + while (active < max && queue.length > 0) _doOne(); + }); + fun.close = function() { + queue = [], closed = true; + } + return fun; + } + + exports.funnel.defaultSize = 4; + + /// + /// ## Stable context (TLS-like) + /// + /// * `galaxy.context = ctx` + /// `ctx = galaxy.context` + /// Sets and gets the stable context. + Object.defineProperty(exports, 'context', { + set: function(val) { + glob.context = val; + }, + get: function() { + return glob.context; + } + }); + + /// + /// ## Miscellaneous + /// + /// * `var genCreate = galaxy.new(genConstructor)` + /// Converts a constructor generator function to a _creator_ function. + /// `genConstructor` is a _starred_ constructor that may contain `yield` calls. + /// The returned `genCreate` is a _starred_ function that you can call as `yield genCreate(args)` + + // undocumented idx is set by streamline because prototype is on unstarred function in this case + exports.new = function(constructor, idx) { + var key = '__new__' + idx; + if (constructor[key]) return constructor[key]; + + var F = function *() { + var that = Object.create((idx != null ? constructor['__unstarred__' + idx] : constructor).prototype); + yield constructor.apply(that, arguments); + return that; + }; + link(constructor, key, F); + return F; + } + + // undocumented helper for streamline compat + exports.invoke = function *(that, fn, args, options) { + var idx = (options && typeof options === 'object') ? options.callbackIndex : options; + var tag = getTag(options, idx); + if (typeof fn !== 'function') { + if (typeof that === 'function' && that['__starred__' + tag] && fn === 'call') { + return yield that['__starred__' + tag].apply(args[0], args.slice(1)); + } + fn = that[fn]; + } + return yield exports.star(fn, options).apply(that, args); + } + + function wrapError(err, g, resume) { + if (!(err instanceof Error)) return err; // handle throw "some string"; + if (err.__async__ && err.__async__.resume === resume) return err; + var continuations = []; + g = g.prev; // first frame will be in err.stack + if (stackHelper) { + for (var gg = g; gg; gg = gg.prev) { + continuations.push(stackHelper.getContinuation(gg)); + } + } + err = Object.create(err); + Object.defineProperty(err, 'stack', { + get: function() { + return stackTrace(this); + } + }); + link(err, "__async__", { + continuations: continuations, + generator: g, + resume: resume, + }); + return err; + } + + function stackTrace(err) { + var extra; + var starredStack = ""; + while (extra = err.__async__) { + if (stackHelper) { + var frames = []; + for (var g = extra.generator; g; g = g.prev) { + var frame = stackHelper.getStackFrame(g, extra.continuations[frames.length]); + frames.push(frame); + } + starredStack = frames.filter(function(frame){ + return !(frame.functionName === "exports.invoke" && /\/galaxy\/lib\/galaxy/.test(frame.scriptName)); + }).map(function(frame) { + return ' at ' + frame.functionName + ' (' + frame.scriptName + ':' + frame.lineNumber + ':' + frame.column + ')'; + }).join('\n') + '\n' + starredStack; + } + err = Object.getPrototypeOf(err); + } + if (!stackHelper) starredStack = ' UNAVAILABLE: ' + stackHelperError + '\n'; + + var rawStack = err.stack; + var cut = rawStack.indexOf(' at GeneratorFunctionPrototype'); + if (cut < 0) cut = rawStack.indexOf('\n') + 1; + var result = rawStack.substring(0, cut) + // + ' <<< yield stack >>>\n' + starredStack + // + ' <<< raw stack >>>\n' + rawStack.substring(cut); + return result; + } + + /// * `galaxy.main(function*() { ... })` + /// Wrapper for a main asynchronous script. + /// See the [tutorial](../tutorial/tutorial.md) for an example + exports.main = function(fn) { + var that = this; + exports.unstar(function*() { + yield fn.call(that); + })(function(err) { + if (err) throw err; + }); + } +})(typeof exports !== 'undefined' ? exports : (window.galaxy = window.galaxy || {})); /// /// # Container for global context /// @@ -65,13 +612,13 @@ function require(str) { /// /// * `fn = globals.withContext(fn, cx)` - /// wraps a function so that it executes with context `cx` (or with a new empty context if `cx` is falsy). + /// wraps a function so that it executes with context `cx` (or a wrapper around current context if `cx` is falsy). /// The previous context will be restored when the function returns (or throws). /// returns the wrapped function. g.withContext = function(fn, cx) { return function() { var oldContext = g.context; - g.context = cx || {}; + g.context = cx || Object.create(oldContext); try { return fn.apply(this, arguments) } finally { @@ -178,7 +725,7 @@ function require(str) { exports.then = exports.star(fut.then, 2); })(typeof exports !== 'undefined' ? module.exports = Object.create(require('galaxy')) : Streamline.runtime = Streamline.runtime || Object.create(require('galaxy'))); -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** * Copyright (c) 2012 Bruno Jouhier * MIT License */ diff --git a/lib/generators/transform-all.js b/lib/generators/transform-all.js index f688639f..32a5bc16 100644 --- a/lib/generators/transform-all.js +++ b/lib/generators/transform-all.js @@ -7733,7 +7733,7 @@ function require(str) { })(); "use strict"; (function(exports) { - exports.version = "0.10.17"; + exports.version = "0.12.0"; })(typeof exports !== 'undefined' ? exports : (Streamline.version = Streamline.version || {})); "use strict"; (function() { @@ -8739,7 +8739,554 @@ if (typeof exports !== 'undefined') { } } })(typeof exports !== 'undefined' ? exports : (window.Streamline = window.Streamline || {})); +"use strict"; +/** + * Copyright (c) 2013 Bruno Jouhier + * MIT License + */ +(function(exports) { + + /// + /// # Main galaxy module + /// + /// `var galaxy = require('galaxy');` + /// + + function link(src, name, dst) { + Object.defineProperty(src, name, { + configurable: false, + writable: true, + enumerable: false, + value: dst + }); + return dst; + } + + + function makeArgs(i) { + if (i <= 0) return ""; + return i > 1 ? makeArgs(i - 1) + ', a' + i : "a1"; + } + + // glob is the hidden global in which we store the context. + // it must be unique, even if we have several versions of the galaxy module. + var glob = (function() { + var gl = typeof global === "object" ? global : window; + // share the secret with streamline's global module. + var secret = "_20c7abceb95c4eb88b7ca1895b1170d1"; + return gl[secret] || link(gl, secret, { context: {} }); + })(); + + if (typeof glob.yielded === "undefined") glob.yielded = true; + glob.PENDING = glob.PENDING || {}; + + var stackHelper, stackHelperError; + try { + stackHelper = require('galaxy-stack'); + } catch (ex) { + stackHelperError = ex.message; + } + + function future(fn, args, i) { + var err, result, done, q = [], + self = this; + args = Array.prototype.slice.call(args); + args[i] = function(e, r) { + //if (arguments.length > 2) r = Array.prototype.slice.call(arguments, 1); + err = e, result = r, done = true; + q && q.forEach(function(f) { + f.call(self, e, r); + }); + q = null; + }; + fn.apply(this, args); + return function F(cb) { + if (typeof cb !== 'function') { + if (cb !== false) throw new Error("invalid argument #0: you must pass _ or !_"); + return F; + } + if (done) cb.call(self, err, result); + else q.push(cb); + } + } + + + function isGenerator(val) { + return Object.prototype.toString.call(val) === "[object Generator]"; + } + + function Frame(g) { + this.g = g; + this.prev = glob.frame; + g.frame = this; + this._info = null; + this.recurse = 0; + this.yielded = 0; + } + + Object.defineProperty(Frame.prototype, "info", { + get: function() { + return this._info || stackHelper.getStackFrame(this.g); + } + }); + + Object.defineProperty(Frame.prototype, "name", { + get: function() { return this.info.functionName; } + }); + + Object.defineProperty(Frame.prototype, "file", { + get: function() { return this.info.scriptName; } + }); + + Object.defineProperty(Frame.prototype, "line", { + get: function() { return this.info.lineNumber; } + }); + + function pushFrame(g) { + glob.frame = g.frame = g.frame || new Frame(g); + glob.emitter.emit('enter', g.frame); + } + + function popFrame(g) { + if (!glob.frame) return; + glob.emitter.emit('exit', g.frame); + glob.frame = glob.frame.prev; + } + + function run(g, cb, options) { + var rsm = glob.resume; + var emit = glob.emitter && stackHelper && function(ev, g) { + g.frame = g.frame || new Frame(g); + glob.emitter.emit(ev, g.frame); + } + + try { + glob.resume = function(err, val) { + if (emit && glob.yielded) { + emit("resume", g); + glob.yielded = false; + } + while (g) { + if (options && options.interrupt && options.interrupt()) return; + try { + // ES6 is deprecating send in favor of next. Following line makes us compatible with both. + var send = g.send || g.next; + var v = err ? g.throw (err) : send.call(g, val); + val = v.value; + err = null; + // if we get PENDING, the current call completed with a pending I/O + // resume will be called again when the I/O completes. So just save the context and return here. + if (val === glob.PENDING) { + if (emit && !glob.yielded) { + emit("yield", g); + glob.yielded = true; + } + return; + } + // if we get [PENDING, e, r], the current call invoked its callback synchronously + // we just loop to send/throw what the callback gave us. + if (val && val[0] === glob.PENDING) { + err = val[1]; + val = val[2]; + if (err) err = wrapError(err, g, glob.resume); + } + // else, if g is done we unwind it we send val to the parent generator (or through cb if we are at the top) + else if (v.done) { + //g.close(); + if (emit) popFrame(g); + g = g.prev; + } + // else if val is not a generator we have an error. Yield was not applied to a generators + else { + if (!isGenerator(val)) { + // but we accept an array of generators, and we parallelize in this case + if (!Array.isArray(val)) throw new Error("invalid value was yielded. Expected a generator, got " + val); + val = val.mapStar(-1, function*(elt) { + if (!isGenerator(elt)) throw new Error("invalid array element was yielded. Expected a generator, got " + elt); + return yield elt; + }); + } + // we got a new generator which means that g called another generator function + // the new generator become current and we loop with g.send(undefined) (equiv to g.next()) + val.prev = g; + g = val; + if (emit) pushFrame(g); + val = undefined; + } + } catch (ex) { + // the send/throw call failed. + // we unwind the current generator and we rethrow into the parent generator (or through cb if at the top) + //g.close(); + err = wrapError(ex, g, glob.resume); + if (emit) popFrame(g); + g = g.prev; + val = undefined; + } + } + // we have exhausted the stack of generators. + // return the result or error through the callback. + cb(err, val); + } + + // start the resume loop + glob.resume(); + } finally { + // restore resume global + glob.resume = rsm; + } + } + + function mapResults(options, args) { + if (options && typeof options === "object") { + if (options.returnArray) return args; + if (options.returnObject) return options.returnObject.reduce(function(res, key, i) { + res[key] = args[i]; + return res; + }, {}); + } + return args[0]; + } + + function getTag(options, idx) { + if (options && typeof options === "object") { + if (options.returnArray) return "A" + idx; + if (options.returnObject) return "O" + options.returnObject.join('/') + idx; + } + return idx; + } + + function invoke(that, fn, args, idx, options) { + if (fn['__unstarred__' + idx]) throw new Error("cannot invoke starred function: " + fn['__unstarred__' + idx]); + // Set things up so that call returns: + // * PENDING if it completes with a pending I/O (and cb will be called later) + // * [PENDING, e, r] if the callback is called synchronously. + var result = glob.PENDING, + sync = true; + var rsm = glob.resume; + + // convert args to array so that args.length gets correctly set if idx is args.length + args = Array.prototype.slice.call(args, 0); + var cx = glob.context; + args[idx == null ? args.length : idx] = function(e, r) { + var oldContext = glob.context; + var oldResume = glob.resume; + try { + if (options) r = mapResults(options, Array.prototype.slice.call(arguments, 1)); + glob.context = cx; + glob.resume = rsm; + if (sync) { + result = [glob.PENDING, e, r]; + } else { + glob.resume(e, r); + } + } finally { + glob.context = oldContext; + glob.resume = oldResume; + } + } + fn.apply(that, args); + sync = false; + return result; + } + function convertAPI(converter, api, idx) { + if (typeof idx === 'string') { + var fn = api[idx]; + if (typeof fn !== 'function') throw new Error("not a function: " + idx); + return converter(fn.bind(api)); + } + return Object.keys(api).reduce(function(result, key) { + var fn = api[key]; + result[key] = (typeof fn === 'function' && !/Sync$/.test(fn.name)) ? converter(fn, idx) : fn; + return result; + }, {}); + } + + /// + /// ## API wrappers + /// + /// * `var genFn = galaxy.star(asyncFn, cbIndex)` + /// This function turns an asynchronous function into a generator function. + /// `asyncFn` is the asynchronous function. + /// `cbIndex` is the index of the callback parameter. It is optional. + /// If omitted the callback is assumed to be the last parameter of `asyncFn`. + var starTemplate = function star(fn, options) { + if (typeof fn === 'object') return convertAPI(exports.star, fn, options); + + var idx = (options && typeof options === 'object') ? options.callbackIndex : options; + var idx2 = idx < 0 ? -(idx + 1) : idx; + var tag = getTag(options, idx); + + var key = '__starred__' + tag; + if (fn[key]) return fn[key]; + + //if (idx == null) idx = fn.length - 1; + + var F = function *() { + if (idx < 0) Array.prototype.splice.call(arguments, idx2, 0, null); + return (yield invoke(this, fn, arguments, idx2, options)); + }; + link(F, '__unstarred__' + tag, fn); + link(fn, key, F); + return F; + } + + var starBody = starTemplate.toString(); + starBody = starBody.substring(starBody.indexOf('{')); + var starrors = []; + + function makeStarror(i) { + return eval("(function(fn, options)" + starBody.replace(/function\s*\*\s*\(\)/, "function*(" + makeArgs(i) + ")") + ")"); + } + + exports.star = function(fn, idx) { + var i = fn.length; + var starror = starrors[i] || (starrors[i] = makeStarror(i)); + return starror(fn, idx); + } + + /// * `var asyncFn = galaxy.unstar(genFn, cbIndex)` + /// This function converts in the other direction. It allows you to turn a generator function into an asynchronous function. + /// `genFn` is the generator function. + /// `cbIndex` is the index of the callback parameter. It is optional. If omitted the callback is added at the end of the parameter list of `genFn`. + /// + /// As previously mentioned these calls may also be applied to a whole module, or to any object containing functions. + /// `Sync` calls are skipped. + // entering is undocumented streamline parameter for future. + var unstarTemplate = function unstar(fn, options, entering) { + if (typeof fn === 'object') return convertAPI(exports.unstar, fn, options); + + var idx = (options && typeof options === 'object') ? options.callbackIndex : options; + if (idx == null) idx = fn.length; + var idx2 = idx < 0 ? -(idx + 1) : idx; + + var key = '__unstarred__' + idx; + if (fn[key]) return fn[key]; + + var F = function() { + var cb = arguments[idx2]; + if (idx < 0) Array.prototype.splice.call(arguments, idx2, 1); + // preserve streamline future semantics in unstarred space. + if (typeof cb !== 'function') { + if (entering && !cb) cb = arguments[idx2] = function(err) { if (err) throw err; }; + return ((options && options.promise) || future).call(this, F, arguments, idx2); + } + var g = fn.apply(this, arguments); + run.call(this, g, cb); + }; + link(F, '__starred__' + idx, fn); + link(fn, key, F); + return F; + } + + var unstarBody = unstarTemplate.toString(); + unstarBody = unstarBody.substring(unstarBody.indexOf('{')); + var unstarrors = []; + + function makeUnstarror(i) { + return eval("(function(fn, options, entering)" + unstarBody.replace(/function\s*\(\)/, "function(" + makeArgs(i) + ")") + ")"); + } + + exports.unstar = function(fn, idx, entering) { + var i = idx == null ? fn.length + 1 : fn.length; + var unstarror = unstarrors[i] || (unstarrors[i] = makeUnstarror(i)); + return unstarror(fn, idx, entering); + } + + + /// + /// ## Parallelizing + /// + /// * `var genFn = galaxy.spin(generator)` + /// Start spinning a generator that you obtained by calling a starred function (without yield). + /// The generator will execute in parallel with other code, at the points where the code yields. + /// The returned value is a generator function on which you can yield later to obtain the result of the computation. + exports.spin = function(g, options) { + if (!isGenerator(g)) throw new Error("Invalid spin call, expected a generator, got " + g); + var that = this; + // use starTemplate rather than galaxy.star because future has arity of 1 and we want arity of 0 + return starTemplate(future(function(cb) { + run.call(that, g, cb, options); + }, [], 0), 0); + } + + /// * `fun = galaxy.funnel(max)` + /// limits the number of concurrent executions of a given code block. + /// + /// The `funnel` function is typically used with the following pattern: + /// + /// ``` javascript + /// // somewhere + /// var myFunnel = galaxy.funnel(10); // create a funnel that only allows 10 concurrent executions. + /// + /// // elsewhere + /// var result = yield myFunnel(function* () { /* code with at most 10 concurrent executions */ }); + /// ``` + /// + /// The `funnel` function can also be used to implement critical sections. Just set funnel's `max` parameter to 1. + /// + /// If `max` is set to 0, a default number of parallel executions is allowed. + /// This default number can be read and set via `galaxy.funnel.defaultSize`. + /// If `max` is negative, the funnel does not limit the level of parallelism. + /// + /// The funnel can be closed with `fun.close()`. + /// When a funnel is closed, the operations that are still in the funnel will continue but their callbacks + /// won't be called, and no other operation will enter the funnel. + exports.funnel = function(max) { + max = max == null ? -1 : max; + if (max === 0) max = funnel.defaultSize; + if (typeof max !== "number") throw new Error("bad max number: " + max); + var queue = [], + active = 0, + closed = false; + + var fun = exports.star(function(fnStar, callback) { + var fn = exports.unstar(fnStar); + if (max < 0 || max == Infinity) return fn(callback); + + queue.push({ + fn: fn, + cb: callback + }); + + function _doOne() { + var current = queue.splice(0, 1)[0]; + if (!current.cb) return current.fn(); + active++; + current.fn(function(err, result) { + active--; + if (!closed) { + current.cb(err, result); + while (active < max && queue.length > 0) _doOne(); + } + }); + } + + while (active < max && queue.length > 0) _doOne(); + }); + fun.close = function() { + queue = [], closed = true; + } + return fun; + } + + exports.funnel.defaultSize = 4; + + /// + /// ## Stable context (TLS-like) + /// + /// * `galaxy.context = ctx` + /// `ctx = galaxy.context` + /// Sets and gets the stable context. + Object.defineProperty(exports, 'context', { + set: function(val) { + glob.context = val; + }, + get: function() { + return glob.context; + } + }); + + /// + /// ## Miscellaneous + /// + /// * `var genCreate = galaxy.new(genConstructor)` + /// Converts a constructor generator function to a _creator_ function. + /// `genConstructor` is a _starred_ constructor that may contain `yield` calls. + /// The returned `genCreate` is a _starred_ function that you can call as `yield genCreate(args)` + + // undocumented idx is set by streamline because prototype is on unstarred function in this case + exports.new = function(constructor, idx) { + var key = '__new__' + idx; + if (constructor[key]) return constructor[key]; + + var F = function *() { + var that = Object.create((idx != null ? constructor['__unstarred__' + idx] : constructor).prototype); + yield constructor.apply(that, arguments); + return that; + }; + link(constructor, key, F); + return F; + } + + // undocumented helper for streamline compat + exports.invoke = function *(that, fn, args, options) { + var idx = (options && typeof options === 'object') ? options.callbackIndex : options; + var tag = getTag(options, idx); + if (typeof fn !== 'function') { + if (typeof that === 'function' && that['__starred__' + tag] && fn === 'call') { + return yield that['__starred__' + tag].apply(args[0], args.slice(1)); + } + fn = that[fn]; + } + return yield exports.star(fn, options).apply(that, args); + } + + function wrapError(err, g, resume) { + if (!(err instanceof Error)) return err; // handle throw "some string"; + if (err.__async__ && err.__async__.resume === resume) return err; + var continuations = []; + g = g.prev; // first frame will be in err.stack + if (stackHelper) { + for (var gg = g; gg; gg = gg.prev) { + continuations.push(stackHelper.getContinuation(gg)); + } + } + err = Object.create(err); + Object.defineProperty(err, 'stack', { + get: function() { + return stackTrace(this); + } + }); + link(err, "__async__", { + continuations: continuations, + generator: g, + resume: resume, + }); + return err; + } + + function stackTrace(err) { + var extra; + var starredStack = ""; + while (extra = err.__async__) { + if (stackHelper) { + var frames = []; + for (var g = extra.generator; g; g = g.prev) { + var frame = stackHelper.getStackFrame(g, extra.continuations[frames.length]); + frames.push(frame); + } + starredStack = frames.filter(function(frame){ + return !(frame.functionName === "exports.invoke" && /\/galaxy\/lib\/galaxy/.test(frame.scriptName)); + }).map(function(frame) { + return ' at ' + frame.functionName + ' (' + frame.scriptName + ':' + frame.lineNumber + ':' + frame.column + ')'; + }).join('\n') + '\n' + starredStack; + } + err = Object.getPrototypeOf(err); + } + if (!stackHelper) starredStack = ' UNAVAILABLE: ' + stackHelperError + '\n'; + + var rawStack = err.stack; + var cut = rawStack.indexOf(' at GeneratorFunctionPrototype'); + if (cut < 0) cut = rawStack.indexOf('\n') + 1; + var result = rawStack.substring(0, cut) + // + ' <<< yield stack >>>\n' + starredStack + // + ' <<< raw stack >>>\n' + rawStack.substring(cut); + return result; + } + + /// * `galaxy.main(function*() { ... })` + /// Wrapper for a main asynchronous script. + /// See the [tutorial](../tutorial/tutorial.md) for an example + exports.main = function(fn) { + var that = this; + exports.unstar(function*() { + yield fn.call(that); + })(function(err) { + if (err) throw err; + }); + } +})(typeof exports !== 'undefined' ? exports : (window.galaxy = window.galaxy || {})); /// /// # Container for global context /// @@ -8787,13 +9334,13 @@ if (typeof exports !== 'undefined') { /// /// * `fn = globals.withContext(fn, cx)` - /// wraps a function so that it executes with context `cx` (or with a new empty context if `cx` is falsy). + /// wraps a function so that it executes with context `cx` (or a wrapper around current context if `cx` is falsy). /// The previous context will be restored when the function returns (or throws). /// returns the wrapped function. g.withContext = function(fn, cx) { return function() { var oldContext = g.context; - g.context = cx || {}; + g.context = cx || Object.create(oldContext); try { return fn.apply(this, arguments) } finally { @@ -8900,7 +9447,7 @@ if (typeof exports !== 'undefined') { exports.then = exports.star(fut.then, 2); })(typeof exports !== 'undefined' ? module.exports = Object.create(require('galaxy')) : Streamline.runtime = Streamline.runtime || Object.create(require('galaxy'))); -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("../generators/runtime");(function(){})();(galaxy.unstar(function*(_) { /** * Copyright (c) 2012 Bruno Jouhier * MIT License */ diff --git a/lib/streams/client/streams.js b/lib/streams/client/streams.js index 48ea71a0..c11f79f9 100644 --- a/lib/streams/client/streams.js +++ b/lib/streams/client/streams.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; diff --git a/lib/version.js b/lib/version.js index 71cd8c51..ab431ea5 100644 --- a/lib/version.js +++ b/lib/version.js @@ -1,4 +1,4 @@ "use strict"; (function(exports) { - exports.version = "0.10.17"; + exports.version = "0.12.0"; })(typeof exports !== 'undefined' ? exports : (Streamline.version = Streamline.version || {})); diff --git a/package.json b/package.json index 211d5a55..c3318345 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "streamline", "description": "Asynchronous Javascript for dummies", - "version": "0.10.17", + "version": "0.12.0", "homepage": "http://github.com/Sage/streamlinejs", "repository": { "type": "git", diff --git a/test/common/callbacks/eval-test.js b/test/common/callbacks/eval-test.js index 11849206..68c8c551 100644 --- a/test/common/callbacks/eval-test.js +++ b/test/common/callbacks/eval-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) --standalone - DO NOT EDIT ***/ var __rt=(function(){var __modules={},mod;function require(p){var m=__modules[p.substring(3)]; return m && m.exports};__modules['globals']=(mod={exports:{}});(function(module, exports){(function() {var glob = typeof global === "object" ? global : window;var secret = "_20c7abceb95c4eb88b7ca1895b1170d1";var g = glob[secret] || (glob[secret] = { context: {} });if (typeof exports !== 'undefined') {module.exports = g;} else {Streamline.globals = g;}g.runtime || Object.defineProperty(g, 'runtime', {get: function() { return g.__runtime__; },set: function(value) {if (g.__runtime__ !== value) {if (g.__runtime__) {if (/-fast$/.test(g.__runtime__) ||/-fast$/.test(value)) throw new Error("cannot mix streamline runtimes: " + g.__runtime__ + " and " + value);console.log("warning: mixing streamline runtimes: " + g.__runtime__ + " and " + value);}g.__runtime__ = value;}}});g.withContext = function(fn, cx) {return function() {var oldContext = g.context;g.context = cx || {};try {return fn.apply(this, arguments)} finally {g.context = oldContext;}};};g.setPromise = function(name) {if (g.Promise) return; var req = require; if (name === true) g.Promise = typeof Promise === "function" ? Promise : req('es6-promise');else g.Promise = require(name);};})();})(mod, mod.exports);__modules['util/future']=(mod={exports:{}});(function(module, exports){(function(exports) {var globals = require("../globals");exports.future = function(fn, args, i) {var err, result, done, q = [], self = this;args = Array.prototype.slice.call(args);args[i] = function(e, r) {err = e, result = r, done = true;q && q.forEach(function(f) {f.call(self, e, r);});q = null;};args[i].__futurecb = true;fn.apply(this, args);var ret = function F(cb) {if (typeof cb !== 'function') {var globals = require('../globals');if (cb == null && globals.Promise) return exports.promise.call(this, F, [], 0);if (cb !== false && !globals.oldStyleFutures) throw new Error("callback missing (argument #0). See https://github.com/Sage/streamlinejs/blob/master/FAQ.md#no-callback-given-error");return F;}if (done) cb.call(self, err, result);else q.push(cb);};ret.__future = true;return ret;};exports.streamlinify = function(fn, idx) {return function() {if (!arguments[idx]) return exports.future.call(this, fn, arguments, idx);else return fn.apply(this, arguments);};};exports.promise = function(fn, args, i) {if (args[i] === false) return exports.future.call(this, fn, args, i);if (args[i] != null) throw new Error("invalid callback: " + typeof(args[i]));if (globals.oldStyleFutures) return exports.future.call(this, fn, args, i);if (!globals.Promise) throw new Error("callback missing (argument #" + i + "). See https://github.com/Sage/streamlinejs/blob/master/FAQ.md#no-callback-given-error");var self = this;args = Array.prototype.slice.call(args);return new globals.Promise(function(resolve, reject) {args[i] = function(e, r) {if (e) reject(e);else resolve(r);};fn.apply(self, args);});};exports.then = function(promise, method, cb) {promise[method](function(r) {cb && cb(null, r);cb = null;}, function(e) {cb && cb(e);cb = null;});};})(typeof exports !== 'undefined' ? exports : (Streamline.future = Streamline.future || {}));})(mod, mod.exports);__modules['callbacks/runtime']=(mod={exports:{}});(function(module, exports){(function(exports) {var __g = require("../globals");__g.runtime = 'callbacks';var __fut = require("../util/future");__g.context = __g.context || {};__g.depth = __g.depth || 0;__g.async = __g.async || false;__g.trampoline = (function() {var q = [];return {queue: function(fn) {q.push(fn);},flush: function() {var oldContext = __g.context;__g.depth++;try {var fn;while (fn = q.shift()) fn();} finally {__g.context = oldContext;__g.depth--;}}}})();exports.runtime = function(filename, oldStyleFutures) {__g.oldStyleFutures = oldStyleFutures;function __func(_, __this, __arguments, fn, index, frame, body) {if (typeof _ !== 'function') return __fut.promise.call(__this, fn, __arguments, index);frame.file = filename;frame.prev = __g.frame;frame.calls = 0;if (frame.prev) frame.prev.calls++;var emitter = __g.emitter;__g.frame = frame;__g.depth++;if (emitter) emitter.emit("enter", frame, _); try {frame.active = true;body();} catch (e) {__setEF(e, frame.prev);__propagate(_, e);} finally {frame.active = false;if (emitter) {emitter.emit("exit", frame);}__g.frame = frame.prev;if (--__g.depth === 0 && __g.trampoline) __g.trampoline.flush();}}return {__g: __g,__func: __func,__cb: __cb,__future: __fut.future,__propagate: __propagate,__trap: __trap,__tryCatch: __tryCatch,__catch: __catch,__forIn: __forIn,__apply: __apply,__construct: __construct,__setEF: __setEF,streamlinify: __fut.streamlinify,__pthen: __fut.then,};};function __cb(_, frame, offset, col, fn, trampo, returnArray) {frame.offset = offset;frame.col = col;var ctx = __g.context;var calls = frame.calls;var emitter = __g.emitter;var ret = function ___(err, result) {if (returnArray) result = Array.prototype.slice.call(arguments, 1);returnArray = false; var oldFrame = __g.frame;__g.frame = frame;var oldContext = __g.context;__g.context = ctx;if (emitter && __g.depth === 0) emitter.emit('resume', frame);if (emitter) emitter.emit('enter', frame);__g.depth++;try {if (trampo && frame.active && __g.trampoline) {__g.trampoline.queue(function() {return ___(err, result);});} else {___.dispatched = true;if (err) {__setEF(err, frame);return _(err);}frame.active = true;return fn(null, result);}} catch (ex) {if (___.dispatched && _.name !== '___' && _.name !== '__trap' && calls !== frame.calls) throw ex;__setEF(ex, frame);return __propagate(_, ex);} finally {frame.active = false;if (emitter) emitter.emit("exit", frame);__g.frame = oldFrame;__g.context = oldContext;if (--__g.depth === 0 && __g.trampoline) __g.trampoline.flush();}};if (emitter && !ret.dispatched) emitter.emit('yield', frame);ret.__streamlined = true;return ret;}function __propagate(_, err) {try {_(err);} catch (ex) {__trap(ex);}}function __trap(err) {if (err) {if (__g.context && __g.context.errorHandler) __g.context.errorHandler(err);else __g.trampoline.queue(function() {throw err;});}}function __tryCatch(_, fn) {try {fn();} catch (e) {try {_(e);} catch (ex) {__trap(ex);}}}function __catch(fn, _) {var frame = __g.frame,context = __g.context;__g.trampoline.queue(function() {var oldFrame = __g.frame,oldContext = __g.context;__g.frame = frame;__g.context = context;try {fn();} catch (ex) {_(ex);} finally {__g.frame = oldFrame;__g.context = oldContext;}});}function __forIn(object) {var array = [];for (var obj in object) {array.push(obj);}return array;}function __apply(cb, fn, thisObj, args, index) {if (cb == null) return __fut.future(__apply, arguments, 0);args = Array.prototype.slice.call(args, 0);args[index != null ? index : args.length] = cb;return fn.apply(thisObj, args);}function __construct(constructor, i) {var key = '__async' + i,f;return constructor[key] || (constructor[key] = function() {var args = arguments;function F() {var self = this;var cb = args[i];args[i] = function(e, r) {cb(e, self);};args[i].__streamlined = cb.__streamlined;args[i].__futurecb = cb.__futurecb;return constructor.apply(self, args);}F.prototype = constructor.prototype;return new F();});}function __setEF(e, f) {function formatStack(e, raw) {var ff = typeof navigator === 'object' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;if (ff) raw = "Error: " + e.message + '\n' + raw;var s = raw,f, skip;var cut = (e.message || '').split('\n').length;var lines = s.split('\n');s = lines.slice(cut).map(function(l) {var m = /([^@]*)\@(.*?)\:(\d+)(?:\:(\d+))?$/.exec(l);l = m ? " at " + m[1] + " (" + m[2] + ":" + parseInt(m[3]) + ":" + (m[4] || "0") + ")" : l;var i = l.indexOf('__$');if (i >= 0 && !skip) {skip = true;return l.substring(0, i) + l.substring(i + 3);}return skip ? '' : l;}).filter(function(l) {return l;}).join('\n');s = lines.slice(0, cut).join('\n') + '\n <<< async stack >>>' + (skip ? '\n' + s : '');for (var f = e.__frame; f; f = f.prev) {if (f.offset >= 0) s += "\n at " + f.name + " (" + f.file + ":" + (f.line + f.offset) + ":" + (f.col+1) + ")"}s += '\n <<< raw stack >>>' + '\n' + lines.slice(cut).join('\n');return s;};e.__frame = e.__frame || f;if (exports.stackTraceEnabled && e.__lookupGetter__ && e.__lookupGetter__("rawStack") == null) {var getter = e.__lookupGetter__("stack");if (!getter) { var raw = e.stack || "raw stack unavailable";getter = function() {return raw;}}e.__defineGetter__("rawStack", getter);e.__defineGetter__("stack", function() {return formatStack(e, getter.call(this));});}}exports.stackTraceEnabled = true;})(typeof exports !== 'undefined' ? exports : (Streamline.runtime = Streamline.runtime || {}));require && require("../callbacks/builtins");})(mod, mod.exports);return __modules['callbacks/runtime'].exports.runtime('test/common/eval-test._js', false);})(),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch,__forIn=__rt.__forIn,__construct=__rt.__construct,__pthen=__rt.__pthen; QUnit.module(module.id); +/*** Generated by streamline 0.12.0 (callbacks) --standalone - DO NOT EDIT ***/ var __rt=(function(){var __modules={},mod;function require(p){var m=__modules[p.substring(3)]; return m && m.exports};__modules['globals']=(mod={exports:{}});(function(module, exports){(function() {var glob = typeof global === "object" ? global : window;var secret = "_20c7abceb95c4eb88b7ca1895b1170d1";var g = glob[secret] || (glob[secret] = { context: {} });if (typeof exports !== 'undefined') {module.exports = g;} else {Streamline.globals = g;}g.runtime || Object.defineProperty(g, 'runtime', {get: function() { return g.__runtime__; },set: function(value) {if (g.__runtime__ !== value) {if (g.__runtime__) {if (/-fast$/.test(g.__runtime__) ||/-fast$/.test(value)) throw new Error("cannot mix streamline runtimes: " + g.__runtime__ + " and " + value);console.log("warning: mixing streamline runtimes: " + g.__runtime__ + " and " + value);}g.__runtime__ = value;}}});g.withContext = function(fn, cx) {return function() {var oldContext = g.context;g.context = cx || Object.create(oldContext);try {return fn.apply(this, arguments)} finally {g.context = oldContext;}};};g.setPromise = function(name) {if (g.Promise) return; var req = require; if (name === true) g.Promise = typeof Promise === "function" ? Promise : req('es6-promise');else g.Promise = require(name);};})();})(mod, mod.exports);__modules['util/future']=(mod={exports:{}});(function(module, exports){(function(exports) {var globals = require("../globals");exports.future = function(fn, args, i) {var err, result, done, q = [], self = this;args = Array.prototype.slice.call(args);args[i] = function(e, r) {err = e, result = r, done = true;q && q.forEach(function(f) {f.call(self, e, r);});q = null;};args[i].__futurecb = true;fn.apply(this, args);var ret = function F(cb) {if (typeof cb !== 'function') {var globals = require('../globals');if (cb == null && globals.Promise) return exports.promise.call(this, F, [], 0);if (cb !== false && !globals.oldStyleFutures) throw new Error("callback missing (argument #0). See https://github.com/Sage/streamlinejs/blob/master/FAQ.md#no-callback-given-error");return F;}if (done) cb.call(self, err, result);else q.push(cb);};ret.__future = true;return ret;};exports.streamlinify = function(fn, idx) {return function() {if (!arguments[idx]) return exports.future.call(this, fn, arguments, idx);else return fn.apply(this, arguments);};};exports.promise = function(fn, args, i) {if (args[i] === false) return exports.future.call(this, fn, args, i);if (args[i] != null) throw new Error("invalid callback: " + typeof(args[i]));if (globals.oldStyleFutures) return exports.future.call(this, fn, args, i);if (!globals.Promise) throw new Error("callback missing (argument #" + i + "). See https://github.com/Sage/streamlinejs/blob/master/FAQ.md#no-callback-given-error");var self = this;args = Array.prototype.slice.call(args);return new globals.Promise(function(resolve, reject) {args[i] = function(e, r) {if (e) reject(e);else resolve(r);};fn.apply(self, args);});};exports.then = function(promise, method, cb) {promise[method](function(r) {cb && cb(null, r);cb = null;}, function(e) {cb && cb(e);cb = null;});};})(typeof exports !== 'undefined' ? exports : (Streamline.future = Streamline.future || {}));})(mod, mod.exports);__modules['callbacks/runtime']=(mod={exports:{}});(function(module, exports){(function(exports) {var __g = require("../globals");__g.runtime = 'callbacks';var __fut = require("../util/future");__g.context = __g.context || {};__g.depth = __g.depth || 0;__g.async = __g.async || false;__g.trampoline = (function() {var q = [];return {queue: function(fn) {q.push(fn);},flush: function() {var oldContext = __g.context;__g.depth++;try {var fn;while (fn = q.shift()) fn();} finally {__g.context = oldContext;__g.depth--;}}}})();exports.runtime = function(filename, oldStyleFutures) {__g.oldStyleFutures = oldStyleFutures;function __func(_, __this, __arguments, fn, index, frame, body) {if (typeof _ !== 'function') return __fut.promise.call(__this, fn, __arguments, index);frame.file = filename;frame.prev = __g.frame;frame.calls = 0;if (frame.prev) frame.prev.calls++;var emitter = __g.emitter;__g.frame = frame;__g.depth++;if (emitter) emitter.emit("enter", frame, _); try {frame.active = true;body();} catch (e) {__setEF(e, frame.prev);__propagate(_, e);} finally {frame.active = false;if (emitter) {emitter.emit("exit", frame);}__g.frame = frame.prev;if (--__g.depth === 0 && __g.trampoline) __g.trampoline.flush();}}return {__g: __g,__func: __func,__cb: __cb,__future: __fut.future,__propagate: __propagate,__trap: __trap,__tryCatch: __tryCatch,__catch: __catch,__forIn: __forIn,__apply: __apply,__construct: __construct,__setEF: __setEF,streamlinify: __fut.streamlinify,__pthen: __fut.then,};};function __cb(_, frame, offset, col, fn, trampo, returnArray) {frame.offset = offset;frame.col = col;var ctx = __g.context;var calls = frame.calls;var emitter = __g.emitter;var ret = function ___(err, result) {if (returnArray) result = Array.prototype.slice.call(arguments, 1);returnArray = false; var oldFrame = __g.frame;__g.frame = frame;var oldContext = __g.context;__g.context = ctx;if (emitter && __g.depth === 0) emitter.emit('resume', frame);if (emitter) emitter.emit('enter', frame);__g.depth++;try {if (trampo && frame.active && __g.trampoline) {__g.trampoline.queue(function() {return ___(err, result);});} else {___.dispatched = true;if (err) {__setEF(err, frame);return _(err);}frame.active = true;return fn(null, result);}} catch (ex) {if (___.dispatched && _.name !== '___' && _.name !== '__trap' && calls !== frame.calls) throw ex;__setEF(ex, frame);return __propagate(_, ex);} finally {frame.active = false;if (emitter) emitter.emit("exit", frame);__g.frame = oldFrame;__g.context = oldContext;if (--__g.depth === 0 && __g.trampoline) __g.trampoline.flush();}};if (emitter && !ret.dispatched) emitter.emit('yield', frame);ret.__streamlined = true;return ret;}function __propagate(_, err) {try {_(err);} catch (ex) {__trap(ex);}}function __trap(err) {if (err) {if (__g.context && __g.context.errorHandler) __g.context.errorHandler(err);else __g.trampoline.queue(function() {throw err;});}}function __tryCatch(_, fn) {try {fn();} catch (e) {try {_(e);} catch (ex) {__trap(ex);}}}function __catch(fn, _) {var frame = __g.frame,context = __g.context;__g.trampoline.queue(function() {var oldFrame = __g.frame,oldContext = __g.context;__g.frame = frame;__g.context = context;try {fn();} catch (ex) {_(ex);} finally {__g.frame = oldFrame;__g.context = oldContext;}});}function __forIn(object) {var array = [];for (var obj in object) {array.push(obj);}return array;}function __apply(cb, fn, thisObj, args, index) {if (cb == null) return __fut.future(__apply, arguments, 0);args = Array.prototype.slice.call(args, 0);args[index != null ? index : args.length] = cb;return fn.apply(thisObj, args);}function __construct(constructor, i) {var key = '__async' + i,f;return constructor[key] || (constructor[key] = function() {var args = arguments;function F() {var self = this;var cb = args[i];args[i] = function(e, r) {cb(e, self);};args[i].__streamlined = cb.__streamlined;args[i].__futurecb = cb.__futurecb;return constructor.apply(self, args);}F.prototype = constructor.prototype;return new F();});}function __setEF(e, f) {function formatStack(e, raw) {var ff = typeof navigator === 'object' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;if (ff) raw = "Error: " + e.message + '\n' + raw;var s = raw,f, skip;var cut = (e.message || '').split('\n').length;var lines = s.split('\n');s = lines.slice(cut).map(function(l) {var m = /([^@]*)\@(.*?)\:(\d+)(?:\:(\d+))?$/.exec(l);l = m ? " at " + m[1] + " (" + m[2] + ":" + parseInt(m[3]) + ":" + (m[4] || "0") + ")" : l;var i = l.indexOf('__$');if (i >= 0 && !skip) {skip = true;return l.substring(0, i) + l.substring(i + 3);}return skip ? '' : l;}).filter(function(l) {return l;}).join('\n');s = lines.slice(0, cut).join('\n') + '\n <<< async stack >>>' + (skip ? '\n' + s : '');for (var f = e.__frame; f; f = f.prev) {if (f.offset >= 0) s += "\n at " + f.name + " (" + f.file + ":" + (f.line + f.offset) + ":" + (f.col+1) + ")"}s += '\n <<< raw stack >>>' + '\n' + lines.slice(cut).join('\n');return s;};e.__frame = e.__frame || f;if (exports.stackTraceEnabled && e.__lookupGetter__ && e.__lookupGetter__("rawStack") == null) {var getter = e.__lookupGetter__("stack");if (!getter) { var raw = e.stack || "raw stack unavailable";getter = function() {return raw;}}e.__defineGetter__("rawStack", getter);e.__defineGetter__("stack", function() {return formatStack(e, getter.call(this));});}}exports.stackTraceEnabled = true;})(typeof exports !== 'undefined' ? exports : (Streamline.runtime = Streamline.runtime || {}));require && require("../callbacks/builtins");})(mod, mod.exports);return __modules['callbacks/runtime'].exports.runtime('test/common/eval-test._js', false);})(),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch,__forIn=__rt.__forIn,__construct=__rt.__construct,__pthen=__rt.__pthen; QUnit.module(module.id); function evalTest(f, val) { f(function (err, result) { diff --git a/test/common/callbacks/flows-test.js b/test/common/callbacks/flows-test.js index 7b400ea1..ad0dd95d 100644 --- a/test/common/callbacks/flows-test.js +++ b/test/common/callbacks/flows-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; QUnit.module(module.id); +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; QUnit.module(module.id); var flows = require('streamline/lib/util/flows'); function delay(_, val) { var __frame = { name: 'delay', line: 4 }; return __func(_, this, arguments, delay, 0, __frame, function __$delay() { diff --git a/test/common/callbacks/futures-test.js b/test/common/callbacks/futures-test.js index f0660bf2..e973ab1b 100644 --- a/test/common/callbacks/futures-test.js +++ b/test/common/callbacks/futures-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; QUnit.module(module.id); +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; QUnit.module(module.id); function delay(millis, val, _) { var __frame = { name: 'delay', line: 3 }; return __func(_, this, arguments, delay, 2, __frame, function __$delay() { return setTimeout(__cb(_, __frame, 1, 0, function __$delay() { diff --git a/test/common/callbacks/stack-test.js b/test/common/callbacks/stack-test.js index 636d33b2..7b15225b 100644 --- a/test/common/callbacks/stack-test.js +++ b/test/common/callbacks/stack-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; +/*** Generated by streamline 0.12.0 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; QUnit.module(module.id); diff --git a/test/common/generators/eval-test.js b/test/common/generators/eval-test.js index 15eed06e..93b5b96f 100644 --- a/test/common/generators/eval-test.js +++ b/test/common/generators/eval-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var delay_ = galaxy.unstar(delay, 0), delayFail_ = galaxy.unstar(delayFail, 0); QUnit.module(module.id); +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var delay_ = galaxy.unstar(delay, 0), delayFail_ = galaxy.unstar(delayFail, 0); QUnit.module(module.id); function evalTest(f, val) { f( function(err, result) { diff --git a/test/common/generators/flows-test.js b/test/common/generators/flows-test.js index a2172987..5a1f74a4 100644 --- a/test/common/generators/flows-test.js +++ b/test/common/generators/flows-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var delay_ = galaxy.unstar(delay, 0), delayFail_ = galaxy.unstar(delayFail, 0); QUnit.module(module.id); +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var delay_ = galaxy.unstar(delay, 0), delayFail_ = galaxy.unstar(delayFail, 0); QUnit.module(module.id); var flows = require("streamline/lib/util/flows"); function* delay(_, val) { diff --git a/test/common/generators/futures-test.js b/test/common/generators/futures-test.js index 94a1a3e3..713ac96f 100644 --- a/test/common/generators/futures-test.js +++ b/test/common/generators/futures-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var delay_ = galaxy.unstar(delay, 2); QUnit.module(module.id); +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var delay_ = galaxy.unstar(delay, 2); QUnit.module(module.id); function* delay(millis, val, _) { (yield galaxy.invoke(null, setTimeout, [_ , millis], 0)); diff --git a/test/common/generators/stack-test.js b/test/common/generators/stack-test.js index 7aff4f35..a7641d9b 100644 --- a/test/common/generators/stack-test.js +++ b/test/common/generators/stack-test.js @@ -1,4 +1,4 @@ -/*** Generated by streamline 0.10.17 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var failAsync_ = galaxy.unstar(failAsync, 0), failSync_ = galaxy.unstar(failSync, 0), A_ = galaxy.unstar(A, 0), B_ = galaxy.unstar(B, 0), C_ = galaxy.unstar(C, 0), D_ = galaxy.unstar(D, 0), E_ = galaxy.unstar(E, 0), F_ = galaxy.unstar(F, 0), G_ = galaxy.unstar(G, 0), H_ = galaxy.unstar(H, 0), I_ = galaxy.unstar(I, 0), issue233_ = galaxy.unstar(issue233, 0), T_ = galaxy.unstar(T, 0); // WARNING: DO NOT INSERT COMMENTS OR REFORMAT OR ANYTHING +/*** Generated by streamline 0.12.0 (generators) - DO NOT EDIT ***/var galaxy = require("streamline/lib/generators/runtime");(function(){})();(galaxy.unstar(function*(_) {var failAsync_ = galaxy.unstar(failAsync, 0), failSync_ = galaxy.unstar(failSync, 0), A_ = galaxy.unstar(A, 0), B_ = galaxy.unstar(B, 0), C_ = galaxy.unstar(C, 0), D_ = galaxy.unstar(D, 0), E_ = galaxy.unstar(E, 0), F_ = galaxy.unstar(F, 0), G_ = galaxy.unstar(G, 0), H_ = galaxy.unstar(H, 0), I_ = galaxy.unstar(I, 0), issue233_ = galaxy.unstar(issue233, 0), T_ = galaxy.unstar(T, 0); // WARNING: DO NOT INSERT COMMENTS OR REFORMAT OR ANYTHING // Line numbers matter to this test! QUnit.module(module.id);