From 59f381f444295793f41c92e0de5f81ebabd8fb0c Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Sat, 14 Mar 2015 20:16:22 +0100 Subject: [PATCH] issue #254 - recompiled --- lib/callbacks/builtins.js | 626 ++++----- lib/callbacks/compile.js | 753 +++++------ lib/callbacks/flows.js | 646 ++++----- lib/callbacks/runtime-all.js | 626 ++++----- lib/callbacks/transform-all.js | 664 +++++----- lib/generators/runtime-all.js | 547 -------- lib/generators/transform-all.js | 547 -------- lib/streams/client/streams.js | 276 ++-- test/common/callbacks/eval-test.js | 1730 ++++++++++++------------- test/common/callbacks/flows-test.js | 570 ++++---- test/common/callbacks/futures-test.js | 22 +- test/common/callbacks/stack-test.js | 464 +++---- 12 files changed, 3198 insertions(+), 4273 deletions(-) diff --git a/lib/callbacks/builtins.js b/lib/callbacks/builtins.js index 77172c21..e752558e 100644 --- a/lib/callbacks/builtins.js +++ b/lib/callbacks/builtins.js @@ -1,367 +1,367 @@ -/*** 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.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; + + + + + + + +(function (exports) { + 'use strict'; + var VERSION = 3; + var 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; }; + + fn.apply(this, args); + return function F(cb) { + if (!cb) return F; + if (done) cb.call(self, err, result); else q.push(cb); }; }; + - (function (exports) { - 'use strict'; - var VERSION = 3; + 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 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; }; + var funCb = function (callback, fn) { + if (callback == null) return future(funCb, arguments, 0); - fn.apply(this, args); - return function F(cb) { - if (!cb) return F; - if (done) cb.call(self, err, result); else q.push(cb); }; }; - - - - - - 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; + if (max < 0 || max == Infinity) return fn(callback); + queue.push({ fn: fn, cb: callback }); - var funCb = function (callback, fn) { - if (callback == null) return future(funCb, arguments, 0); - - 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(); }; - var fun = __rt.streamlinify(funCb, 0); - fun.close = function () { - queue = [], closed = true; }; + 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(); } }); } - return fun; }; - - var funnel = exports.funnel; - funnel.defaultSize = 4; - - function _parallel(options) { - if (typeof options === 'number') return options; - if (typeof options.parallel === 'number') return options.parallel; - return options.parallel ? -1 : 1; } - - - if (Array.prototype.forEach_ && Array.prototype.forEach_.version_ >= VERSION) return; - - - try { - Object.defineProperty({}, 'x', {}); } catch (e) { - return; } - - - var has = Object.prototype.hasOwnProperty; - - - - - - - - - - - - - - - - - - - - - + + + while (active < max && queue.length > 0) _doOne(); }; + var fun = __rt.streamlinify(funCb, 0); + fun.close = function () { + queue = [], closed = true; }; + return fun; }; + + var funnel = exports.funnel; + funnel.defaultSize = 4; + + function _parallel(options) { + if (typeof options === 'number') return options; + if (typeof options.parallel === 'number') return options.parallel; + return options.parallel ? -1 : 1; } + + + if (Array.prototype.forEach_ && Array.prototype.forEach_.version_ >= VERSION) return; + + + try { + Object.defineProperty({}, 'x', {}); } catch (e) { - delete Array.prototype.forEach_; - Object.defineProperty(Array.prototype, 'forEach_', { configurable: true, writable: true, enumerable: false, value: function value__1(_, options, fn, thisObj) { - + return; } + + + var has = Object.prototype.hasOwnProperty; + + + + + + + + + + + + + + + + + + + + + + + + + + delete Array.prototype.forEach_; + Object.defineProperty(Array.prototype, 'forEach_', { configurable: true, writable: true, enumerable: false, value: function value__1(_, options, fn, thisObj) { + + + + var par, len, i, __this = this; var __frame = { name: 'value__1', line: 124 }; return __func(_, this, arguments, value__1, 0, __frame, function __$value__1() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, i, __this = this; var __frame = { name: 'value__1', line: 124 }; return __func(_, this, arguments, value__1, 0, __frame, function __$value__1() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); - - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - - return function __$value__1(__then) { if (par === 1 || len <= 1) { i = 0; - var __2 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__1() { __more = false; if (__2) { i++; } else { __2 = true; } var __1 = i < len; if (__1) { - return function __$value__1(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 7, 0, __then, true, false), __this[i], i); } else { __then(); } }(function __$value__1() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - - return __this.map_(__cb(_, __frame, 10, 0, __then, true, false), par, fn, thisObj); } }(function __$value__1() { + return function __$value__1(__then) { if (par === 1 || len <= 1) { + i = 0; var __2 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__1() { __more = false; if (__2) { i++; } else { __2 = true; } var __1 = i < len; if (__1) { + return function __$value__1(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 7, 0, __then, true, false), __this[i], i); } else { __then(); } }(function __$value__1() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - return _(null, __this); }); }); } }); - - - Array.prototype.forEach_.version_ = VERSION; - - - delete Array.prototype.map_; - Object.defineProperty(Array.prototype, 'map_', { configurable: true, writable: true, enumerable: false, value: function value__2(_, options, fn, thisObj) { + + return __this.map_(__cb(_, __frame, 10, 0, __then, true, false), par, fn, thisObj); } }(function __$value__1() { + + return _(null, __this); }); }); } }); + + + Array.prototype.forEach_.version_ = VERSION; + + + delete Array.prototype.map_; + Object.defineProperty(Array.prototype, 'map_', { configurable: true, writable: true, enumerable: false, value: function value__2(_, options, fn, thisObj) { + + + + var par, len, result, i, fun, __this = this; var __frame = { name: 'value__2', line: 147 }; return __func(_, this, arguments, value__2, 0, __frame, function __$value__2() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, result, i, fun, __this = this; var __frame = { name: 'value__2', line: 147 }; return __func(_, this, arguments, value__2, 0, __frame, function __$value__2() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); - - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - - - return function __$value__2(__then) { if (par === 1 || len <= 1) { - result = new Array(len); i = 0; - var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < len; if (__3) { - return function __$value__2(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 9, 0, function ___(__0, __1) { result[i] = __1; __then(); }, true, false), __this[i], i); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - - result = __this.map(function (elt, i) { - return fun(false, function __1(_) { var __frame = { name: '__1', line: 161 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt, i); }); }); }); i = 0; - - - var __7 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < len; if (__6) { - return function __$value__2(__then) { if (has.call(__this, i)) { return result[i](__cb(_, __frame, 19, 0, function ___(__0, __2) { result[i] = __2; __then(); }, true, false)); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__2() { + return function __$value__2(__then) { if (par === 1 || len <= 1) { + result = new Array(len); + i = 0; var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < len; if (__3) { + return function __$value__2(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 9, 0, function ___(__0, __1) { result[i] = __1; __then(); }, true, false), __this[i], i); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + fun = funnel(par); - return _(null, result); }); }); } }); - - - - - delete Array.prototype.filter_; - Object.defineProperty(Array.prototype, 'filter_', { configurable: true, writable: true, enumerable: false, value: function value__3(_, options, fn, thisObj) { - + result = __this.map(function (elt, i) { + return fun(false, function __1(_) { var __frame = { name: '__1', line: 161 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt, i); }); }); }); + + + i = 0; var __7 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < len; if (__6) { + return function __$value__2(__then) { if (has.call(__this, i)) { return result[i](__cb(_, __frame, 19, 0, function ___(__0, __2) { result[i] = __2; __then(); }, true, false)); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__2() { + + + return _(null, result); }); }); } }); + + + + + delete Array.prototype.filter_; + Object.defineProperty(Array.prototype, 'filter_', { configurable: true, writable: true, enumerable: false, value: function value__3(_, options, fn, thisObj) { + + + + var par, result, len, i, elt, __this = this; var __frame = { name: 'value__3', line: 179 }; return __func(_, this, arguments, value__3, 0, __frame, function __$value__3() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; result = []; + len = __this.length; - var par, result, len, i, elt, __this = this; var __frame = { name: 'value__3', line: 179 }; return __func(_, this, arguments, value__3, 0, __frame, function __$value__3() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + return function __$value__3(__then) { if (par === 1 || len <= 1) { + i = 0; var __5 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__3() { __more = false; if (__5) { i++; } else { __5 = true; } var __4 = i < len; if (__4) { + return function __$value__3(__then) { if (has.call(__this, i)) { elt = __this[i]; + + return fn.call(thisObj, __cb(_, __frame, 10, 0, function ___(__0, __3) { var __2 = __3; return function __$value__3(__then) { if (__2) { result.push(elt); __then(); } else { __then(); } }(__then); }, true, false), elt); } else { __then(); } }(function __$value__3() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + + + + return __this.map_(__cb(_, __frame, 14, 0, __then, true, false), par, function __1(_, elt) { var __frame = { name: '__1', line: 193 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$__1(__then) { if (__1) { result.push(elt); __then(); } else { __then(); } }(_); }, true, false), elt); }); }, thisObj); } }(function __$value__3() { - thisObj = thisObj !== undefined ? thisObj : __this; result = []; - len = __this.length; - return function __$value__3(__then) { if (par === 1 || len <= 1) { i = 0; - var __5 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__3() { __more = false; if (__5) { i++; } else { __5 = true; } var __4 = i < len; if (__4) { - return function __$value__3(__then) { if (has.call(__this, i)) { elt = __this[i]; - - return fn.call(thisObj, __cb(_, __frame, 10, 0, function ___(__0, __3) { var __2 = __3; return function __$value__3(__then) { if (__2) { result.push(elt); __then(); } else { __then(); } }(__then); }, true, false), elt); } else { __then(); } }(function __$value__3() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - + return _(null, result); }); }); } }); + + + + + delete Array.prototype.every_; + Object.defineProperty(Array.prototype, 'every_', { configurable: true, writable: true, enumerable: false, value: function value__4(_, options, fn, thisObj) { + + + + var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__4', line: 207 }; return __func(_, this, arguments, value__4, 0, __frame, function __$value__4() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + + return function __$value__4(__then) { if (par === 1 || len <= 1) { + i = 0; var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { + + return function __$value__4(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 8, 0, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true, false), __this[i]); }(__cb(_, __frame, 8, 0, function ___(__0, __4) { var __3 = __4; return function __$value__4(__then) { if (__3) { return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + + fun = funnel(par); + futures = __this.map(function (elt) { - return __this.map_(__cb(_, __frame, 14, 0, __then, true, false), par, function __1(_, elt) { var __frame = { name: '__1', line: 193 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$__1(__then) { if (__1) { result.push(elt); __then(); } else { __then(); } }(_); }, true, false), elt); }); }, thisObj); } }(function __$value__3() { + return fun(false, function __1(_) { var __frame = { name: '__1', line: 220 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); - return _(null, result); }); }); } }); - - - - - delete Array.prototype.every_; - Object.defineProperty(Array.prototype, 'every_', { configurable: true, writable: true, enumerable: false, value: function value__4(_, options, fn, thisObj) { - - - - var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__4', line: 207 }; return __func(_, this, arguments, value__4, 0, __frame, function __$value__4() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + i = 0; var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { + return function __$value__4(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 18, 0, function ___(__0, __4) { var __3 = !__4; return _(null, __3); }, true, false)); }(__cb(_, __frame, 18, 0, function ___(__0, __6) { var __5 = __6; return function __$value__4(__then) { if (__5) { + fun.close(); + return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__4() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - return function __$value__4(__then) { if (par === 1 || len <= 1) { i = 0; - var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { - - return function __$value__4(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 8, 0, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true, false), __this[i]); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$value__4(__then) { if (__3) { return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - futures = __this.map(function (elt) { - - return fun(false, function __1(_) { var __frame = { name: '__1', line: 220 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); i = 0; - - - var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { - return function __$value__4(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 18, 0, function ___(__0, __4) { var __3 = !__4; return _(null, __3); }, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { var __5 = __6; return function __$value__4(__then) { if (__5) { - fun.close(); - return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__4() { + + return _(null, true); }); }); } }); + + + + + delete Array.prototype.some_; + Object.defineProperty(Array.prototype, 'some_', { configurable: true, writable: true, enumerable: false, value: function value__5(_, options, fn, thisObj) { + + + + var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__5', line: 241 }; return __func(_, this, arguments, value__5, 0, __frame, function __$value__5() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + + return function __$value__5(__then) { if (par === 1 || len <= 1) { + i = 0; var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { + return function __$value__5(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 7, 0, _, true, false), __this[i]); }(__cb(_, __frame, 7, 0, function ___(__0, __4) { var __3 = __4; return function __$value__5(__then) { if (__3) { return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + fun = funnel(par); + futures = __this.map(function (elt) { + + return fun(false, function __1(_) { var __frame = { name: '__1', line: 253 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); - return _(null, true); }); }); } }); - - - - - delete Array.prototype.some_; - Object.defineProperty(Array.prototype, 'some_', { configurable: true, writable: true, enumerable: false, value: function value__5(_, options, fn, thisObj) { - + i = 0; var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { + return function __$value__5(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 17, 0, _, true, false)); }(__cb(_, __frame, 17, 0, function ___(__0, __6) { var __5 = __6; return function __$value__5(__then) { if (__5) { + fun.close(); + return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__5() { + + + + return _(null, false); }); }); } }); + + + + + delete Array.prototype.reduce_; + Object.defineProperty(Array.prototype, 'reduce_', { configurable: true, writable: true, enumerable: false, value: function value__6(_, fn, v, thisObj) { + + + + var len, i, __this = this; var __frame = { name: 'value__6', line: 274 }; return __func(_, this, arguments, value__6, 0, __frame, function __$value__6() { + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + i = 0; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__6() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < len; if (__2) { + return function __$value__6(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__6() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__6() { + + return _(null, v); }); }); } }); + + + + + delete Array.prototype.reduceRight_; + Object.defineProperty(Array.prototype, 'reduceRight_', { configurable: true, writable: true, enumerable: false, value: function value__7(_, fn, v, thisObj) { + + + + var len, i, __this = this; var __frame = { name: 'value__7', line: 290 }; return __func(_, this, arguments, value__7, 0, __frame, function __$value__7() { + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__5', line: 241 }; return __func(_, this, arguments, value__5, 0, __frame, function __$value__5() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + i = len - 1; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__7() { __more = false; if (__3) { i--; } else { __3 = true; } var __2 = i >= 0; if (__2) { + return function __$value__7(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__7() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__7() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + return _(null, v); }); }); } }); + + + + + + + delete Array.prototype.sort_; + Object.defineProperty(Array.prototype, 'sort_', { configurable: true, writable: true, enumerable: false, value: function value__8(_, compare, beg, end) { + + + + var array, __this = this; + + + + + function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: '_qsort', line: 313 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() { + if (beg >= end) { return _(null); } - return function __$value__5(__then) { if (par === 1 || len <= 1) { i = 0; - var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { - return function __$value__5(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 7, 0, _, true, false), __this[i]); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$value__5(__then) { if (__3) { return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - futures = __this.map(function (elt) { - - return fun(false, function __1(_) { var __frame = { name: '__1', line: 253 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); i = 0; - - - var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { - return function __$value__5(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 17, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { var __5 = __6; return function __$value__5(__then) { if (__5) { - fun.close(); - return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__5() { - + return function __$_qsort(__then) { if (end == beg + 1) { + return compare(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 > 0; return function __$_qsort(__then) { if (__3) { tmp = array[beg]; + + array[beg] = array[end]; + array[end] = tmp; __then(); } else { __then(); } }(function __$_qsort() { + + return _(null); }); }, true, false), array[beg], array[end]); } else { __then(); } }(function __$_qsort() { mid = Math.floor((beg + end) / 2); - return _(null, false); }); }); } }); - - - - - delete Array.prototype.reduce_; - Object.defineProperty(Array.prototype, 'reduce_', { configurable: true, writable: true, enumerable: false, value: function value__6(_, fn, v, thisObj) { - - - - var len, i, __this = this; var __frame = { name: 'value__6', line: 274 }; return __func(_, this, arguments, value__6, 0, __frame, function __$value__6() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - i = 0; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__6() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < len; if (__2) { - return function __$value__6(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__6() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__6() { - - return _(null, v); }); }); } }); - - - - - delete Array.prototype.reduceRight_; - Object.defineProperty(Array.prototype, 'reduceRight_', { configurable: true, writable: true, enumerable: false, value: function value__7(_, fn, v, thisObj) { - - - - var len, i, __this = this; var __frame = { name: 'value__7', line: 290 }; return __func(_, this, arguments, value__7, 0, __frame, function __$value__7() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - i = len - 1; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__7() { __more = false; if (__3) { i--; } else { __3 = true; } var __2 = i >= 0; if (__2) { - return function __$value__7(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__7() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__7() { + o = array[mid]; + nbeg = beg; + nend = end; - return _(null, v); }); }); } }); - - - - - - - delete Array.prototype.sort_; - Object.defineProperty(Array.prototype, 'sort_', { configurable: true, writable: true, enumerable: false, value: function value__8(_, compare, beg, end) { - - - - var array, __this = this; - - - - - function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: '_qsort', line: 313 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() { - if (beg >= end) { return _(null); } - return function __$_qsort(__then) { if (end == beg + 1) { - return compare(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 > 0; return function __$_qsort(__then) { if (__3) { tmp = array[beg]; + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; var __6 = nbeg <= nend; if (__6) { + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { return function __$_qsort(_) { var __1 = nbeg < end; if (!__1) { return _(null, __1); } return compare(__cb(_, __frame, 18, 0, function ___(__0, __3) { var __2 = __3 < 0; return _(null, __2); }, true, false), array[nbeg], o); }(__cb(_, __frame, 18, 0, _, true, false)); }(__cb(_, __frame, 18, 0, function ___(__0, __7) { if (__7) { nbeg++; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { return function __$_qsort(_) { var __2 = beg < nend; if (!__2) { return _(null, __2); } return compare(__cb(_, __frame, 19, 0, function ___(__0, __4) { var __3 = __4 < 0; return _(null, __3); }, true, false), o, array[nend]); }(__cb(_, __frame, 19, 0, _, true, false)); }(__cb(_, __frame, 19, 0, function ___(__0, __9) { if (__9) { nend--; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - array[beg] = array[end]; - array[end] = tmp; __then(); } else { __then(); } }(function __$_qsort() { - - return _(null); }); }, true, false), array[beg], array[end]); } else { __then(); } }(function __$_qsort() { mid = Math.floor((beg + end) / 2); + if (nbeg <= nend) { tmp = array[nbeg]; + + array[nbeg] = array[nend]; + array[nend] = tmp; + nbeg++; + nend--; } while (__more) { __loop(); } __more = true; }); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - o = array[mid]; - nbeg = beg; - nend = end; - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; var __6 = nbeg <= nend; - - if (__6) { return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { - return function __$_qsort(_) { var __1 = nbeg < end; if (!__1) { return _(null, __1); } return compare(__cb(_, __frame, 18, 0, function ___(__0, __3) { var __2 = __3 < 0; return _(null, __2); }, true, false), array[nbeg], o); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __7) { if (__7) { nbeg++; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { - return function __$_qsort(_) { var __2 = beg < nend; if (!__2) { return _(null, __2); } return compare(__cb(_, __frame, 19, 0, function ___(__0, __4) { var __3 = __4 < 0; return _(null, __3); }, true, false), o, array[nend]); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __9) { if (__9) { nend--; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - - if (nbeg <= nend) { tmp = array[nbeg]; - - array[nbeg] = array[nend]; - array[nend] = tmp; - nbeg++; - nend--; } while (__more) { __loop(); } __more = true; }); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - - - - return function __$_qsort(__then) { if (nbeg < end) { return _qsort(__cb(_, __frame, 30, 0, __then, true, false), nbeg, end); } else { __then(); } }(function __$_qsort() { - return function __$_qsort(__then) { if (beg < nend) { return _qsort(__cb(_, __frame, 31, 0, __then, true, false), beg, nend); } else { __then(); } }(_); }); }); }); }); } var __frame = { name: 'value__8', line: 308 }; return __func(_, this, arguments, value__8, 0, __frame, function __$value__8() { array = __this; beg = beg || 0; end = end == null ? array.length - 1 : end; - - return _qsort(__cb(_, __frame, 38, 0, function __$value__8() { - return _(null, array); }, true, false), beg, end); }); } }); - - - - - - - - - - - - delete Function.prototype.apply_; - Object.defineProperty(Function.prototype, 'apply_', { configurable: true, writable: true, enumerable: false, value: function (callback, thisObj, args, index) { - - - + + return function __$_qsort(__then) { if (nbeg < end) { return _qsort(__cb(_, __frame, 30, 0, __then, true, false), nbeg, end); } else { __then(); } }(function __$_qsort() { + return function __$_qsort(__then) { if (beg < nend) { return _qsort(__cb(_, __frame, 31, 0, __then, true, false), beg, nend); } else { __then(); } }(_); }); }); }); }); } var __frame = { name: 'value__8', line: 308 }; return __func(_, this, arguments, value__8, 0, __frame, function __$value__8() { array = __this; beg = beg || 0; end = end == null ? array.length - 1 : end; - args = Array.prototype.slice.call(args, 0); - args.splice(index != null && index >= 0 ? index : args.length, 0, callback); - return this.apply(thisObj, args); } }); }(typeof exports !== 'undefined' ? exports : Streamline.builtins = Streamline.builtins || {})); \ No newline at end of file + return _qsort(__cb(_, __frame, 38, 0, function __$value__8() { + return _(null, array); }, true, false), beg, end); }); } }); + + + + + + + + + + + + delete Function.prototype.apply_; + Object.defineProperty(Function.prototype, 'apply_', { configurable: true, writable: true, enumerable: false, value: function (callback, thisObj, args, index) { + + + + + args = Array.prototype.slice.call(args, 0); + args.splice(index != null && index >= 0 ? index : args.length, 0, callback); + return this.apply(thisObj, args); } }); }(typeof exports !== 'undefined' ? exports : Streamline.builtins = Streamline.builtins || {})); \ No newline at end of file diff --git a/lib/callbacks/compile.js b/lib/callbacks/compile.js index 8046d1b5..23ef02c0 100644 --- a/lib/callbacks/compile.js +++ b/lib/callbacks/compile.js @@ -1,423 +1,424 @@ -/*** 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; - - - - - - - - var fs = require('fs'); - var fspath = require('path'); - var compileSync = require('../compiler/compileSync'); - - var _exists = __rt.streamlinify(function (cb, fname) { - fs.exists(fname, function (result) { - cb(null, result); }); }, 0); - - - - function mtime(_, fname) { var __frame = { name: 'mtime', line: 19 }; return __func(_, this, arguments, mtime, 0, __frame, function __$mtime() { - return function __$mtime(_) { return _exists(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$mtime(__then) { if (__1) { return fs.stat(fname, __cb(_, __frame, 1, 0, function ___(__0, __4) { var __3 = __4.mtime; return _(null, __3); }, true, false)); } else { __then(); } }(function __$mtime() { return _(null, 0); }); }, true, false), fname); }(__cb(_, __frame, 0, 0, _, true, false)); }); } - - - var _0755 = parseInt('0755', 8); - - function _getTransform(options) { +/*** 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; + + + + + + + +var fs = require('fs'); +var fspath = require('path'); +var compileSync = require('../compiler/compileSync'); + +var _exists = __rt.streamlinify(function (cb, fname) { + fs.exists(fname, function (result) { + cb(null, result); }); }, 0); + + + +function mtime(_, fname) { var __frame = { name: 'mtime', line: 19 }; return __func(_, this, arguments, mtime, 0, __frame, function __$mtime() { + return function __$mtime(_) { return _exists(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$mtime(__then) { if (__1) { return fs.stat(fname, __cb(_, __frame, 1, 0, function ___(__0, __4) { var __3 = __4.mtime; return _(null, __3); }, true, false)); } else { __then(); } }(function __$mtime() { return _(null, 0); }); }, true, false), fname); }(__cb(_, __frame, 1, 0, _, true, false)); }); } + + +var _0755 = parseInt('0755', 8); + +function _getTransform(options) { + + var req = require; + if (options.generators) { + if (options.fast) return req('../generators-fast/transform'); else return req('../generators/transform'); } else if (options.fibers) { - var req = require; - if (options.generators) { - if (options.fast) return req('../generators-fast/transform'); else return req('../generators/transform'); } else if (options.fibers) { - + + if (options.fast) return req('../fibers-fast/transform'); else return req('../fibers/transform'); } else { + + + return require('../callbacks/transform'); } } + + + +function _banner(version, options) { + + var optStr = options.oldStyleFutures ? ' --old-style-futures' : ''; + if (options.promise) optStr += ' --promise-' + options.promise; + if (options.standalone) optStr += ' --standalone'; + if (options.aggressive) optStr += ' --aggressive'; + return '/*** Generated by streamline ' + version + optStr + ' - DO NOT EDIT ***/'; } + + +function _extend(obj, other) { + for (var i in other) { + obj[i] = other[i]; } + + return obj; } + + +function _transform(transform, source, options) { + options.source = source; + options.callback = options.callback || '_'; + options.lines = options.lines || 'preserve'; + return transform.transform(source, options); } + + +function parseShebang(content) { + if (content[0] === '#' && content[1] === '!') { + var n = content.indexOf('\n'); + var le = '\n'; + if (n != -1) { + var shebang = content.substr(0, n); + if (shebang[shebang.length - 1] == '\r') { + le = '\r\n'; + shebang = shebang.substr(0, shebang.length - 1); } - if (options.fast) return req('../fibers-fast/transform'); else return req('../fibers/transform'); } else { + content = content.substr(n + 1); + return [ shebang, content, le ]; } } + + + return [ '', content, '' ]; } + + +function mkdirp(_, path) { var __frame = { name: 'mkdirp', line: 79 }; return __func(_, this, arguments, mkdirp, 0, __frame, function __$mkdirp() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$mkdirp() { + return fs.mkdir(path, _0755, __cb(_, __frame, 2, 0, __then, true, false)); }); }(function ___(err, __result) { + __catch(function __$mkdirp() { if (err) { + return function __$mkdirp(__then) { if (err.code == 'EEXIST') { + return fs.stat(path, __cb(_, __frame, 5, 0, function ___(__0, __2) { var __1 = __2.isDirectory(); return function __$mkdirp(__then) { if (__1) { + return _(null); } else { __then(); } }(function __$mkdirp() { + + return _(err); }); }, true, false)); } else { __then(); } }(function __$mkdirp() { + + return function __$mkdirp(__then) { if (err.code == 'ENOENT') { + return mkdirp(__cb(_, __frame, 11, 0, function __$mkdirp() { + return fs.mkdir(path, _0755, __cb(_, __frame, 12, 0, function __$mkdirp() { + return _(null); }, true, false)); }, true, false), fspath.join(path, '..')); } else { __then(); } }(function __$mkdirp() { + + return _(err); }); }); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$mkdirp() { _(); }); }); }); } + + + +function outputFile(_, inFile, options) { var dirname, outDir, stripped; var __frame = { name: 'outputFile', line: 98 }; return __func(_, this, arguments, outputFile, 0, __frame, function __$outputFile() { dirname = fspath.dirname(inFile); + + + if (options.outputDir) { + if (options.baseDir) { + outDir = fspath.join(options.outputDir, fspath.relative(options.baseDir, dirname)); } else { + + outDir = options.outputDir; } } else { - return require('../callbacks/transform'); } } - - - - function _banner(version, options) { + outDir = dirname; } - var optStr = options.oldStyleFutures ? ' --old-style-futures' : ''; - if (options.promise) optStr += ' --promise-' + options.promise; - if (options.standalone) optStr += ' --standalone'; - if (options.aggressive) optStr += ' --aggressive'; - return '/*** Generated by streamline ' + version + optStr + ' - DO NOT EDIT ***/'; } - - - function _extend(obj, other) { - for (var i in other) { - obj[i] = other[i]; } + return mkdirp(__cb(_, __frame, 12, 0, function __$outputFile() { stripped = fspath.basename(inFile, fspath.extname(inFile)); + + return _(null, fspath.join(outDir, stripped + '.js')); }, true, false), outDir); }); } + + +function fixSourceMap(sourceMap) { + var prev; + sourceMap._mappings._array = sourceMap._mappings._array.filter(function (mapping) { + if (!mapping.originalLine) return false; + if (prev && mapping.source === prev.source && mapping.originalLine === prev.originalLine && mapping.originalColumn === prev.originalColumn) return false; - return obj; } - - - function _transform(transform, source, options) { - options.source = source; - options.callback = options.callback || '_'; - options.lines = options.lines || 'preserve'; - return transform.transform(source, options); } - - - function parseShebang(content) { - if (content[0] === '#' && content[1] === '!') { - var n = content.indexOf('\n'); - var le = '\n'; - if (n != -1) { - var shebang = content.substr(0, n); - if (shebang[shebang.length - 1] == '\r') { - le = '\r\n'; - shebang = shebang.substr(0, shebang.length - 1); } - - content = content.substr(n + 1); - return [ shebang, content, le ]; } } + prev = mapping; + return true; }); } + + + + +exports.compileFile = function exports_compileFile__1(_, path, options) { var ext, language, basename, relpath, dstName, dirname, mtimeSrc, mtimeDst, transform, banner, content, shebangparse, shebang, le, coffee, transformed, sourceMap, mapFile, mapPath; var __frame = { name: 'exports_compileFile__1', line: 128 }; return __func(_, this, arguments, exports_compileFile__1, 0, __frame, function __$exports_compileFile__1() { + options = _extend({}, options || {}); ext = fspath.extname(path); + language = ext.substring(2); + basename = fspath.basename(path, ext); + relpath = fspath.relative('.', path); - return [ '', content, '' ]; } - - - function mkdirp(_, path) { var __frame = { name: 'mkdirp', line: 79 }; return __func(_, this, arguments, mkdirp, 0, __frame, function __$mkdirp() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$mkdirp() { - return fs.mkdir(path, _0755, __cb(_, __frame, 2, 0, __then, true, false)); }); }(function ___(err, __result) { - __catch(function __$mkdirp() { if (err) { - return function __$mkdirp(__then) { if (err.code == 'EEXIST') { - return fs.stat(path, __cb(_, __frame, 5, 0, function ___(__0, __2) { var __1 = __2.isDirectory(); return function __$mkdirp(__then) { if (__1) { - return _(null); } else { __then(); } }(function __$mkdirp() { - - return _(err); }); }, true, false)); } else { __then(); } }(function __$mkdirp() { - - return function __$mkdirp(__then) { if (err.code == 'ENOENT') { - return mkdirp(__cb(_, __frame, 11, 0, function __$mkdirp() { - return fs.mkdir(path, _0755, __cb(_, __frame, 12, 0, function __$mkdirp() { - return _(null); }, true, false)); }, true, false), fspath.join(path, '..')); } else { __then(); } }(function __$mkdirp() { - - return _(err); }); }); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$mkdirp() { _(); }); }); }); } - - - - function outputFile(_, inFile, options) { var dirname, outDir, stripped; var __frame = { name: 'outputFile', line: 98 }; return __func(_, this, arguments, outputFile, 0, __frame, function __$outputFile() { dirname = fspath.dirname(inFile); + return outputFile(__cb(_, __frame, 6, 0, function ___(__0, __2) { dstName = __2; dirname = fspath.dirname(dstName); - if (options.outputDir) { - if (options.baseDir) { - outDir = fspath.join(options.outputDir, fspath.relative(options.baseDir, dirname)); } else { + return mtime(__cb(_, __frame, 9, 0, function ___(__0, __3) { mtimeSrc = __3; + return mtime(__cb(_, __frame, 10, 0, function ___(__0, __4) { mtimeDst = __4; transform = _getTransform(options); + banner = _banner(transform.version, options); - outDir = options.outputDir; } } else { - - - outDir = dirname; } - - return mkdirp(__cb(_, __frame, 12, 0, function __$outputFile() { stripped = fspath.basename(inFile, fspath.extname(inFile)); - - return _(null, fspath.join(outDir, stripped + '.js')); }, true, false), outDir); }); } - - - function fixSourceMap(sourceMap) { - var keys = {}; - sourceMap._mappings._array = sourceMap._mappings._array.filter(function (mapping) { - if (!mapping.originalLine) return false; - var key = mapping.originalLine + '/' + mapping.originalColumn; - if (keys[key]) return false; - keys[key] = true; - return true; }); } - - - - - exports.compileFile = function exports_compileFile__1(_, path, options) { var ext, language, basename, relpath, dstName, dirname, mtimeSrc, mtimeDst, transform, banner, content, shebangparse, shebang, le, coffee, transformed, sourceMap, mapFile, mapPath; var __frame = { name: 'exports_compileFile__1', line: 127 }; return __func(_, this, arguments, exports_compileFile__1, 0, __frame, function __$exports_compileFile__1() { - options = _extend({}, options || {}); ext = fspath.extname(path); - language = ext.substring(2); - basename = fspath.basename(path, ext); - relpath = fspath.relative('.', path); - - return outputFile(__cb(_, __frame, 6, 0, function ___(__0, __2) { dstName = __2; dirname = fspath.dirname(dstName); - - - return mtime(__cb(_, __frame, 9, 0, function ___(__0, __3) { mtimeSrc = __3; - return mtime(__cb(_, __frame, 10, 0, function ___(__0, __4) { mtimeDst = __4; transform = _getTransform(options); - banner = _banner(transform.version, options); + + options.sourceName = relpath; + return fs.readFile(path, 'utf8', __cb(_, __frame, 15, 0, function ___(__0, __5) { content = __5; shebangparse = parseShebang(content); + shebang = shebangparse[0]; + le = shebangparse[2]; + content = shebangparse[1]; - options.sourceName = relpath; - return fs.readFile(path, 'utf8', __cb(_, __frame, 15, 0, function ___(__0, __5) { content = __5; shebangparse = parseShebang(content); - shebang = shebangparse[0]; - le = shebangparse[2]; + if (language === 'coffee') { coffee = require('../util/require')('coffee-script'); - content = shebangparse[1]; + if (options.sourceMap) { + content = coffee.compile(content, { filename: relpath, sourceFiles: [relpath], sourceMap: 1 }); + + + + + options.prevMap = new (require('source-map')).SourceMapConsumer(content.v3SourceMap); + content = content.js; } else { + + content = coffee.compile(content, { filename: path }); } } + + + + + + if (options.sourceMap) { + options.lines = 'sourcemap'; } + + + banner = shebang + le + banner; + return function __$exports_compileFile__1(_) { var __1 = mtimeDst; if (!__1) { return _(null, __1); } return fs.readFile(dstName, 'utf8', __cb(_, __frame, 43, 0, _, true, false)); }(__cb(_, __frame, 43, 0, function ___(__0, __6) { transformed = __6; + if (transformed && mtimeSrc < mtimeDst && transformed.substring(0, banner.length) == banner && !options.force) { + return _(null, transformed); } + + if (options.verbose) { + console.log('streamline: creating: ' + dstName); } transformed = _transform(transform, content, options); + + mapFile = options.sourceMapFile || fspath.join(dirname, basename + '.map'); - if (language === 'coffee') { coffee = require('../util/require')('coffee-script'); + + if (typeof transformed == 'string') { + transformed = banner + transformed; + if (options.prevMap) { + transformed += '\n//# sourceMappingURL=' + (options.sourceMapFile || basename + '.map') + '\n'; + sourceMap = require('source-map').SourceMapGenerator.fromSourceMap(options.prevMap); + options.prevMap = null; } } else { + + transformed.prepend(banner); if (options.sourceMap) { - content = coffee.compile(content, { filename: relpath, sourceFiles: [relpath], sourceMap: 1 }); - + transformed.add('\n//# sourceMappingURL=' + (options.sourceMapFile || basename + '.map') + '\n'); mapPath = fspath.dirname(mapFile); + sourceMap = transformed.toStringWithSourceMap({ file: fspath.relative(mapPath, dstName), sourceRoot: fspath.relative(mapPath, '.') }); - options.prevMap = new (require('source-map')).SourceMapConsumer(content.v3SourceMap); - content = content.js; } else { - content = coffee.compile(content, { filename: path }); } } - - - - - - if (options.sourceMap) { - options.lines = 'sourcemap'; } + transformed = sourceMap.code; + sourceMap = sourceMap.map; + fixSourceMap(sourceMap); } } - banner = shebang + le + banner; - return function __$exports_compileFile__1(_) { var __1 = mtimeDst; if (!__1) { return _(null, __1); } return fs.readFile(dstName, 'utf8', __cb(_, __frame, 43, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { transformed = __6; - if (transformed && mtimeSrc < mtimeDst && transformed.substring(0, banner.length) == banner && !options.force) { - return _(null, transformed); } - - if (options.verbose) { - console.log('streamline: creating: ' + dstName); } transformed = _transform(transform, content, options); - - mapFile = options.sourceMapFile || fspath.join(dirname, basename + '.map'); - - - if (typeof transformed == 'string') { - transformed = banner + transformed; - if (options.prevMap) { - transformed += '\n//# sourceMappingURL=' + (options.sourceMapFile || basename + '.map') + '\n'; - sourceMap = require('source-map').SourceMapGenerator.fromSourceMap(options.prevMap); - options.prevMap = null; } } else { + return function __$exports_compileFile__1(__then) { if (options.noWrite) { + return _(null, { transformed: transformed, sourceMap: sourceMap }); } else { - transformed.prepend(banner); - if (options.sourceMap) { - transformed.add('\n//# sourceMappingURL=' + (options.sourceMapFile || basename + '.map') + '\n'); mapPath = fspath.dirname(mapFile); - - sourceMap = transformed.toStringWithSourceMap({ file: fspath.relative(mapPath, dstName), sourceRoot: fspath.relative(mapPath, '.') }); - - - - transformed = sourceMap.code; - sourceMap = sourceMap.map; - fixSourceMap(sourceMap); } } - - - return function __$exports_compileFile__1(__then) { if (options.noWrite) { - return _(null, { transformed: transformed, sourceMap: sourceMap }); } else { - - - - - - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$exports_compileFile__1() { - return fs.writeFile(dstName, transformed, 'utf8', __cb(_, __frame, 83, 0, __then, true, false)); }); }(function ___(ex, __result) { - __catch(function __$exports_compileFile__1() { if (ex) { __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$exports_compileFile__1() { - return function __$exports_compileFile__1(__then) { if (options.sourceMap) { - if (options.prevMap) { - sourceMap.applySourceMap(options.prevMap, options.sourceName); } - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$exports_compileFile__1() { - if (options.verbose) { console.log('streamline: creating: ' + mapFile); } - return fs.writeFile(mapFile, sourceMap.toString(), 'utf8', __cb(_, __frame, 91, 0, __then, true, false)); }); }(function ___(ex, __result) { - __catch(function __$exports_compileFile__1() { if (ex) { __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(__then); }); }); } }(_); }, true, false)); }, true, false)); }, true, false), dstName); }, true, false), path); }, true, false), path, options); }); }; - - - - - - - - - - exports.loadFile = function exports_loadFile__2(_, path, options) { var ext, basename, dirname, js, transform, banner, content, shebangparse, shebang, le, matches; var __frame = { name: 'exports_loadFile__2', line: 229 }; return __func(_, this, arguments, exports_loadFile__2, 0, __frame, function __$exports_loadFile__2() { - options = _extend({}, options || {}); ext = fspath.extname(path); + + + + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$exports_compileFile__1() { + return fs.writeFile(dstName, transformed, 'utf8', __cb(_, __frame, 83, 0, __then, true, false)); }); }(function ___(ex, __result) { + __catch(function __$exports_compileFile__1() { if (ex) { __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$exports_compileFile__1() { + return function __$exports_compileFile__1(__then) { if (options.sourceMap) { + if (options.prevMap) { + sourceMap.applySourceMap(options.prevMap, options.sourceName); } + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$exports_compileFile__1() { + if (options.verbose) { console.log('streamline: creating: ' + mapFile); } + return fs.writeFile(mapFile, sourceMap.toString(), 'utf8', __cb(_, __frame, 91, 0, __then, true, false)); }); }(function ___(ex, __result) { + __catch(function __$exports_compileFile__1() { if (ex) { __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(__then); }); }); } }(_); }, true, false)); }, true, false)); }, true, false), dstName); }, true, false), path); }, true, false), path, options); }); }; + + + + + + + + + +exports.loadFile = function exports_loadFile__2(_, path, options) { var ext, basename, dirname, js, transform, banner, content, shebangparse, shebang, le, matches; var __frame = { name: 'exports_loadFile__2', line: 230 }; return __func(_, this, arguments, exports_loadFile__2, 0, __frame, function __$exports_loadFile__2() { + options = _extend({}, options || {}); ext = fspath.extname(path); + + + return function __$exports_loadFile__2(__then) { if (ext !== '.js' && ext !== '._js') { + + return _exists(__cb(_, __frame, 6, 0, function ___(__0, __2) { var __1 = __2; return function __$exports_loadFile__2(__then) { if (__1) { path = path + (ext = '._js'); __then(); } else { + return _exists(__cb(_, __frame, 7, 0, function ___(__0, __4) { var __3 = __4; return function __$exports_loadFile__2(__then) { if (__3) { path = path + (ext = '.js'); __then(); } else { + return _(null); } }(__then); }, true, false), path + '.js'); } }(__then); }, true, false), path + '._js'); } else { __then(); } }(function __$exports_loadFile__2() { basename = fspath.basename(path, ext); + dirname = fspath.dirname(path); + js = dirname + '/' + basename + ext; - return function __$exports_loadFile__2(__then) { if (ext !== '.js' && ext !== '._js') { - - return _exists(__cb(_, __frame, 6, 0, function ___(__0, __2) { var __1 = __2; return function __$exports_loadFile__2(__then) { if (__1) { path = path + (ext = '._js'); __then(); } else { - return _exists(__cb(_, __frame, 7, 0, function ___(__0, __4) { var __3 = __4; return function __$exports_loadFile__2(__then) { if (__3) { path = path + (ext = '.js'); __then(); } else { - return _(null); } }(__then); }, true, false), path + '.js'); } }(__then); }, true, false), path + '._js'); } else { __then(); } }(function __$exports_loadFile__2() { basename = fspath.basename(path, ext); - - dirname = fspath.dirname(path); - js = dirname + '/' + basename + ext; - + + options.lines = options.lines || 'preserve'; transform = _getTransform(options); + + banner = _banner(transform.version, options); + + options.sourceName = js; + return fs.readFile(js, 'utf8', __cb(_, __frame, 19, 0, function ___(__0, __5) { content = __5; shebangparse = parseShebang(content); + shebang = shebangparse[0]; + le = shebangparse[2]; - options.lines = options.lines || 'preserve'; transform = _getTransform(options); + content = shebangparse[1]; - banner = _banner(transform.version, options); + banner = shebang + le + banner; - options.sourceName = js; - return fs.readFile(js, 'utf8', __cb(_, __frame, 19, 0, function ___(__0, __5) { content = __5; shebangparse = parseShebang(content); - shebang = shebangparse[0]; - le = shebangparse[2]; - - content = shebangparse[1]; - - banner = shebang + le + banner; - - return function __$exports_loadFile__2(__then) { if (ext === '._js') { - return cachedTransform(__cb(_, __frame, 28, 0, _, true, false), content, path, transform, banner, options); } else { - - return _(null, content); } }(_); }, true, false)); }); }); }; - - - - exports.transformModule = compileSync.transformModule; - - function cacheRoot(options) { - if (options.cacheDir) return options.cacheDir; - if (process.env.HOME === undefined && process.env.HOMEDRIVE === undefined) throw new Error('HOME not found, unable to store Streamline callback cache'); - return (process.env.HOME || (process.env.HOMEDRIVE + process.env.HOMEPATH).replace(/\\/g, '/')) + '/.streamline'; } - - - var dirMode = parseInt('777', 8); - - function mkdirs(_, path) { var p, i, segs, seg; var __frame = { name: 'mkdirs', line: 273 }; return __func(_, this, arguments, mkdirs, 0, __frame, function __$mkdirs() { p = ''; - i = 0; - segs = path.split('/').slice(0, -1); - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$mkdirs() { __more = false; var __3 = i < segs.length; - if (__3) { seg = segs[i]; + return function __$exports_loadFile__2(__then) { if (ext === '._js') { + return cachedTransform(__cb(_, __frame, 28, 0, _, true, false), content, path, transform, banner, options); } else { - p += (i++ ? '/' : '') + seg; - return _exists(__cb(_, __frame, 7, 0, function ___(__0, __2) { var __1 = !__2; return function __$mkdirs(__then) { if (__1) { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$mkdirs() { - return fs.mkdir(p, dirMode, __cb(_, __frame, 9, 0, __then, true, false)); }); }(function ___(err, __result) { - __catch(function __$mkdirs() { if (err) { - if (i > 1 && err.code !== 'EEXIST') { - return _(err); } __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(function __$mkdirs() { while (__more) { __loop(); } __more = true; }); }, true, false), p); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(_); }); } - - - - - - - function subdir(options) { - var d = options.generators ? 'generators' : options.fibers ? 'fibers' : 'callbacks'; - if (options.fast) d += '-fast'; - if (options.aggressive) d += '-aggressive'; - return d; } - - - function cachedTransform(_, content, path, transform, banner, options) { var i, dir, f, transformed; var __frame = { name: 'cachedTransform', line: 299 }; return __func(_, this, arguments, cachedTransform, 0, __frame, function __$cachedTransform() { - path = path.replace(/\\/g, '/'); - return function __$cachedTransform(__then) { if (options.cache) { i = path.indexOf('node_modules/'); - - if (i < 0) { i = path.lastIndexOf('/'); } else { - i += 'node_modules'.length; } dir = cacheRoot(options) + '/' + subdir(options); - - - dir += '/' + path.substring(0, i).replace(/[\/\:]/g, '__'); f = dir + path.substring(i); + return _(null, content); } }(_); }, true, false)); }); }); }; + + + +exports.transformModule = compileSync.transformModule; + +function cacheRoot(options) { + if (options.cacheDir) return options.cacheDir; + if (process.env.HOME === undefined && process.env.HOMEDRIVE === undefined) throw new Error('HOME not found, unable to store Streamline callback cache'); + return (process.env.HOME || (process.env.HOMEDRIVE + process.env.HOMEPATH).replace(/\\/g, '/')) + '/.streamline'; } + + +var dirMode = parseInt('777', 8); + +function mkdirs(_, path) { var p, i, segs, seg; var __frame = { name: 'mkdirs', line: 274 }; return __func(_, this, arguments, mkdirs, 0, __frame, function __$mkdirs() { p = ''; + i = 0; + segs = path.split('/').slice(0, -1); + + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$mkdirs() { __more = false; var __3 = i < segs.length; if (__3) { seg = segs[i]; - return mkdirs(__cb(_, __frame, 10, 0, function __$cachedTransform() { - - return mtime(__cb(_, __frame, 12, 0, function ___(__0, __2) { return mtime(__cb(_, __frame, 12, 0, function ___(__0, __3) { var __1 = __2 > __3; return function __$cachedTransform(__then) { if (__1) { - return fs.readFile(f, 'utf8', __cb(_, __frame, 13, 0, function ___(__0, __4) { transformed = __4; - if (transformed.substring(0, banner.length) === banner) { return _(null, transformed); } __then(); }, true, false)); } else { __then(); } }(__then); }, true, false), path); }, true, false), f); }, true, false), f); } else { __then(); } }(function __$cachedTransform() { - - - - if (options.verbose) { console.log('streamline: transforming: ' + path); } - options.lines = options.lines || 'sourcemap'; - transformed = banner + _transform(transform, content, options); - return function __$cachedTransform(__then) { if (options.cache && path.indexOf('/tmp--') < 0) { return fs.writeFile(f, transformed, 'utf8', __cb(_, __frame, 21, 0, __then, true, false)); } else { __then(); } }(function __$cachedTransform() { - return _(null, transformed); }); }); }); } - - - exports.cachedTransformSync = compileSync.cachedTransformSync; - - function compileCoffee(_, path, options) { var jsPath, mapPath, outDir, coffeeOpts, source, coffee, compiled, js; var __frame = { name: 'compileCoffee', line: 326 }; return __func(_, this, arguments, compileCoffee, 0, __frame, function __$compileCoffee() { - return outputFile(__cb(_, __frame, 1, 0, function ___(__0, __2) { jsPath = __2; mapPath = jsPath.replace(/\.js$/, '.map'); - outDir = fspath.dirname(jsPath); - coffeeOpts = { filename: path, sourceMap: options.sourceMap, jsPath: jsPath, sourceRoot: fspath.relative(outDir, '.'), sourceFiles: [fspath.relative('.', path)], generatedFile: fspath.basename(jsPath) }; - - + p += (i++ ? '/' : '') + seg; + return _exists(__cb(_, __frame, 7, 0, function ___(__0, __2) { var __1 = !__2; return function __$mkdirs(__then) { if (__1) { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$mkdirs() { + return fs.mkdir(p, dirMode, __cb(_, __frame, 9, 0, __then, true, false)); }); }(function ___(err, __result) { + __catch(function __$mkdirs() { if (err) { + if (i > 1 && err.code !== 'EEXIST') { + return _(err); } __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(function __$mkdirs() { while (__more) { __loop(); } __more = true; }); }, true, false), p); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(_); }); } + + + + + + +function subdir(options) { + var d = options.generators ? 'generators' : options.fibers ? 'fibers' : 'callbacks'; + if (options.fast) d += '-fast'; + if (options.aggressive) d += '-aggressive'; + return d; } + + +function cachedTransform(_, content, path, transform, banner, options) { var i, dir, f, transformed; var __frame = { name: 'cachedTransform', line: 300 }; return __func(_, this, arguments, cachedTransform, 0, __frame, function __$cachedTransform() { + path = path.replace(/\\/g, '/'); + return function __$cachedTransform(__then) { if (options.cache) { i = path.indexOf('node_modules/'); + if (i < 0) { i = path.lastIndexOf('/'); } else { + i += 'node_modules'.length; } dir = cacheRoot(options) + '/' + subdir(options); + dir += '/' + path.substring(0, i).replace(/[\/\:]/g, '__'); f = dir + path.substring(i); - - - return function __$compileCoffee(_) { var __1 = options.force; if (__1) { return _(null, __1); } return mtime(__cb(_, __frame, 12, 0, function ___(__0, __3) { return mtime(__cb(_, __frame, 12, 0, function ___(__0, __4) { var __2 = __3 > __4; return _(null, __2); }, true, false), jsPath); }, true, false), path); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$compileCoffee(__then) { if (__3) { - return fs.readFile(path, 'utf8', __cb(_, __frame, 13, 0, function ___(__0, __5) { source = __5; coffee = require('../util/require')('coffee-script'); - compiled = coffee.compile(source, coffeeOpts); - - if (options.verbose) { console.log('streamline: coffee compiling: ' + path + ' to ' + jsPath); } - - if (options.sourceMap) { - js = compiled.js + '\n//# sourceMappingURL=' + fspath.basename(mapPath) + '\n'; } else { - - js = compiled; } - - return function __$compileCoffee(__then) { if (options.noWrite) { - return _(null, { transformed: js, sourceMap: compiled.v3SourceMap }); } else { - - - - - - return fs.writeFile(jsPath, js, 'utf8', __cb(_, __frame, 30, 0, function __$compileCoffee() { - return function __$compileCoffee(__then) { if (options.sourceMap) { - return fs.writeFile(mapPath, compiled.v3SourceMap, 'utf8', __cb(_, __frame, 32, 0, __then, true, false)); } else { __then(); } }(__then); }, true, false)); } }(__then); }, true, false)); } else { __then(); } }(_); }, true, false)); }, true, false), path, options); }); } - - - - - - - function _getCompiler(path) { - var ext = fspath.extname(path); - if (ext === '._js' || ext === '._coffee') { - return exports.compileFile; } else if (ext === '.coffee' && path[path.length - ext.length - 1] !== '_') { + return mkdirs(__cb(_, __frame, 10, 0, function __$cachedTransform() { + + return mtime(__cb(_, __frame, 12, 0, function ___(__0, __2) { return mtime(__cb(_, __frame, 12, 0, function ___(__0, __3) { var __1 = __2 > __3; return function __$cachedTransform(__then) { if (__1) { + return fs.readFile(f, 'utf8', __cb(_, __frame, 13, 0, function ___(__0, __4) { transformed = __4; + if (transformed.substring(0, banner.length) === banner) { return _(null, transformed); } __then(); }, true, false)); } else { __then(); } }(__then); }, true, false), path); }, true, false), f); }, true, false), f); } else { __then(); } }(function __$cachedTransform() { - return compileCoffee; } else { } } - - - - - - - - exports.transform = function exports_transform__3(_, path, options) { var compiler; var __frame = { name: 'exports_transform__3', line: 378 }; return __func(_, this, arguments, exports_transform__3, 0, __frame, function __$exports_transform__3() { - options = _extend({ noWrite: true }, options || {}); - compiler = _getCompiler(path); - return function __$exports_transform__3(__then) { if (compiler) { return compiler(__cb(_, __frame, 5, 0, __then, true, false), path, options); } else { __then(); } }(_); }); }; - - - - - - - - - exports.compile = function exports_compile__4(_, paths, options) { var failed, transform, cwd; - function _compile(_, path, base, options) { var stat, compiler; var __frame = { name: '_compile', line: 393 }; return __func(_, this, arguments, _compile, 0, __frame, function __$_compile() { - return fs.stat(path, __cb(_, __frame, 1, 0, function ___(__0, __2) { stat = __2; - return function __$_compile(__then) { if (stat.isDirectory()) { - base = base || path; - return fs.readdir(path, __cb(_, __frame, 4, 0, function ___(__0, __3) { return __3.forEach_(__cb(_, __frame, 4, 0, __then, true, false), function __1(_, f) { var __frame = { name: '__1', line: 397 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return _compile(__cb(_, __frame, 1, 0, function __$__1() { _(); }, true, false), path + '/' + f, base, options); }); }); }, true, false)); } else { - - return function __$_compile(__then) { if (stat.isFile()) { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$_compile() { - base = base || fspath.dirname(path); - options.baseDir = base; compiler = _getCompiler(path); - - return function __$_compile(__then) { if (compiler) { return compiler(__cb(_, __frame, 12, 0, __then, true, false), path, options); } else { __then(); } }(__then); }); }(function ___(ex, __result) { - __catch(function __$_compile() { if (ex) { - console.error(ex.stack); - failed++; __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(__then); } }(_); }, true, false)); }); } var __frame = { name: 'exports_compile__4', line: 392 }; return __func(_, this, arguments, exports_compile__4, 0, __frame, function __$exports_compile__4() { failed = 0; + if (options.verbose) { console.log('streamline: transforming: ' + path); } + options.lines = options.lines || (options.sourceMap ? 'sourcemap' : 'preserve'); + transformed = banner + _transform(transform, content, options); + return function __$cachedTransform(__then) { if (options.cache && path.indexOf('/tmp--') < 0) { return fs.writeFile(f, transformed, 'utf8', __cb(_, __frame, 21, 0, __then, true, false)); } else { __then(); } }(function __$cachedTransform() { + return _(null, transformed); }); }); }); } + + +exports.cachedTransformSync = compileSync.cachedTransformSync; + +function compileCoffee(_, path, options) { var jsPath, mapPath, outDir, coffeeOpts, source, coffee, compiled, js; var __frame = { name: 'compileCoffee', line: 327 }; return __func(_, this, arguments, compileCoffee, 0, __frame, function __$compileCoffee() { + return outputFile(__cb(_, __frame, 1, 0, function ___(__0, __2) { jsPath = __2; mapPath = jsPath.replace(/\.js$/, '.map'); + outDir = fspath.dirname(jsPath); + coffeeOpts = { filename: path, sourceMap: options.sourceMap, jsPath: jsPath, sourceRoot: fspath.relative(outDir, '.'), sourceFiles: [fspath.relative('.', path)], generatedFile: fspath.basename(jsPath) }; - options = options || {}; transform = _getTransform(options); - if (options.verbose) { console.log('transform version: ' + transform.version); } - if (!paths || paths.length == 0) { return _(new Error('cannot compile: no files specified')); } cwd = process.cwd(); - return paths.forEach_(__cb(_, __frame, 28, 0, function __$exports_compile__4() { - - - if (failed) { return _(new Error('errors found in ' + failed + ' files')); } _(); }, true, false), function __1(_, path) { var __frame = { name: '__1', line: 420 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return _compile(__cb(_, __frame, 1, 0, function __$__1() { _(); }, true, false), fspath.resolve(cwd, path), null, options); }); }); }); }; + return function __$compileCoffee(_) { var __1 = options.force; if (__1) { return _(null, __1); } return mtime(__cb(_, __frame, 12, 0, function ___(__0, __3) { return mtime(__cb(_, __frame, 12, 0, function ___(__0, __4) { var __2 = __3 > __4; return _(null, __2); }, true, false), jsPath); }, true, false), path); }(__cb(_, __frame, 12, 0, function ___(__0, __4) { var __3 = __4; return function __$compileCoffee(__then) { if (__3) { + return fs.readFile(path, 'utf8', __cb(_, __frame, 13, 0, function ___(__0, __5) { source = __5; coffee = require('../util/require')('coffee-script'); + compiled = coffee.compile(source, coffeeOpts); + + if (options.verbose) { console.log('streamline: coffee compiling: ' + path + ' to ' + jsPath); } + + if (options.sourceMap) { + js = compiled.js + '\n//# sourceMappingURL=' + fspath.basename(mapPath) + '\n'; } else { + + js = compiled; } + + return function __$compileCoffee(__then) { if (options.noWrite) { + return _(null, { transformed: js, sourceMap: compiled.v3SourceMap }); } else { + + + + + + return fs.writeFile(jsPath, js, 'utf8', __cb(_, __frame, 30, 0, function __$compileCoffee() { + return function __$compileCoffee(__then) { if (options.sourceMap) { + return fs.writeFile(mapPath, compiled.v3SourceMap, 'utf8', __cb(_, __frame, 32, 0, __then, true, false)); } else { __then(); } }(__then); }, true, false)); } }(__then); }, true, false)); } else { __then(); } }(_); }, true, false)); }, true, false), path, options); }); } + + + + + + +function _getCompiler(path) { + var ext = fspath.extname(path); + if (ext === '._js' || ext === '._coffee') { + return exports.compileFile; } else if (ext === '.coffee' && path[path.length - ext.length - 1] !== '_') { + + return compileCoffee; } else { } } + + + + + + + +exports.transform = function exports_transform__3(_, path, options) { var compiler; var __frame = { name: 'exports_transform__3', line: 379 }; return __func(_, this, arguments, exports_transform__3, 0, __frame, function __$exports_transform__3() { + options = _extend({ noWrite: true }, options || {}); + + compiler = _getCompiler(path); + + return function __$exports_transform__3(__then) { if (compiler) { return compiler(__cb(_, __frame, 5, 0, __then, true, false), path, options); } else { __then(); } }(_); }); }; + + + + + + + + +exports.compile = function exports_compile__4(_, paths, options) { var failed, transform, cwd; + function _compile(_, path, base, options) { var stat, compiler; var __frame = { name: '_compile', line: 394 }; return __func(_, this, arguments, _compile, 0, __frame, function __$_compile() { + return fs.stat(path, __cb(_, __frame, 1, 0, function ___(__0, __2) { stat = __2; + return function __$_compile(__then) { if (stat.isDirectory()) { + base = base || path; + return fs.readdir(path, __cb(_, __frame, 4, 0, function ___(__0, __3) { return __3.forEach_(__cb(_, __frame, 4, 0, __then, true, false), function __1(_, f) { var __frame = { name: '__1', line: 398 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return _compile(__cb(_, __frame, 1, 0, function __$__1() { _(); }, true, false), path + '/' + f, base, options); }); }); }, true, false)); } else { + + return function __$_compile(__then) { if (stat.isFile()) { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$_compile() { + base = base || fspath.dirname(path); + options.baseDir = base; compiler = _getCompiler(path); + + return function __$_compile(__then) { if (compiler) { return compiler(__cb(_, __frame, 12, 0, __then, true, false), path, options); } else { __then(); } }(__then); }); }(function ___(ex, __result) { + __catch(function __$_compile() { if (ex) { + console.error(ex.stack); + failed++; __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(__then); } }(_); }, true, false)); }); } var __frame = { name: 'exports_compile__4', line: 393 }; return __func(_, this, arguments, exports_compile__4, 0, __frame, function __$exports_compile__4() { failed = 0; + + + + + + + options = options || {}; transform = _getTransform(options); + + if (options.verbose) { console.log('transform version: ' + transform.version); } + if (!paths || paths.length == 0) { return _(new Error('cannot compile: no files specified')); } cwd = process.cwd(); + + return paths.forEach_(__cb(_, __frame, 28, 0, function __$exports_compile__4() { + + + if (failed) { return _(new Error('errors found in ' + failed + ' files')); } _(); }, true, false), function __1(_, path) { var __frame = { name: '__1', line: 421 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return _compile(__cb(_, __frame, 1, 0, function __$__1() { _(); }, true, false), fspath.resolve(cwd, path), null, options); }); }); }); }; diff --git a/lib/callbacks/flows.js b/lib/callbacks/flows.js index 39e84d5b..85e010cc 100644 --- a/lib/callbacks/flows.js +++ b/lib/callbacks/flows.js @@ -1,4 +1,39 @@ -/*** 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.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(function (exports) { + 'use strict'; + var globals = require('../globals'); + var dir = '../' + globals.runtime; + var builtins = require(dir + '/builtins'); @@ -7,369 +42,334 @@ + exports.each = function exports_each__1(_, array, fn, thisObj) { var __frame = { name: 'exports_each__1', line: 45 }; return __func(_, this, arguments, exports_each__1, 0, __frame, function __$exports_each__1() { + return function __$exports_each__1(_) { var __1 = array && array.length; return function __$exports_each__1(__then) { if (__1) { return array.forEach_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_each__1() { return _(null, undefined); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + exports.map = function exports_map__2(_, array, fn, thisObj) { var __frame = { name: 'exports_map__2', line: 51 }; return __func(_, this, arguments, exports_map__2, 0, __frame, function __$exports_map__2() { + return function __$exports_map__2(_) { var __1 = array; return function __$exports_map__2(__then) { if (__1) { return array.map_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_map__2() { return _(null, array); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + exports.filter = function exports_filter__3(_, array, fn, thisObj) { var __frame = { name: 'exports_filter__3', line: 57 }; return __func(_, this, arguments, exports_filter__3, 0, __frame, function __$exports_filter__3() { + return function __$exports_filter__3(_) { var __1 = array; return function __$exports_filter__3(__then) { if (__1) { return array.filter_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_filter__3() { return _(null, array); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + exports.every = function exports_every__4(_, array, fn, thisObj) { var __frame = { name: 'exports_every__4', line: 63 }; return __func(_, this, arguments, exports_every__4, 0, __frame, function __$exports_every__4() { + return function __$exports_every__4(_) { var __1 = array; return function __$exports_every__4(__then) { if (__1) { return array.every_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_every__4() { return _(null, undefined); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + exports.some = function exports_some__5(_, array, fn, thisObj) { var __frame = { name: 'exports_some__5', line: 69 }; return __func(_, this, arguments, exports_some__5, 0, __frame, function __$exports_some__5() { + return function __$exports_some__5(_) { var __1 = array; return function __$exports_some__5(__then) { if (__1) { return array.some_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_some__5() { return _(null, undefined); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + exports.reduce = function exports_reduce__6(_, array, fn, v, thisObj) { var __frame = { name: 'exports_reduce__6', line: 75 }; return __func(_, this, arguments, exports_reduce__6, 0, __frame, function __$exports_reduce__6() { + return function __$exports_reduce__6(_) { var __1 = array; return function __$exports_reduce__6(__then) { if (__1) { return array.reduce_(__cb(_, __frame, 1, 0, _, true, false), fn, v, thisObj); } else { __then(); } }(function __$exports_reduce__6() { return _(null, v); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; - (function (exports) { - 'use strict'; - var globals = require('../globals'); - var dir = '../' + globals.runtime; - var builtins = require(dir + '/builtins'); - - - - - - - - - exports.each = function exports_each__1(_, array, fn, thisObj) { var __frame = { name: 'exports_each__1', line: 45 }; return __func(_, this, arguments, exports_each__1, 0, __frame, function __$exports_each__1() { - return function __$exports_each__1(_) { var __1 = array && array.length; return function __$exports_each__1(__then) { if (__1) { return array.forEach_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_each__1() { return _(null, undefined); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - exports.map = function exports_map__2(_, array, fn, thisObj) { var __frame = { name: 'exports_map__2', line: 51 }; return __func(_, this, arguments, exports_map__2, 0, __frame, function __$exports_map__2() { - return function __$exports_map__2(_) { var __1 = array; return function __$exports_map__2(__then) { if (__1) { return array.map_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_map__2() { return _(null, array); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - exports.filter = function exports_filter__3(_, array, fn, thisObj) { var __frame = { name: 'exports_filter__3', line: 57 }; return __func(_, this, arguments, exports_filter__3, 0, __frame, function __$exports_filter__3() { - return function __$exports_filter__3(_) { var __1 = array; return function __$exports_filter__3(__then) { if (__1) { return array.filter_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_filter__3() { return _(null, array); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - exports.every = function exports_every__4(_, array, fn, thisObj) { var __frame = { name: 'exports_every__4', line: 63 }; return __func(_, this, arguments, exports_every__4, 0, __frame, function __$exports_every__4() { - return function __$exports_every__4(_) { var __1 = array; return function __$exports_every__4(__then) { if (__1) { return array.every_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_every__4() { return _(null, undefined); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - exports.some = function exports_some__5(_, array, fn, thisObj) { var __frame = { name: 'exports_some__5', line: 69 }; return __func(_, this, arguments, exports_some__5, 0, __frame, function __$exports_some__5() { - return function __$exports_some__5(_) { var __1 = array; return function __$exports_some__5(__then) { if (__1) { return array.some_(__cb(_, __frame, 1, 0, _, true, false), fn, thisObj); } else { __then(); } }(function __$exports_some__5() { return _(null, undefined); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - exports.reduce = function exports_reduce__6(_, array, fn, v, thisObj) { var __frame = { name: 'exports_reduce__6', line: 75 }; return __func(_, this, arguments, exports_reduce__6, 0, __frame, function __$exports_reduce__6() { - return function __$exports_reduce__6(_) { var __1 = array; return function __$exports_reduce__6(__then) { if (__1) { return array.reduce_(__cb(_, __frame, 1, 0, _, true, false), fn, v, thisObj); } else { __then(); } }(function __$exports_reduce__6() { return _(null, v); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - exports.reduceRight = function exports_reduceRight__7(_, array, fn, v, thisObj) { var __frame = { name: 'exports_reduceRight__7', line: 81 }; return __func(_, this, arguments, exports_reduceRight__7, 0, __frame, function __$exports_reduceRight__7() { - return function __$exports_reduceRight__7(_) { var __1 = array; return function __$exports_reduceRight__7(__then) { if (__1) { return array.reduceRight_(__cb(_, __frame, 1, 0, _, true, false), fn, v, thisObj); } else { __then(); } }(function __$exports_reduceRight__7() { return _(null, v); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - - - - exports.sort = function exports_sort__8(_, array, compare, beg, end) { var __frame = { name: 'exports_sort__8', line: 90 }; return __func(_, this, arguments, exports_sort__8, 0, __frame, function __$exports_sort__8() { - return function __$exports_sort__8(_) { var __1 = array; return function __$exports_sort__8(__then) { if (__1) { return array.sort_(__cb(_, __frame, 1, 0, _, true, false), compare, beg, end); } else { __then(); } }(function __$exports_sort__8() { return _(null, array); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - - - - - exports.eachKey = function exports_eachKey__9(_, obj, fn, thisObj) { var __frame = { name: 'exports_eachKey__9', line: 100 }; return __func(_, this, arguments, exports_eachKey__9, 0, __frame, function __$exports_eachKey__9() { - return (obj ? Object.keys(obj) : []).forEach_(__cb(_, __frame, 1, 0, _, true, false), function __1(_, elt) { var __frame = { name: '__1', line: 101 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, function __$__1() { _(); }, true, false), elt, obj[elt]); }); }); }); }; - - - - exports.spray = function (fns, max) { - return new function () { - - - var funnel = exports.funnel(max); - this.collect = function collect__1(_, count, trim) { var __this = this; var __frame = { name: 'collect__1', line: 111 }; return __func(_, this, arguments, collect__1, 0, __frame, function __$collect__1() { - return function (callback) { - if (typeof callback != 'function') throw new Error('invalid call to collect: no callback'); - var results = trim ? [] : new Array(fns.length); - count = count < 0 ? fns.length : Math.min(count, fns.length); - if (count == 0) return callback(null, results); - var collected = 0; - for (var i = 0; i < fns.length; i++) { - (function (i) { - funnel(function (err, result) { - if (err) return callback(err); - if (trim) results.push(result); else results[i] = result; - - if (++collected == count) return callback(null, results); }, fns[i]); }(i)); } }.call(__this, __cb(_, __frame, 17, 0, _, true, false)); }); }; + + + exports.reduceRight = function exports_reduceRight__7(_, array, fn, v, thisObj) { var __frame = { name: 'exports_reduceRight__7', line: 81 }; return __func(_, this, arguments, exports_reduceRight__7, 0, __frame, function __$exports_reduceRight__7() { + return function __$exports_reduceRight__7(_) { var __1 = array; return function __$exports_reduceRight__7(__then) { if (__1) { return array.reduceRight_(__cb(_, __frame, 1, 0, _, true, false), fn, v, thisObj); } else { __then(); } }(function __$exports_reduceRight__7() { return _(null, v); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + + + + + + + + exports.sort = function exports_sort__8(_, array, compare, beg, end) { var __frame = { name: 'exports_sort__8', line: 90 }; return __func(_, this, arguments, exports_sort__8, 0, __frame, function __$exports_sort__8() { + return function __$exports_sort__8(_) { var __1 = array; return function __$exports_sort__8(__then) { if (__1) { return array.sort_(__cb(_, __frame, 1, 0, _, true, false), compare, beg, end); } else { __then(); } }(function __$exports_sort__8() { return _(null, array); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + + + + + + + + + exports.eachKey = function exports_eachKey__9(_, obj, fn, thisObj) { var __frame = { name: 'exports_eachKey__9', line: 100 }; return __func(_, this, arguments, exports_eachKey__9, 0, __frame, function __$exports_eachKey__9() { + return (obj ? Object.keys(obj) : []).forEach_(__cb(_, __frame, 1, 0, _, true, false), function __1(_, elt) { var __frame = { name: '__1', line: 101 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, function __$__1() { _(); }, true, false), elt, obj[elt]); }); }); }); }; + + + + exports.spray = function (fns, max) { + return new function () { + + + var funnel = exports.funnel(max); + this.collect = function collect__1(_, count, trim) { var __this = this; var __frame = { name: 'collect__1', line: 111 }; return __func(_, this, arguments, collect__1, 0, __frame, function __$collect__1() { + return function (callback) { + if (typeof callback != 'function') throw new Error('invalid call to collect: no callback'); + var results = trim ? [] : new Array(fns.length); + count = count < 0 ? fns.length : Math.min(count, fns.length); + if (count == 0) return callback(null, results); + var collected = 0; + for (var i = 0; i < fns.length; i++) { + (function (i) { + funnel(function (err, result) { + if (err) return callback(err); + if (trim) results.push(result); else results[i] = result; + + if (++collected == count) return callback(null, results); }, fns[i]); }(i)); } }.call(__this, __cb(_, __frame, 17, 0, _, true, false)); }); }; + + + + + + this.collectOne = function collectOne__2(_) { var result, __this = this; var __frame = { name: 'collectOne__2', line: 130 }; return __func(_, this, arguments, collectOne__2, 0, __frame, function __$collectOne__2() { + return __this.collect(__cb(_, __frame, 1, 0, function ___(__0, __1) { result = __1; + return _(null, result && result[0]); }, true, false), 1, true); }); }; + + this.collectAll = function collectAll__3(_) { var __this = this; var __frame = { name: 'collectAll__3', line: 134 }; return __func(_, this, arguments, collectAll__3, 0, __frame, function __$collectAll__3() { + return __this.collect(__cb(_, __frame, 1, 0, _, true, false), -1, false); }); }; }(); }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + exports.funnel = builtins.funnel; + + + + + + + + + exports.handshake = function () { + var callback = null, notified = false; + return { wait: __rt.streamlinify(function (cb) { + if (callback) throw new Error('already waiting'); + if (notified) exports.setImmediate(cb); else callback = cb; + notified = false; }, 0), notify: function () { + if (!callback) notified = true; else exports.setImmediate(callback); - this.collectOne = function collectOne__2(_) { var result, __this = this; var __frame = { name: 'collectOne__2', line: 130 }; return __func(_, this, arguments, collectOne__2, 0, __frame, function __$collectOne__2() { - return __this.collect(__cb(_, __frame, 1, 0, function ___(__0, __1) { result = __1; - return _(null, result && result[0]); }, true, false), 1, true); }); }; + callback = null; } }; }; + + + + + + + + + + + + + + exports.queue = function (options) { + options = options || {}; + var max = options.max != null ? options.max : -1; + var callback = null, q = [], pendingWrites = []; + return { read: __rt.streamlinify(function (cb) { - this.collectAll = function collectAll__3(_) { var __this = this; var __frame = { name: 'collectAll__3', line: 134 }; return __func(_, this, arguments, collectAll__3, 0, __frame, function __$collectAll__3() { - return __this.collect(__cb(_, __frame, 1, 0, _, true, false), -1, false); }); }; }(); }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - exports.funnel = builtins.funnel; - - - - - - - - - exports.handshake = function () { - var callback = null, notified = false; - return { wait: __rt.streamlinify(function (cb) { - - if (callback) throw new Error('already waiting'); - if (notified) exports.setImmediate(cb); else callback = cb; - - notified = false; }, 0), notify: function () { - - - if (!callback) notified = true; else exports.setImmediate(callback); - - callback = null; } }; }; - - - - - - - - - - - - - - exports.queue = function (options) { - options = options || {}; - var max = options.max != null ? options.max : -1; - var callback = null, q = [], pendingWrites = []; - return { read: __rt.streamlinify(function (cb) { - - if (callback) throw new Error('already getting'); - if (q.length > 0) { - var item = q.shift(); - - if (q.length === 0) q = []; - exports.setImmediate(function () { - cb(null, item); }); - - if (pendingWrites.length > 0) { - var wr = pendingWrites.shift(); - exports.setImmediate(function () { - wr[0](null, wr[1]); }); } } else { - - - - callback = cb; } }, 0), write: __rt.streamlinify(function (cb, item) { - + if (callback) throw new Error('already getting'); + if (q.length > 0) { + var item = q.shift(); + if (q.length === 0) q = []; + exports.setImmediate(function () { + cb(null, item); }); - if (this.put(item)) { + if (pendingWrites.length > 0) { + var wr = pendingWrites.shift(); exports.setImmediate(function () { - cb(); }); } else { - - - pendingWrites.push([ cb, item ]); } }, 0), put: function (item, force) { + wr[0](null, wr[1]); }); } } else { - if (!callback) { - if (max >= 0 && q.length >= max && !force) return false; - q.push(item); } else { - - var cb = callback; - callback = null; - exports.setImmediate(function () { - cb(null, item); }); } - - - return true; }, end: function () { + callback = cb; } }, 0), write: __rt.streamlinify(function (cb, item) { + + + + if (this.put(item)) { + exports.setImmediate(function () { + cb(); }); } else { - this.put(undefined, true); } }; }; - - - - - - - - - exports.collect = function exports_collect__10(_, futures) { var __frame = { name: 'exports_collect__10', line: 258 }; return __func(_, this, arguments, exports_collect__10, 0, __frame, function __$exports_collect__10() { - return function __$exports_collect__10(_) { var __2 = futures; if (!__2) { return _(null, __2); } return futures.map_(__cb(_, __frame, 1, 0, _, true, false), function __1(_, future) { var __frame = { name: '__1', line: 259 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return future(__cb(_, __frame, 1, 0, _, true, false)); }); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - - - - var globals = require('../globals'); - exports.setContext = function (ctx) { - var old = globals.context; - globals.context = ctx; - return old; }; - - exports.getContext = function () { - return globals.context; }; - - - - - - - - - exports.trampoline = __rt.streamlinify(function (cb, fn, thisObj) { - fn = globals.withContext(fn, globals.context); - exports.setImmediate(function () { - fn.call(thisObj, cb); }); }, 0); - - - - - - - exports.setImmediate = typeof setImmediate === 'function' ? setImmediate : function (fn) { - setTimeout(fn, 0); }; - - - - - - - var nextTick = typeof process === 'object' && typeof process.nextTick === 'function' ? process.nextTick : function (cb) { - cb(); }; - - - - exports.nextTick = function exports_nextTick__11(_) { var __frame = { name: 'exports_nextTick__11', line: 304 }; return __func(_, this, arguments, exports_nextTick__11, 0, __frame, function __$exports_nextTick__11() { - return nextTick(__cb(_, __frame, 1, 0, function __$exports_nextTick__11() { _(); }, true, false)); }); }; - - - - - exports.setTimeout = function (fn, millis) { - - - - var max = 2147483647; - if (millis > max) { - return setTimeout(function () { - exports.setTimeout(fn, millis - max); }, max); } else { + pendingWrites.push([ cb, item ]); } }, 0), put: function (item, force) { - return setTimeout(function () { - fn(false); }, millis); } }; - - - - - - exports.setInterval = function (fn, millis) { - return setInterval(function () { - fn(false); }, millis); }; - - - - - - - exports.sleep = function exports_sleep__12(_, millis) { var __frame = { name: 'exports_sleep__12', line: 336 }; return __func(_, this, arguments, exports_sleep__12, 0, __frame, function __$exports_sleep__12() { - return setTimeout(__cb(_, __frame, 1, 0, _, true, false), millis); }); }; - - - exports.eventHandler = function (fn) { - return function () { - var that = this; - var args = Array.prototype.slice(arguments, 0); - return function __1(_) { var __frame = { name: '__1', line: 344 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.apply_(__cb(_, __frame, 1, 0, _, true, false), that, args, 0); }); }(function (err) { + + if (!callback) { + if (max >= 0 && q.length >= max && !force) return false; + q.push(item); } else { - if (err) throw err; }); }; }; - - - - - - exports.apply = function apply(_, fn, thisObj, args, index) { var __frame = { name: 'apply', line: 353 }; return __func(_, this, arguments, apply, 0, __frame, function __$apply() { - return fn.apply_(__cb(_, __frame, 1, 0, _, true, false), thisObj, args, index); }); }; - - - + var cb = callback; + callback = null; + exports.setImmediate(function () { + cb(null, item); }); } + + + return true; }, end: function () { + + + this.put(undefined, true); } }; }; + + + + + + + + + exports.collect = function exports_collect__10(_, futures) { var __frame = { name: 'exports_collect__10', line: 258 }; return __func(_, this, arguments, exports_collect__10, 0, __frame, function __$exports_collect__10() { + return function __$exports_collect__10(_) { var __2 = futures; if (!__2) { return _(null, __2); } return futures.map_(__cb(_, __frame, 1, 0, _, true, false), function __1(_, future) { var __frame = { name: '__1', line: 259 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return future(__cb(_, __frame, 1, 0, _, true, false)); }); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; + + + + + var globals = require('../globals'); + exports.setContext = function (ctx) { + var old = globals.context; + globals.context = ctx; + return old; }; + + exports.getContext = function () { + return globals.context; }; + + + + + + + + + exports.trampoline = __rt.streamlinify(function (cb, fn, thisObj) { + fn = globals.withContext(fn, globals.context); + exports.setImmediate(function () { + fn.call(thisObj, cb); }); }, 0); + + + + + + + exports.setImmediate = typeof setImmediate === 'function' ? setImmediate : function (fn) { + setTimeout(fn, 0); }; + + + + + + + var nextTick = typeof process === 'object' && typeof process.nextTick === 'function' ? process.nextTick : function (cb) { + cb(); }; + + + + exports.nextTick = function exports_nextTick__11(_) { var __frame = { name: 'exports_nextTick__11', line: 304 }; return __func(_, this, arguments, exports_nextTick__11, 0, __frame, function __$exports_nextTick__11() { + return nextTick(__cb(_, __frame, 1, 0, function __$exports_nextTick__11() { _(); }, true, false)); }); }; + + + + + exports.setTimeout = function (fn, millis) { - exports.callWithTimeout = __rt.streamlinify(function (cb, fn, millis) { - var tid = setTimeout(function () { - if (cb) { - var ex = new Error('timeout'); - ex.code = 'ETIMEOUT'; - ex.errno = 'ETIMEOUT'; - cb(ex); - cb = null; } }, millis); + var max = 2147483647; + if (millis > max) { + return setTimeout(function () { + exports.setTimeout(fn, millis - max); }, max); } else { - fn(function (err, result) { - if (cb) { - clearTimeout(tid); - cb(err, result); - cb = null; } }); }, 0); }(typeof exports !== 'undefined' ? exports : Streamline.flows = Streamline.flows || {})); \ No newline at end of file + return setTimeout(function () { + fn(false); }, millis); } }; + + + + + + exports.setInterval = function (fn, millis) { + return setInterval(function () { + fn(false); }, millis); }; + + + + + + + exports.sleep = function exports_sleep__12(_, millis) { var __frame = { name: 'exports_sleep__12', line: 336 }; return __func(_, this, arguments, exports_sleep__12, 0, __frame, function __$exports_sleep__12() { + return setTimeout(__cb(_, __frame, 1, 0, _, true, false), millis); }); }; + + + exports.eventHandler = function (fn) { + return function () { + var that = this; + var args = Array.prototype.slice(arguments, 0); + return function __1(_) { var __frame = { name: '__1', line: 344 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.apply_(__cb(_, __frame, 1, 0, _, true, false), that, args, 0); }); }(function (err) { + + if (err) throw err; }); }; }; + + + + + + exports.apply = function apply(_, fn, thisObj, args, index) { var __frame = { name: 'apply', line: 353 }; return __func(_, this, arguments, apply, 0, __frame, function __$apply() { + return fn.apply_(__cb(_, __frame, 1, 0, _, true, false), thisObj, args, index); }); }; + + + + + + + exports.callWithTimeout = __rt.streamlinify(function (cb, fn, millis) { + var tid = setTimeout(function () { + if (cb) { + var ex = new Error('timeout'); + ex.code = 'ETIMEOUT'; + ex.errno = 'ETIMEOUT'; + cb(ex); + cb = null; } }, millis); + + + fn(function (err, result) { + if (cb) { + clearTimeout(tid); + cb(err, result); + cb = null; } }); }, 0); }(typeof exports !== 'undefined' ? exports : Streamline.flows = Streamline.flows || {})); \ No newline at end of file diff --git a/lib/callbacks/runtime-all.js b/lib/callbacks/runtime-all.js index 2145ff4b..04b9c0cf 100644 --- a/lib/callbacks/runtime-all.js +++ b/lib/callbacks/runtime-all.js @@ -422,370 +422,370 @@ 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.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; + + + + + + + +(function (exports) { + 'use strict'; + var VERSION = 3; + var 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; }; + + fn.apply(this, args); + return function F(cb) { + if (!cb) return F; + if (done) cb.call(self, err, result); else q.push(cb); }; }; + - (function (exports) { - 'use strict'; - var VERSION = 3; + 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 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; }; + var funCb = function (callback, fn) { + if (callback == null) return future(funCb, arguments, 0); - fn.apply(this, args); - return function F(cb) { - if (!cb) return F; - if (done) cb.call(self, err, result); else q.push(cb); }; }; - - - - - - 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; + if (max < 0 || max == Infinity) return fn(callback); + queue.push({ fn: fn, cb: callback }); - var funCb = function (callback, fn) { - if (callback == null) return future(funCb, arguments, 0); - - 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(); }; - var fun = __rt.streamlinify(funCb, 0); - fun.close = function () { - queue = [], closed = true; }; + 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(); } }); } - return fun; }; - - var funnel = exports.funnel; - funnel.defaultSize = 4; - - function _parallel(options) { - if (typeof options === 'number') return options; - if (typeof options.parallel === 'number') return options.parallel; - return options.parallel ? -1 : 1; } - - - if (Array.prototype.forEach_ && Array.prototype.forEach_.version_ >= VERSION) return; - - - try { - Object.defineProperty({}, 'x', {}); } catch (e) { - return; } - - - var has = Object.prototype.hasOwnProperty; - - - - - - - - - - - - - - - - - - - - - + + + while (active < max && queue.length > 0) _doOne(); }; + var fun = __rt.streamlinify(funCb, 0); + fun.close = function () { + queue = [], closed = true; }; + return fun; }; + + var funnel = exports.funnel; + funnel.defaultSize = 4; + + function _parallel(options) { + if (typeof options === 'number') return options; + if (typeof options.parallel === 'number') return options.parallel; + return options.parallel ? -1 : 1; } + + + if (Array.prototype.forEach_ && Array.prototype.forEach_.version_ >= VERSION) return; + + + try { + Object.defineProperty({}, 'x', {}); } catch (e) { - delete Array.prototype.forEach_; - Object.defineProperty(Array.prototype, 'forEach_', { configurable: true, writable: true, enumerable: false, value: function value__1(_, options, fn, thisObj) { - + return; } + + + var has = Object.prototype.hasOwnProperty; + + + + + + + + + + + + + + + + + + + + + + + + + + delete Array.prototype.forEach_; + Object.defineProperty(Array.prototype, 'forEach_', { configurable: true, writable: true, enumerable: false, value: function value__1(_, options, fn, thisObj) { + + + + var par, len, i, __this = this; var __frame = { name: 'value__1', line: 124 }; return __func(_, this, arguments, value__1, 0, __frame, function __$value__1() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, i, __this = this; var __frame = { name: 'value__1', line: 124 }; return __func(_, this, arguments, value__1, 0, __frame, function __$value__1() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); - - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - - return function __$value__1(__then) { if (par === 1 || len <= 1) { i = 0; - var __2 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__1() { __more = false; if (__2) { i++; } else { __2 = true; } var __1 = i < len; if (__1) { - return function __$value__1(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 7, 0, __then, true, false), __this[i], i); } else { __then(); } }(function __$value__1() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - - return __this.map_(__cb(_, __frame, 10, 0, __then, true, false), par, fn, thisObj); } }(function __$value__1() { + return function __$value__1(__then) { if (par === 1 || len <= 1) { + i = 0; var __2 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__1() { __more = false; if (__2) { i++; } else { __2 = true; } var __1 = i < len; if (__1) { + return function __$value__1(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 7, 0, __then, true, false), __this[i], i); } else { __then(); } }(function __$value__1() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - return _(null, __this); }); }); } }); - - - Array.prototype.forEach_.version_ = VERSION; - - - delete Array.prototype.map_; - Object.defineProperty(Array.prototype, 'map_', { configurable: true, writable: true, enumerable: false, value: function value__2(_, options, fn, thisObj) { + + return __this.map_(__cb(_, __frame, 10, 0, __then, true, false), par, fn, thisObj); } }(function __$value__1() { + + return _(null, __this); }); }); } }); + + + Array.prototype.forEach_.version_ = VERSION; + + + delete Array.prototype.map_; + Object.defineProperty(Array.prototype, 'map_', { configurable: true, writable: true, enumerable: false, value: function value__2(_, options, fn, thisObj) { + + + + var par, len, result, i, fun, __this = this; var __frame = { name: 'value__2', line: 147 }; return __func(_, this, arguments, value__2, 0, __frame, function __$value__2() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, result, i, fun, __this = this; var __frame = { name: 'value__2', line: 147 }; return __func(_, this, arguments, value__2, 0, __frame, function __$value__2() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); - - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - - - return function __$value__2(__then) { if (par === 1 || len <= 1) { - result = new Array(len); i = 0; - var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < len; if (__3) { - return function __$value__2(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 9, 0, function ___(__0, __1) { result[i] = __1; __then(); }, true, false), __this[i], i); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - - result = __this.map(function (elt, i) { - return fun(false, function __1(_) { var __frame = { name: '__1', line: 161 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt, i); }); }); }); i = 0; - - - var __7 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < len; if (__6) { - return function __$value__2(__then) { if (has.call(__this, i)) { return result[i](__cb(_, __frame, 19, 0, function ___(__0, __2) { result[i] = __2; __then(); }, true, false)); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__2() { + return function __$value__2(__then) { if (par === 1 || len <= 1) { + result = new Array(len); + i = 0; var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < len; if (__3) { + return function __$value__2(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 9, 0, function ___(__0, __1) { result[i] = __1; __then(); }, true, false), __this[i], i); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + fun = funnel(par); - return _(null, result); }); }); } }); - - - - - delete Array.prototype.filter_; - Object.defineProperty(Array.prototype, 'filter_', { configurable: true, writable: true, enumerable: false, value: function value__3(_, options, fn, thisObj) { - + result = __this.map(function (elt, i) { + return fun(false, function __1(_) { var __frame = { name: '__1', line: 161 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt, i); }); }); }); + + + i = 0; var __7 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < len; if (__6) { + return function __$value__2(__then) { if (has.call(__this, i)) { return result[i](__cb(_, __frame, 19, 0, function ___(__0, __2) { result[i] = __2; __then(); }, true, false)); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__2() { + + + return _(null, result); }); }); } }); + + + + + delete Array.prototype.filter_; + Object.defineProperty(Array.prototype, 'filter_', { configurable: true, writable: true, enumerable: false, value: function value__3(_, options, fn, thisObj) { + + + + var par, result, len, i, elt, __this = this; var __frame = { name: 'value__3', line: 179 }; return __func(_, this, arguments, value__3, 0, __frame, function __$value__3() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; result = []; + len = __this.length; - var par, result, len, i, elt, __this = this; var __frame = { name: 'value__3', line: 179 }; return __func(_, this, arguments, value__3, 0, __frame, function __$value__3() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + return function __$value__3(__then) { if (par === 1 || len <= 1) { + i = 0; var __5 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__3() { __more = false; if (__5) { i++; } else { __5 = true; } var __4 = i < len; if (__4) { + return function __$value__3(__then) { if (has.call(__this, i)) { elt = __this[i]; + + return fn.call(thisObj, __cb(_, __frame, 10, 0, function ___(__0, __3) { var __2 = __3; return function __$value__3(__then) { if (__2) { result.push(elt); __then(); } else { __then(); } }(__then); }, true, false), elt); } else { __then(); } }(function __$value__3() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + + + + return __this.map_(__cb(_, __frame, 14, 0, __then, true, false), par, function __1(_, elt) { var __frame = { name: '__1', line: 193 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$__1(__then) { if (__1) { result.push(elt); __then(); } else { __then(); } }(_); }, true, false), elt); }); }, thisObj); } }(function __$value__3() { - thisObj = thisObj !== undefined ? thisObj : __this; result = []; - len = __this.length; - return function __$value__3(__then) { if (par === 1 || len <= 1) { i = 0; - var __5 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__3() { __more = false; if (__5) { i++; } else { __5 = true; } var __4 = i < len; if (__4) { - return function __$value__3(__then) { if (has.call(__this, i)) { elt = __this[i]; - - return fn.call(thisObj, __cb(_, __frame, 10, 0, function ___(__0, __3) { var __2 = __3; return function __$value__3(__then) { if (__2) { result.push(elt); __then(); } else { __then(); } }(__then); }, true, false), elt); } else { __then(); } }(function __$value__3() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - + return _(null, result); }); }); } }); + + + + + delete Array.prototype.every_; + Object.defineProperty(Array.prototype, 'every_', { configurable: true, writable: true, enumerable: false, value: function value__4(_, options, fn, thisObj) { + + + + var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__4', line: 207 }; return __func(_, this, arguments, value__4, 0, __frame, function __$value__4() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + + return function __$value__4(__then) { if (par === 1 || len <= 1) { + i = 0; var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { + + return function __$value__4(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 8, 0, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true, false), __this[i]); }(__cb(_, __frame, 8, 0, function ___(__0, __4) { var __3 = __4; return function __$value__4(__then) { if (__3) { return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + + fun = funnel(par); + futures = __this.map(function (elt) { - return __this.map_(__cb(_, __frame, 14, 0, __then, true, false), par, function __1(_, elt) { var __frame = { name: '__1', line: 193 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$__1(__then) { if (__1) { result.push(elt); __then(); } else { __then(); } }(_); }, true, false), elt); }); }, thisObj); } }(function __$value__3() { + return fun(false, function __1(_) { var __frame = { name: '__1', line: 220 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); - return _(null, result); }); }); } }); - - - - - delete Array.prototype.every_; - Object.defineProperty(Array.prototype, 'every_', { configurable: true, writable: true, enumerable: false, value: function value__4(_, options, fn, thisObj) { - - - - var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__4', line: 207 }; return __func(_, this, arguments, value__4, 0, __frame, function __$value__4() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + i = 0; var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { + return function __$value__4(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 18, 0, function ___(__0, __4) { var __3 = !__4; return _(null, __3); }, true, false)); }(__cb(_, __frame, 18, 0, function ___(__0, __6) { var __5 = __6; return function __$value__4(__then) { if (__5) { + fun.close(); + return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__4() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - return function __$value__4(__then) { if (par === 1 || len <= 1) { i = 0; - var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { - - return function __$value__4(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 8, 0, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true, false), __this[i]); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$value__4(__then) { if (__3) { return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - futures = __this.map(function (elt) { - - return fun(false, function __1(_) { var __frame = { name: '__1', line: 220 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); i = 0; - - - var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { - return function __$value__4(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 18, 0, function ___(__0, __4) { var __3 = !__4; return _(null, __3); }, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { var __5 = __6; return function __$value__4(__then) { if (__5) { - fun.close(); - return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__4() { + + return _(null, true); }); }); } }); + + + + + delete Array.prototype.some_; + Object.defineProperty(Array.prototype, 'some_', { configurable: true, writable: true, enumerable: false, value: function value__5(_, options, fn, thisObj) { + + + + var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__5', line: 241 }; return __func(_, this, arguments, value__5, 0, __frame, function __$value__5() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + + return function __$value__5(__then) { if (par === 1 || len <= 1) { + i = 0; var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { + return function __$value__5(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 7, 0, _, true, false), __this[i]); }(__cb(_, __frame, 7, 0, function ___(__0, __4) { var __3 = __4; return function __$value__5(__then) { if (__3) { return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + fun = funnel(par); + futures = __this.map(function (elt) { + + return fun(false, function __1(_) { var __frame = { name: '__1', line: 253 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); - return _(null, true); }); }); } }); - - - - - delete Array.prototype.some_; - Object.defineProperty(Array.prototype, 'some_', { configurable: true, writable: true, enumerable: false, value: function value__5(_, options, fn, thisObj) { - + i = 0; var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { + return function __$value__5(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 17, 0, _, true, false)); }(__cb(_, __frame, 17, 0, function ___(__0, __6) { var __5 = __6; return function __$value__5(__then) { if (__5) { + fun.close(); + return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__5() { + + + + return _(null, false); }); }); } }); + + + + + delete Array.prototype.reduce_; + Object.defineProperty(Array.prototype, 'reduce_', { configurable: true, writable: true, enumerable: false, value: function value__6(_, fn, v, thisObj) { + + + + var len, i, __this = this; var __frame = { name: 'value__6', line: 274 }; return __func(_, this, arguments, value__6, 0, __frame, function __$value__6() { + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + i = 0; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__6() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < len; if (__2) { + return function __$value__6(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__6() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__6() { + + return _(null, v); }); }); } }); + + + + + delete Array.prototype.reduceRight_; + Object.defineProperty(Array.prototype, 'reduceRight_', { configurable: true, writable: true, enumerable: false, value: function value__7(_, fn, v, thisObj) { + + + + var len, i, __this = this; var __frame = { name: 'value__7', line: 290 }; return __func(_, this, arguments, value__7, 0, __frame, function __$value__7() { + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__5', line: 241 }; return __func(_, this, arguments, value__5, 0, __frame, function __$value__5() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + i = len - 1; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__7() { __more = false; if (__3) { i--; } else { __3 = true; } var __2 = i >= 0; if (__2) { + return function __$value__7(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__7() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__7() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + return _(null, v); }); }); } }); + + + + + + + delete Array.prototype.sort_; + Object.defineProperty(Array.prototype, 'sort_', { configurable: true, writable: true, enumerable: false, value: function value__8(_, compare, beg, end) { + + + + var array, __this = this; + + + + + function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: '_qsort', line: 313 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() { + if (beg >= end) { return _(null); } - return function __$value__5(__then) { if (par === 1 || len <= 1) { i = 0; - var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { - return function __$value__5(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 7, 0, _, true, false), __this[i]); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$value__5(__then) { if (__3) { return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - futures = __this.map(function (elt) { - - return fun(false, function __1(_) { var __frame = { name: '__1', line: 253 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); i = 0; - - - var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { - return function __$value__5(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 17, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { var __5 = __6; return function __$value__5(__then) { if (__5) { - fun.close(); - return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__5() { + return function __$_qsort(__then) { if (end == beg + 1) { + return compare(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 > 0; return function __$_qsort(__then) { if (__3) { tmp = array[beg]; + + array[beg] = array[end]; + array[end] = tmp; __then(); } else { __then(); } }(function __$_qsort() { + + return _(null); }); }, true, false), array[beg], array[end]); } else { __then(); } }(function __$_qsort() { mid = Math.floor((beg + end) / 2); + o = array[mid]; + nbeg = beg; + nend = end; - return _(null, false); }); }); } }); - - - - - delete Array.prototype.reduce_; - Object.defineProperty(Array.prototype, 'reduce_', { configurable: true, writable: true, enumerable: false, value: function value__6(_, fn, v, thisObj) { - - - - var len, i, __this = this; var __frame = { name: 'value__6', line: 274 }; return __func(_, this, arguments, value__6, 0, __frame, function __$value__6() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - i = 0; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__6() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < len; if (__2) { - return function __$value__6(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__6() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__6() { - return _(null, v); }); }); } }); - - - - - delete Array.prototype.reduceRight_; - Object.defineProperty(Array.prototype, 'reduceRight_', { configurable: true, writable: true, enumerable: false, value: function value__7(_, fn, v, thisObj) { - - - - var len, i, __this = this; var __frame = { name: 'value__7', line: 290 }; return __func(_, this, arguments, value__7, 0, __frame, function __$value__7() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - i = len - 1; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__7() { __more = false; if (__3) { i--; } else { __3 = true; } var __2 = i >= 0; if (__2) { - return function __$value__7(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__7() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__7() { - - return _(null, v); }); }); } }); - - - - - - - delete Array.prototype.sort_; - Object.defineProperty(Array.prototype, 'sort_', { configurable: true, writable: true, enumerable: false, value: function value__8(_, compare, beg, end) { - - - - var array, __this = this; - - - - - function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: '_qsort', line: 313 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() { - if (beg >= end) { return _(null); } - - return function __$_qsort(__then) { if (end == beg + 1) { - return compare(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 > 0; return function __$_qsort(__then) { if (__3) { tmp = array[beg]; + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; var __6 = nbeg <= nend; if (__6) { + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { return function __$_qsort(_) { var __1 = nbeg < end; if (!__1) { return _(null, __1); } return compare(__cb(_, __frame, 18, 0, function ___(__0, __3) { var __2 = __3 < 0; return _(null, __2); }, true, false), array[nbeg], o); }(__cb(_, __frame, 18, 0, _, true, false)); }(__cb(_, __frame, 18, 0, function ___(__0, __7) { if (__7) { nbeg++; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { return function __$_qsort(_) { var __2 = beg < nend; if (!__2) { return _(null, __2); } return compare(__cb(_, __frame, 19, 0, function ___(__0, __4) { var __3 = __4 < 0; return _(null, __3); }, true, false), o, array[nend]); }(__cb(_, __frame, 19, 0, _, true, false)); }(__cb(_, __frame, 19, 0, function ___(__0, __9) { if (__9) { nend--; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - array[beg] = array[end]; - array[end] = tmp; __then(); } else { __then(); } }(function __$_qsort() { - - return _(null); }); }, true, false), array[beg], array[end]); } else { __then(); } }(function __$_qsort() { mid = Math.floor((beg + end) / 2); + if (nbeg <= nend) { tmp = array[nbeg]; + + array[nbeg] = array[nend]; + array[nend] = tmp; + nbeg++; + nend--; } while (__more) { __loop(); } __more = true; }); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - o = array[mid]; - nbeg = beg; - nend = end; - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; var __6 = nbeg <= nend; - - if (__6) { return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { - return function __$_qsort(_) { var __1 = nbeg < end; if (!__1) { return _(null, __1); } return compare(__cb(_, __frame, 18, 0, function ___(__0, __3) { var __2 = __3 < 0; return _(null, __2); }, true, false), array[nbeg], o); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __7) { if (__7) { nbeg++; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { - return function __$_qsort(_) { var __2 = beg < nend; if (!__2) { return _(null, __2); } return compare(__cb(_, __frame, 19, 0, function ___(__0, __4) { var __3 = __4 < 0; return _(null, __3); }, true, false), o, array[nend]); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __9) { if (__9) { nend--; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - - if (nbeg <= nend) { tmp = array[nbeg]; - - array[nbeg] = array[nend]; - array[nend] = tmp; - nbeg++; - nend--; } while (__more) { __loop(); } __more = true; }); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - - - - return function __$_qsort(__then) { if (nbeg < end) { return _qsort(__cb(_, __frame, 30, 0, __then, true, false), nbeg, end); } else { __then(); } }(function __$_qsort() { - return function __$_qsort(__then) { if (beg < nend) { return _qsort(__cb(_, __frame, 31, 0, __then, true, false), beg, nend); } else { __then(); } }(_); }); }); }); }); } var __frame = { name: 'value__8', line: 308 }; return __func(_, this, arguments, value__8, 0, __frame, function __$value__8() { array = __this; beg = beg || 0; end = end == null ? array.length - 1 : end; - - return _qsort(__cb(_, __frame, 38, 0, function __$value__8() { - return _(null, array); }, true, false), beg, end); }); } }); - - - - - - - - - - - - delete Function.prototype.apply_; - Object.defineProperty(Function.prototype, 'apply_', { configurable: true, writable: true, enumerable: false, value: function (callback, thisObj, args, index) { - - - + + return function __$_qsort(__then) { if (nbeg < end) { return _qsort(__cb(_, __frame, 30, 0, __then, true, false), nbeg, end); } else { __then(); } }(function __$_qsort() { + return function __$_qsort(__then) { if (beg < nend) { return _qsort(__cb(_, __frame, 31, 0, __then, true, false), beg, nend); } else { __then(); } }(_); }); }); }); }); } var __frame = { name: 'value__8', line: 308 }; return __func(_, this, arguments, value__8, 0, __frame, function __$value__8() { array = __this; beg = beg || 0; end = end == null ? array.length - 1 : end; - args = Array.prototype.slice.call(args, 0); - args.splice(index != null && index >= 0 ? index : args.length, 0, callback); - return this.apply(thisObj, args); } }); }(typeof exports !== 'undefined' ? exports : Streamline.builtins = Streamline.builtins || {})); + return _qsort(__cb(_, __frame, 38, 0, function __$value__8() { + return _(null, array); }, true, false), beg, end); }); } }); + + + + + + + + + + + + delete Function.prototype.apply_; + Object.defineProperty(Function.prototype, 'apply_', { configurable: true, writable: true, enumerable: false, value: function (callback, thisObj, args, index) { + + + + + args = Array.prototype.slice.call(args, 0); + args.splice(index != null && index >= 0 ? index : args.length, 0, callback); + return this.apply(thisObj, args); } }); }(typeof exports !== 'undefined' ? exports : Streamline.builtins = Streamline.builtins || {})); diff --git a/lib/callbacks/transform-all.js b/lib/callbacks/transform-all.js index 2cabcea3..5805ff5a 100644 --- a/lib/callbacks/transform-all.js +++ b/lib/callbacks/transform-all.js @@ -8123,6 +8123,7 @@ if (typeof exports !== 'undefined') { return child; }, true); node = _flatten(node); + node.loc = node.loc || loc; return node; } } @@ -9728,6 +9729,7 @@ if (typeof exports !== 'undefined') { var node = esprima.parse(source, { loc: true, range: true, + source: options.sourceName || '', }); node = node.body[0].body; if (node.type !== 'BlockStatement') throw new Error("source wrapper error: " + node.type); @@ -9751,22 +9753,38 @@ if (typeof exports !== 'undefined') { var used = {}; node = _simplify(node, options, used); //fixRanges(node); - addNewlines(node); - var result = escodegen.generate(node, { + if (options.lines === "preserve") addNewlines(node); + + // transform top node into Program to avoid extra curly braces + if (node.type === "BlockStatement") node.type = "Program"; + + var ecopts = options.sourceMap ? { + sourceMap: true, + sourceMapWithCode: true, + } : options.lines === "preserve" ? { comment: true, - }); - // remove curly braces around generated source - result = result[0] === '{' ? result.substring(1, result.length - 1) : result; - // turn comments into newlines - //result = result.replace(/\n\s*/g, ' ').replace(/\/\*undefined\*\//g, '\n'); - result = result.split(/\/\*undefined\*\/\n/).map(function(s) { - return s.replace(/\n\s*/g, ' '); - }).join('\n'); + } : {}; + var result = escodegen.generate(node, ecopts); + if (options.sourceMap) { + // convert result into a SourceNode. + // would be much easier (and faster) if escodegen had an option to return SourceNode directly + var SourceNode = require('source-map').SourceNode; + var SourceMapConsumer = require('source-map').SourceMapConsumer; + result = SourceNode.fromStringWithSourceMap(result.code, new SourceMapConsumer(result.map.toString())); + } + + if (options.lines === "preserve") { + // turn comments into newlines + //result = result.replace(/\n\s*/g, ' ').replace(/\/\*undefined\*\//g, '\n'); + result = result.split(/\/\*undefined\*\/\n/).map(function(s) { + return s.replace(/\n\s*/g, ' '); + }).join('\n'); + }; // add helpers at beginning so that __g is initialized before any other code if (!options.noHelpers) { var s = exports.helpersSource(options, used, strict); - if (options.lines == "sourcemap") { + if (options.sourceMap) { result.prepend(s); } else { result = s + result; @@ -10253,370 +10271,370 @@ 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.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('../callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; + + + + + + + +(function (exports) { + 'use strict'; + var VERSION = 3; + var 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; }; + + fn.apply(this, args); + return function F(cb) { + if (!cb) return F; + if (done) cb.call(self, err, result); else q.push(cb); }; }; + - (function (exports) { - 'use strict'; - var VERSION = 3; + 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 future = function (fn, args, i) { - var err, result, done, q = [], self = this; + var funCb = function (callback, fn) { + if (callback == null) return future(funCb, arguments, 0); - 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; }; + if (max < 0 || max == Infinity) return fn(callback); - fn.apply(this, args); - return function F(cb) { - if (!cb) return F; - if (done) cb.call(self, err, result); else q.push(cb); }; }; - - - - - - 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; + queue.push({ fn: fn, cb: callback }); - var funCb = function (callback, fn) { - if (callback == null) return future(funCb, arguments, 0); - - 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(); }; - var fun = __rt.streamlinify(funCb, 0); + 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(); } }); } - fun.close = function () { - queue = [], closed = true; }; - return fun; }; - - var funnel = exports.funnel; - funnel.defaultSize = 4; - - function _parallel(options) { - if (typeof options === 'number') return options; - if (typeof options.parallel === 'number') return options.parallel; - return options.parallel ? -1 : 1; } - - - if (Array.prototype.forEach_ && Array.prototype.forEach_.version_ >= VERSION) return; - - - try { - Object.defineProperty({}, 'x', {}); } catch (e) { - return; } - - - var has = Object.prototype.hasOwnProperty; - - - - - - - - - - - - - - - - - - - - - + + while (active < max && queue.length > 0) _doOne(); }; + var fun = __rt.streamlinify(funCb, 0); + fun.close = function () { + queue = [], closed = true; }; + return fun; }; + + var funnel = exports.funnel; + funnel.defaultSize = 4; + + function _parallel(options) { + if (typeof options === 'number') return options; + if (typeof options.parallel === 'number') return options.parallel; + return options.parallel ? -1 : 1; } + + + if (Array.prototype.forEach_ && Array.prototype.forEach_.version_ >= VERSION) return; + + + try { + Object.defineProperty({}, 'x', {}); } catch (e) { - delete Array.prototype.forEach_; - Object.defineProperty(Array.prototype, 'forEach_', { configurable: true, writable: true, enumerable: false, value: function value__1(_, options, fn, thisObj) { - + return; } + + + var has = Object.prototype.hasOwnProperty; + + + + + + + + + + + + + + + + + + + + + + + + + + delete Array.prototype.forEach_; + Object.defineProperty(Array.prototype, 'forEach_', { configurable: true, writable: true, enumerable: false, value: function value__1(_, options, fn, thisObj) { + + + + var par, len, i, __this = this; var __frame = { name: 'value__1', line: 124 }; return __func(_, this, arguments, value__1, 0, __frame, function __$value__1() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, i, __this = this; var __frame = { name: 'value__1', line: 124 }; return __func(_, this, arguments, value__1, 0, __frame, function __$value__1() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); - - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - - return function __$value__1(__then) { if (par === 1 || len <= 1) { i = 0; - var __2 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__1() { __more = false; if (__2) { i++; } else { __2 = true; } var __1 = i < len; if (__1) { - return function __$value__1(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 7, 0, __then, true, false), __this[i], i); } else { __then(); } }(function __$value__1() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - - return __this.map_(__cb(_, __frame, 10, 0, __then, true, false), par, fn, thisObj); } }(function __$value__1() { + return function __$value__1(__then) { if (par === 1 || len <= 1) { + i = 0; var __2 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__1() { __more = false; if (__2) { i++; } else { __2 = true; } var __1 = i < len; if (__1) { + return function __$value__1(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 7, 0, __then, true, false), __this[i], i); } else { __then(); } }(function __$value__1() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - return _(null, __this); }); }); } }); - - - Array.prototype.forEach_.version_ = VERSION; - - - delete Array.prototype.map_; - Object.defineProperty(Array.prototype, 'map_', { configurable: true, writable: true, enumerable: false, value: function value__2(_, options, fn, thisObj) { + + return __this.map_(__cb(_, __frame, 10, 0, __then, true, false), par, fn, thisObj); } }(function __$value__1() { + + return _(null, __this); }); }); } }); + + + Array.prototype.forEach_.version_ = VERSION; + + + delete Array.prototype.map_; + Object.defineProperty(Array.prototype, 'map_', { configurable: true, writable: true, enumerable: false, value: function value__2(_, options, fn, thisObj) { + + + + var par, len, result, i, fun, __this = this; var __frame = { name: 'value__2', line: 147 }; return __func(_, this, arguments, value__2, 0, __frame, function __$value__2() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, result, i, fun, __this = this; var __frame = { name: 'value__2', line: 147 }; return __func(_, this, arguments, value__2, 0, __frame, function __$value__2() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); - - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - - - return function __$value__2(__then) { if (par === 1 || len <= 1) { - result = new Array(len); i = 0; - var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < len; if (__3) { - return function __$value__2(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 9, 0, function ___(__0, __1) { result[i] = __1; __then(); }, true, false), __this[i], i); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - - result = __this.map(function (elt, i) { - return fun(false, function __1(_) { var __frame = { name: '__1', line: 161 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt, i); }); }); }); i = 0; - - - var __7 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < len; if (__6) { - return function __$value__2(__then) { if (has.call(__this, i)) { return result[i](__cb(_, __frame, 19, 0, function ___(__0, __2) { result[i] = __2; __then(); }, true, false)); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__2() { + return function __$value__2(__then) { if (par === 1 || len <= 1) { + result = new Array(len); + i = 0; var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < len; if (__3) { + return function __$value__2(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 9, 0, function ___(__0, __1) { result[i] = __1; __then(); }, true, false), __this[i], i); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + fun = funnel(par); - return _(null, result); }); }); } }); - - - - - delete Array.prototype.filter_; - Object.defineProperty(Array.prototype, 'filter_', { configurable: true, writable: true, enumerable: false, value: function value__3(_, options, fn, thisObj) { - + result = __this.map(function (elt, i) { + return fun(false, function __1(_) { var __frame = { name: '__1', line: 161 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt, i); }); }); }); + + + i = 0; var __7 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__2() { __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < len; if (__6) { + return function __$value__2(__then) { if (has.call(__this, i)) { return result[i](__cb(_, __frame, 19, 0, function ___(__0, __2) { result[i] = __2; __then(); }, true, false)); } else { __then(); } }(function __$value__2() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__2() { + + + return _(null, result); }); }); } }); + + + + + delete Array.prototype.filter_; + Object.defineProperty(Array.prototype, 'filter_', { configurable: true, writable: true, enumerable: false, value: function value__3(_, options, fn, thisObj) { + + + + var par, result, len, i, elt, __this = this; var __frame = { name: 'value__3', line: 179 }; return __func(_, this, arguments, value__3, 0, __frame, function __$value__3() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + thisObj = thisObj !== undefined ? thisObj : __this; result = []; + len = __this.length; - var par, result, len, i, elt, __this = this; var __frame = { name: 'value__3', line: 179 }; return __func(_, this, arguments, value__3, 0, __frame, function __$value__3() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + return function __$value__3(__then) { if (par === 1 || len <= 1) { + i = 0; var __5 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__3() { __more = false; if (__5) { i++; } else { __5 = true; } var __4 = i < len; if (__4) { + return function __$value__3(__then) { if (has.call(__this, i)) { elt = __this[i]; + + return fn.call(thisObj, __cb(_, __frame, 10, 0, function ___(__0, __3) { var __2 = __3; return function __$value__3(__then) { if (__2) { result.push(elt); __then(); } else { __then(); } }(__then); }, true, false), elt); } else { __then(); } }(function __$value__3() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + + + + return __this.map_(__cb(_, __frame, 14, 0, __then, true, false), par, function __1(_, elt) { var __frame = { name: '__1', line: 193 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$__1(__then) { if (__1) { result.push(elt); __then(); } else { __then(); } }(_); }, true, false), elt); }); }, thisObj); } }(function __$value__3() { - thisObj = thisObj !== undefined ? thisObj : __this; result = []; - len = __this.length; - return function __$value__3(__then) { if (par === 1 || len <= 1) { i = 0; - var __5 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__3() { __more = false; if (__5) { i++; } else { __5 = true; } var __4 = i < len; if (__4) { - return function __$value__3(__then) { if (has.call(__this, i)) { elt = __this[i]; - - return fn.call(thisObj, __cb(_, __frame, 10, 0, function ___(__0, __3) { var __2 = __3; return function __$value__3(__then) { if (__2) { result.push(elt); __then(); } else { __then(); } }(__then); }, true, false), elt); } else { __then(); } }(function __$value__3() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - + return _(null, result); }); }); } }); + + + + + delete Array.prototype.every_; + Object.defineProperty(Array.prototype, 'every_', { configurable: true, writable: true, enumerable: false, value: function value__4(_, options, fn, thisObj) { + + + + var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__4', line: 207 }; return __func(_, this, arguments, value__4, 0, __frame, function __$value__4() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + + return function __$value__4(__then) { if (par === 1 || len <= 1) { + i = 0; var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { + + return function __$value__4(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 8, 0, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true, false), __this[i]); }(__cb(_, __frame, 8, 0, function ___(__0, __4) { var __3 = __4; return function __$value__4(__then) { if (__3) { return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + + fun = funnel(par); + futures = __this.map(function (elt) { - return __this.map_(__cb(_, __frame, 14, 0, __then, true, false), par, function __1(_, elt) { var __frame = { name: '__1', line: 193 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2; return function __$__1(__then) { if (__1) { result.push(elt); __then(); } else { __then(); } }(_); }, true, false), elt); }); }, thisObj); } }(function __$value__3() { + return fun(false, function __1(_) { var __frame = { name: '__1', line: 220 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); - return _(null, result); }); }); } }); - - - - - delete Array.prototype.every_; - Object.defineProperty(Array.prototype, 'every_', { configurable: true, writable: true, enumerable: false, value: function value__4(_, options, fn, thisObj) { - - - - var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__4', line: 207 }; return __func(_, this, arguments, value__4, 0, __frame, function __$value__4() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + i = 0; var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { + return function __$value__4(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 18, 0, function ___(__0, __4) { var __3 = !__4; return _(null, __3); }, true, false)); }(__cb(_, __frame, 18, 0, function ___(__0, __6) { var __5 = __6; return function __$value__4(__then) { if (__5) { + fun.close(); + return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__4() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - return function __$value__4(__then) { if (par === 1 || len <= 1) { i = 0; - var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { - - return function __$value__4(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 8, 0, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true, false), __this[i]); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$value__4(__then) { if (__3) { return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - futures = __this.map(function (elt) { - - return fun(false, function __1(_) { var __frame = { name: '__1', line: 220 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); i = 0; - - - var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__4() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { - return function __$value__4(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 18, 0, function ___(__0, __4) { var __3 = !__4; return _(null, __3); }, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { var __5 = __6; return function __$value__4(__then) { if (__5) { - fun.close(); - return _(null, false); } else { __then(); } }(function __$value__4() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__4() { + + return _(null, true); }); }); } }); + + + + + delete Array.prototype.some_; + Object.defineProperty(Array.prototype, 'some_', { configurable: true, writable: true, enumerable: false, value: function value__5(_, options, fn, thisObj) { + + + + var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__5', line: 241 }; return __func(_, this, arguments, value__5, 0, __frame, function __$value__5() { + if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + + return function __$value__5(__then) { if (par === 1 || len <= 1) { + i = 0; var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { + return function __$value__5(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 7, 0, _, true, false), __this[i]); }(__cb(_, __frame, 7, 0, function ___(__0, __4) { var __3 = __4; return function __$value__5(__then) { if (__3) { return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { + fun = funnel(par); + futures = __this.map(function (elt) { + + return fun(false, function __1(_) { var __frame = { name: '__1', line: 253 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); - return _(null, true); }); }); } }); - - - - - delete Array.prototype.some_; - Object.defineProperty(Array.prototype, 'some_', { configurable: true, writable: true, enumerable: false, value: function value__5(_, options, fn, thisObj) { - + i = 0; var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { + return function __$value__5(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 17, 0, _, true, false)); }(__cb(_, __frame, 17, 0, function ___(__0, __6) { var __5 = __6; return function __$value__5(__then) { if (__5) { + fun.close(); + return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__5() { + + + + return _(null, false); }); }); } }); + + + + + delete Array.prototype.reduce_; + Object.defineProperty(Array.prototype, 'reduce_', { configurable: true, writable: true, enumerable: false, value: function value__6(_, fn, v, thisObj) { + + + + var len, i, __this = this; var __frame = { name: 'value__6', line: 274 }; return __func(_, this, arguments, value__6, 0, __frame, function __$value__6() { + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + i = 0; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__6() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < len; if (__2) { + return function __$value__6(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__6() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__6() { + + return _(null, v); }); }); } }); + + + + + delete Array.prototype.reduceRight_; + Object.defineProperty(Array.prototype, 'reduceRight_', { configurable: true, writable: true, enumerable: false, value: function value__7(_, fn, v, thisObj) { + + + + var len, i, __this = this; var __frame = { name: 'value__7', line: 290 }; return __func(_, this, arguments, value__7, 0, __frame, function __$value__7() { + thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - var par, len, i, fun, futures, __this = this; var __frame = { name: 'value__5', line: 241 }; return __func(_, this, arguments, value__5, 0, __frame, function __$value__5() { - if (typeof options === 'function') { thisObj = fn, fn = options, options = 1; } par = _parallel(options); + i = len - 1; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__7() { __more = false; if (__3) { i--; } else { __3 = true; } var __2 = i >= 0; if (__2) { + return function __$value__7(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__7() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__7() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; + return _(null, v); }); }); } }); + + + + + + + delete Array.prototype.sort_; + Object.defineProperty(Array.prototype, 'sort_', { configurable: true, writable: true, enumerable: false, value: function value__8(_, compare, beg, end) { + + + + var array, __this = this; + + + + + function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: '_qsort', line: 313 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() { + if (beg >= end) { return _(null); } - return function __$value__5(__then) { if (par === 1 || len <= 1) { i = 0; - var __8 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__8) { i++; } else { __8 = true; } var __7 = i < len; if (__7) { - return function __$value__5(_) { var __1 = has.call(__this, i); if (!__1) { return _(null, __1); } return fn.call(thisObj, __cb(_, __frame, 7, 0, _, true, false), __this[i]); }(__cb(_, __frame, 0, 0, function ___(__0, __4) { var __3 = __4; return function __$value__5(__then) { if (__3) { return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } else { - - fun = funnel(par); - futures = __this.map(function (elt) { - - return fun(false, function __1(_) { var __frame = { name: '__1', line: 253 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return fn.call(thisObj, __cb(_, __frame, 1, 0, _, true, false), elt); }); }); }); i = 0; - - - var __11 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__5() { __more = false; if (__11) { i++; } else { __11 = true; } var __10 = i < len; if (__10) { - return function __$value__5(_) { var __2 = has.call(__this, i); if (!__2) { return _(null, __2); } return futures[i](__cb(_, __frame, 17, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __6) { var __5 = __6; return function __$value__5(__then) { if (__5) { - fun.close(); - return _(null, true); } else { __then(); } }(function __$value__5() { while (__more) { __loop(); } __more = true; }); }, true, false)); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(__then); } }(function __$value__5() { - - + return function __$_qsort(__then) { if (end == beg + 1) { + return compare(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 > 0; return function __$_qsort(__then) { if (__3) { tmp = array[beg]; + + array[beg] = array[end]; + array[end] = tmp; __then(); } else { __then(); } }(function __$_qsort() { + + return _(null); }); }, true, false), array[beg], array[end]); } else { __then(); } }(function __$_qsort() { mid = Math.floor((beg + end) / 2); - return _(null, false); }); }); } }); - - - - - delete Array.prototype.reduce_; - Object.defineProperty(Array.prototype, 'reduce_', { configurable: true, writable: true, enumerable: false, value: function value__6(_, fn, v, thisObj) { - - - - var len, i, __this = this; var __frame = { name: 'value__6', line: 274 }; return __func(_, this, arguments, value__6, 0, __frame, function __$value__6() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - i = 0; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__6() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < len; if (__2) { - return function __$value__6(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__6() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__6() { - return _(null, v); }); }); } }); - - - - - delete Array.prototype.reduceRight_; - Object.defineProperty(Array.prototype, 'reduceRight_', { configurable: true, writable: true, enumerable: false, value: function value__7(_, fn, v, thisObj) { - - - - var len, i, __this = this; var __frame = { name: 'value__7', line: 290 }; return __func(_, this, arguments, value__7, 0, __frame, function __$value__7() { - thisObj = thisObj !== undefined ? thisObj : __this; len = __this.length; - i = len - 1; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$value__7() { __more = false; if (__3) { i--; } else { __3 = true; } var __2 = i >= 0; if (__2) { - return function __$value__7(__then) { if (has.call(__this, i)) { return fn.call(thisObj, __cb(_, __frame, 4, 0, function ___(__0, __1) { v = __1; __then(); }, true, false), v, __this[i], i, __this); } else { __then(); } }(function __$value__7() { while (__more) { __loop(); } __more = true; }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$value__7() { + o = array[mid]; + nbeg = beg; + nend = end; - return _(null, v); }); }); } }); - - - - - - - delete Array.prototype.sort_; - Object.defineProperty(Array.prototype, 'sort_', { configurable: true, writable: true, enumerable: false, value: function value__8(_, compare, beg, end) { - - - - var array, __this = this; - - - - - function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: '_qsort', line: 313 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() { - if (beg >= end) { return _(null); } - return function __$_qsort(__then) { if (end == beg + 1) { - return compare(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 > 0; return function __$_qsort(__then) { if (__3) { tmp = array[beg]; + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; var __6 = nbeg <= nend; if (__6) { + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { return function __$_qsort(_) { var __1 = nbeg < end; if (!__1) { return _(null, __1); } return compare(__cb(_, __frame, 18, 0, function ___(__0, __3) { var __2 = __3 < 0; return _(null, __2); }, true, false), array[nbeg], o); }(__cb(_, __frame, 18, 0, _, true, false)); }(__cb(_, __frame, 18, 0, function ___(__0, __7) { if (__7) { nbeg++; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { return function __$_qsort(_) { var __2 = beg < nend; if (!__2) { return _(null, __2); } return compare(__cb(_, __frame, 19, 0, function ___(__0, __4) { var __3 = __4 < 0; return _(null, __3); }, true, false), o, array[nend]); }(__cb(_, __frame, 19, 0, _, true, false)); }(__cb(_, __frame, 19, 0, function ___(__0, __9) { if (__9) { nend--; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - array[beg] = array[end]; - array[end] = tmp; __then(); } else { __then(); } }(function __$_qsort() { - - return _(null); }); }, true, false), array[beg], array[end]); } else { __then(); } }(function __$_qsort() { mid = Math.floor((beg + end) / 2); + if (nbeg <= nend) { tmp = array[nbeg]; + + array[nbeg] = array[nend]; + array[nend] = tmp; + nbeg++; + nend--; } while (__more) { __loop(); } __more = true; }); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - o = array[mid]; - nbeg = beg; - nend = end; - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; var __6 = nbeg <= nend; - - if (__6) { return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { - return function __$_qsort(_) { var __1 = nbeg < end; if (!__1) { return _(null, __1); } return compare(__cb(_, __frame, 18, 0, function ___(__0, __3) { var __2 = __3 < 0; return _(null, __2); }, true, false), array[nbeg], o); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __7) { if (__7) { nbeg++; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return function __$_qsort(_) { - return function __$_qsort(_) { var __2 = beg < nend; if (!__2) { return _(null, __2); } return compare(__cb(_, __frame, 19, 0, function ___(__0, __4) { var __3 = __4 < 0; return _(null, __3); }, true, false), o, array[nend]); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __9) { if (__9) { nend--; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - - if (nbeg <= nend) { tmp = array[nbeg]; - - array[nbeg] = array[nend]; - array[nend] = tmp; - nbeg++; - nend--; } while (__more) { __loop(); } __more = true; }); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$_qsort() { - - - - return function __$_qsort(__then) { if (nbeg < end) { return _qsort(__cb(_, __frame, 30, 0, __then, true, false), nbeg, end); } else { __then(); } }(function __$_qsort() { - return function __$_qsort(__then) { if (beg < nend) { return _qsort(__cb(_, __frame, 31, 0, __then, true, false), beg, nend); } else { __then(); } }(_); }); }); }); }); } var __frame = { name: 'value__8', line: 308 }; return __func(_, this, arguments, value__8, 0, __frame, function __$value__8() { array = __this; beg = beg || 0; end = end == null ? array.length - 1 : end; - - return _qsort(__cb(_, __frame, 38, 0, function __$value__8() { - return _(null, array); }, true, false), beg, end); }); } }); - - - - - - - - - - - - delete Function.prototype.apply_; - Object.defineProperty(Function.prototype, 'apply_', { configurable: true, writable: true, enumerable: false, value: function (callback, thisObj, args, index) { - - - + + return function __$_qsort(__then) { if (nbeg < end) { return _qsort(__cb(_, __frame, 30, 0, __then, true, false), nbeg, end); } else { __then(); } }(function __$_qsort() { + return function __$_qsort(__then) { if (beg < nend) { return _qsort(__cb(_, __frame, 31, 0, __then, true, false), beg, nend); } else { __then(); } }(_); }); }); }); }); } var __frame = { name: 'value__8', line: 308 }; return __func(_, this, arguments, value__8, 0, __frame, function __$value__8() { array = __this; beg = beg || 0; end = end == null ? array.length - 1 : end; - args = Array.prototype.slice.call(args, 0); - args.splice(index != null && index >= 0 ? index : args.length, 0, callback); - return this.apply(thisObj, args); } }); }(typeof exports !== 'undefined' ? exports : Streamline.builtins = Streamline.builtins || {})); + return _qsort(__cb(_, __frame, 38, 0, function __$value__8() { + return _(null, array); }, true, false), beg, end); }); } }); + + + + + + + + + + + + delete Function.prototype.apply_; + Object.defineProperty(Function.prototype, 'apply_', { configurable: true, writable: true, enumerable: false, value: function (callback, thisObj, args, index) { + + + + + args = Array.prototype.slice.call(args, 0); + args.splice(index != null && index >= 0 ? index : args.length, 0, callback); + return this.apply(thisObj, args); } }); }(typeof exports !== 'undefined' ? exports : Streamline.builtins = Streamline.builtins || {})); diff --git a/lib/generators/runtime-all.js b/lib/generators/runtime-all.js index c4536ac0..869b6487 100644 --- a/lib/generators/runtime-all.js +++ b/lib/generators/runtime-all.js @@ -17,554 +17,7 @@ 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 /// diff --git a/lib/generators/transform-all.js b/lib/generators/transform-all.js index 0d4d901f..f688639f 100644 --- a/lib/generators/transform-all.js +++ b/lib/generators/transform-all.js @@ -8739,554 +8739,7 @@ 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 /// diff --git a/lib/streams/client/streams.js b/lib/streams/client/streams.js index 656f70a1..48ea71a0 100644 --- a/lib/streams/client/streams.js +++ b/lib/streams/client/streams.js @@ -1,142 +1,142 @@ -/*** 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; - - - - - - - - - - - - - function DataBuffer(options) { - var _chunks = []; - - this.read = function read__1(_, len) { var chunks, total, chunk; var __frame = { name: 'read__1', line: 17 }; return __func(_, this, arguments, read__1, 0, __frame, function __$read__1() { - if (len < 0) { len = Infinity; } - if (len == 0) { return _(null, ''); } chunks = []; - total = 0; +/*** 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; + + + + + + + + + + + + +function DataBuffer(options) { + var _chunks = []; + + this.read = function read__1(_, len) { var chunks, total, chunk; var __frame = { name: 'read__1', line: 17 }; return __func(_, this, arguments, read__1, 0, __frame, function __$read__1() { + if (len < 0) { len = Infinity; } + if (len == 0) { return _(null, ''); } chunks = []; + total = 0; + + while (total < len) { chunk = _chunks.splice(0, 1)[0]; - while (total < len) { chunk = _chunks.splice(0, 1)[0]; + if (!chunk) { return _(null, chunks.length == 0 ? null : chunks.join('')); } + if (total + chunk.length <= len) { + chunks.push(chunk); + total += chunk.length; } else { - if (!chunk) { return _(null, chunks.length == 0 ? null : chunks.join('')); } - if (total + chunk.length <= len) { - chunks.push(chunk); - total += chunk.length; } else { - - chunks.push(chunk.substring(0, len - total)); - _chunks.splice(0, 0, chunk.substring(len - total)); - total = len; } } + chunks.push(chunk.substring(0, len - total)); + _chunks.splice(0, 0, chunk.substring(len - total)); + total = len; } } + + + return _(null, chunks.join('')); }); }; + + + + + this.readAll = function readAll__2(_) { var __this = this; var __frame = { name: 'readAll__2', line: 39 }; return __func(_, this, arguments, readAll__2, 0, __frame, function __$readAll__2() { + return __this.read(__cb(_, __frame, 1, 0, _, true, false), -1); }); }; + + + + + this.unread = function (chunk) { + _chunks.splice(0, 0, chunk); + return this; }; + + + this.write = function write__3(_, data, enc) { var __this = this; var __frame = { name: 'write__3', line: 50 }; return __func(_, this, arguments, write__3, 0, __frame, function __$write__3() { + _chunks.push(data); + return _(null, __this); }); }; + + + this.end = function (data, enc) { + if (data) _chunks.push(data); + return this; }; + + + this.contents = function () { + return _chunks.join(''); }; } + + + +function HttpError(statusCode, message) { + this.statusCode = statusCode; + this.message = message; + this.stack = new Error().stack; } + + +function _fixHttpClientOptions(options) { + if (!options) throw new Error('request error: no options'); + if (typeof options === 'string') options = { url: options }; + + + return options; } + + + + + + + + + + + + + + + + + + + + + +function HttpClientRequest(options) { + options = _fixHttpClientOptions(options); + DataBuffer.call(this, options); + var _xhr; + this.response = function (callback) { + if (!callback) return __future.call(this, this.response, arguments, 0); + $.ajax({ url: options.url, headers: options.headers, type: options.method, data: this.contents(), dataType: 'text', beforeSend: function (xhr) { - return _(null, chunks.join('')); }); }; - - - - - this.readAll = function readAll__2(_) { var __this = this; var __frame = { name: 'readAll__2', line: 39 }; return __func(_, this, arguments, readAll__2, 0, __frame, function __$readAll__2() { - return __this.read(__cb(_, __frame, 1, 0, _, true, false), -1); }); }; - - - - - this.unread = function (chunk) { - _chunks.splice(0, 0, chunk); - return this; }; - - - this.write = function write__3(_, data, enc) { var __this = this; var __frame = { name: 'write__3', line: 50 }; return __func(_, this, arguments, write__3, 0, __frame, function __$write__3() { - _chunks.push(data); - return _(null, __this); }); }; - - - this.end = function (data, enc) { - if (data) _chunks.push(data); - return this; }; - - - this.contents = function () { - return _chunks.join(''); }; } - - - - function HttpError(statusCode, message) { - this.statusCode = statusCode; - this.message = message; - this.stack = new Error().stack; } - - - function _fixHttpClientOptions(options) { - if (!options) throw new Error('request error: no options'); - if (typeof options === 'string') options = { url: options }; - - - return options; } - - - - - - - - - - - - - - - - - - - - - - function HttpClientRequest(options) { - options = _fixHttpClientOptions(options); - DataBuffer.call(this, options); - var _xhr; - this.response = function (callback) { - if (!callback) return __future.call(this, this.response, arguments, 0); - $.ajax({ url: options.url, headers: options.headers, type: options.method, data: this.contents(), dataType: 'text', beforeSend: function (xhr) { - - - - - - - - _xhr = xhr; }, success: function (data, statusText, xhr) { - - - callback(null, new HttpClientResponse(data, xhr)); }, error: function (xhr, statusText, message) { - - - if (statusText == 'error') callback(new HttpError(xhr.status, statusText + ': ' + message)); else callback(new HttpError(400, statusText + ': ' + message)); } }); }; - - - - - this.abort = function () { - _xhr && _xhr.abort(); - _xhr = null; }; } - - - - function HttpClientResponse(data, xhr) { - DataBuffer.call(this); - this.end(data); - this.statusCode = xhr.status; - this.headers = {}; - var self = this; - xhr.getAllResponseHeaders().replace(/\r\n/g, '\n').split('\n').forEach(function (header) { - var pair = header.split(':'); - self.headers[pair[0].toLowerCase()] = pair[1] && pair[1].trim(); }); } - - - - exports.httpRequest = function (options) { - return new HttpClientRequest(options); }; \ No newline at end of file + + + + + + _xhr = xhr; }, success: function (data, statusText, xhr) { + + + callback(null, new HttpClientResponse(data, xhr)); }, error: function (xhr, statusText, message) { + + + if (statusText == 'error') callback(new HttpError(xhr.status, statusText + ': ' + message)); else callback(new HttpError(400, statusText + ': ' + message)); } }); }; + + + + + this.abort = function () { + _xhr && _xhr.abort(); + _xhr = null; }; } + + + +function HttpClientResponse(data, xhr) { + DataBuffer.call(this); + this.end(data); + this.statusCode = xhr.status; + this.headers = {}; + var self = this; + xhr.getAllResponseHeaders().replace(/\r\n/g, '\n').split('\n').forEach(function (header) { + var pair = header.split(':'); + self.headers[pair[0].toLowerCase()] = pair[1] && pair[1].trim(); }); } + + + +exports.httpRequest = function (options) { + return new HttpClientRequest(options); }; \ No newline at end of file diff --git a/test/common/callbacks/eval-test.js b/test/common/callbacks/eval-test.js index 2fc0d7ee..11849206 100644 --- a/test/common/callbacks/eval-test.js +++ b/test/common/callbacks/eval-test.js @@ -1,910 +1,910 @@ -/*** 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); - - function evalTest(f, val) { - f(function (err, result) { - var str = err ? 'ERR: ' + err : result; - strictEqual(str, val, val); - start(); }); } - - - - function delay(_, val) { var __frame = { name: 'delay', line: 11 }; return __func(_, this, arguments, delay, 0, __frame, function __$delay() { - return setTimeout(__cb(_, __frame, 1, 0, function __$delay() { - return _(null, val); }, true, false), 0); }); } - - - function delayFail(_, err) { var __frame = { name: 'delayFail', line: 16 }; return __func(_, this, arguments, delayFail, 0, __frame, function __$delayFail() { - return setTimeout(__cb(_, __frame, 1, 0, function __$delayFail() { - return _(err); }, true, false), 0); }); } - - - function throwError(message) { - throw new Error(message); } - - - asyncTest('eval return', 1, function __1(_) { var __frame = { name: '__1', line: 25 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - evalTest(function f(_) { var __frame = { name: 'f', line: 26 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return delay(__cb(_, __frame, 1, 0, _, true, false), 5); }); }, 5); - _(); }); }); - - asyncTest('eval if true', 1, function __2(_) { var __frame = { name: '__2', line: 30 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { - evalTest(function f(_) { var __frame = { name: 'f', line: 31 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function __$f(__then) { if (true) { return delay(__cb(_, __frame, 1, 0, _, true, false), 3); } else { __then(); } }(function __$f() { - return _(null, 4); }); }); }, 3); - _(); }); }); - - asyncTest('eval if false', 1, function __3(_) { var __frame = { name: '__3', line: 36 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { - evalTest(function f(_) { var __frame = { name: 'f', line: 37 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function __$f(__then) { if (false) { return delay(__cb(_, __frame, 1, 0, _, true, false), 3); } else { __then(); } }(function __$f() { - return _(null, 4); }); }); }, 4); - _(); }); }); - - asyncTest('eval while', 1, function __4(_) { var __frame = { name: '__4', line: 42 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { - evalTest(function f(_) { var i, result; var __frame = { name: 'f', line: 43 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 1; - result = 1; - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __2 = i < 5; - if (__2) { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { result = __1; - i++; while (__more) { __loop(); } __more = true; }, true, false), i * result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { - - return _(null, result); }); }); }, 24); - _(); }); }); - - asyncTest('eval for', 1, function __5(_) { var __frame = { name: '__5', line: 53 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { - evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 54 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; - i = 1; - var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < 5; if (__3) { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), result); }, true, false), i); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { +/*** 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); + +function evalTest(f, val) { + f(function (err, result) { + var str = err ? 'ERR: ' + err : result; + strictEqual(str, val, val); + start(); }); } + + + +function delay(_, val) { var __frame = { name: 'delay', line: 11 }; return __func(_, this, arguments, delay, 0, __frame, function __$delay() { + return setTimeout(__cb(_, __frame, 1, 0, function __$delay() { + return _(null, val); }, true, false), 0); }); } + + +function delayFail(_, err) { var __frame = { name: 'delayFail', line: 16 }; return __func(_, this, arguments, delayFail, 0, __frame, function __$delayFail() { + return setTimeout(__cb(_, __frame, 1, 0, function __$delayFail() { + return _(err); }, true, false), 0); }); } + + +function throwError(message) { + throw new Error(message); } + + +asyncTest('eval return', 1, function __1(_) { var __frame = { name: '__1', line: 25 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + evalTest(function f(_) { var __frame = { name: 'f', line: 26 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return delay(__cb(_, __frame, 1, 0, _, true, false), 5); }); }, 5); + _(); }); }); + +asyncTest('eval if true', 1, function __2(_) { var __frame = { name: '__2', line: 30 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { + evalTest(function f(_) { var __frame = { name: 'f', line: 31 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function __$f(__then) { if (true) { return delay(__cb(_, __frame, 1, 0, _, true, false), 3); } else { __then(); } }(function __$f() { + return _(null, 4); }); }); }, 3); + _(); }); }); + +asyncTest('eval if false', 1, function __3(_) { var __frame = { name: '__3', line: 36 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { + evalTest(function f(_) { var __frame = { name: 'f', line: 37 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function __$f(__then) { if (false) { return delay(__cb(_, __frame, 1, 0, _, true, false), 3); } else { __then(); } }(function __$f() { + return _(null, 4); }); }); }, 4); + _(); }); }); + +asyncTest('eval while', 1, function __4(_) { var __frame = { name: '__4', line: 42 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { + evalTest(function f(_) { var i, result; var __frame = { name: 'f', line: 43 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 1; + result = 1; + + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __2 = i < 5; if (__2) { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { result = __1; + i++; while (__more) { __loop(); } __more = true; }, true, false), i * result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 24); + _(); }); }); + +asyncTest('eval for', 1, function __5(_) { var __frame = { name: '__5', line: 53 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { + evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 54 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; + + i = 1; var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < 5; if (__3) { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), result); }, true, false), i); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 24); + _(); }); }); + +asyncTest('eval for in', 1, function __6(_) { var __frame = { name: '__6', line: 62 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { + evalTest(function f(_) { var foo, result, k; var __frame = { name: 'f', line: 63 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { foo = { a: 1, b: 2, c: 3, d: 5 }; + + + + + result = 1; + + + var __1 = __forIn(foo); var __2 = 0; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __6 = __2 < __1.length; if (__6) { k = __1[__2++]; + return delay(__cb(_, __frame, 9, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 9, 0, function ___(__0, __4) { return delay(__cb(_, __frame, 9, 0, function ___(__0, __5) { result = __4 * __5; while (__more) { __loop(); } __more = true; }, true, false), result); }, true, false), foo[__3]); }, true, false), k); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 30); + _(); }); }); + +asyncTest('fully async for in', 1, function __7(_) { var __frame = { name: '__7', line: 77 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { + evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 78 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; + + return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { i = __1; var __6 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; return function __$f(__then) { if (__6) { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { i = __1 + 1; _(); }, true, false), i); }(__cb(_, __frame, 2, 0, __then, true, false)); } else { __6 = true; __then(); } }(function __$f() { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = i < __2; return _(null, __1); }, true, false), 5); }(__cb(_, __frame, 2, 0, function ___(__0, __5) { if (__5) { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { return delay(__cb(_, __frame, 3, 0, function ___(__0, __3) { result = __2 * __3; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }, true, false)); }); }); do { __loop(); } while (__more); __more = true; }(function __$f() { - return _(null, result); }); }); }, 24); - _(); }); }); - - asyncTest('eval for in', 1, function __6(_) { var __frame = { name: '__6', line: 62 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { - evalTest(function f(_) { var foo, result, k; var __frame = { name: 'f', line: 63 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { foo = { a: 1, b: 2, c: 3, d: 5 }; - - - - - result = 1; - - var __1 = __forIn(foo); - var __2 = 0; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __6 = __2 < __1.length; if (__6) { k = __1[__2++]; - return delay(__cb(_, __frame, 9, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 9, 0, function ___(__0, __4) { return delay(__cb(_, __frame, 9, 0, function ___(__0, __5) { result = __4 * __5; while (__more) { __loop(); } __more = true; }, true, false), result); }, true, false), foo[__3]); }, true, false), k); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { - - return _(null, result); }); }); }, 30); - _(); }); }); - - asyncTest('fully async for in', 1, function __7(_) { var __frame = { name: '__7', line: 77 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { - evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 78 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; - - return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { i = __1; var __6 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; return function __$f(__then) { if (__6) { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { i = __1 + 1; _(); }, true, false), i); }(__cb(_, __frame, 0, 0, __then, true, false)); } else { __6 = true; __then(); } }(function __$f() { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = i < __2; return _(null, __1); }, true, false), 5); }(__cb(_, __frame, 0, 0, function ___(__0, __5) { if (__5) { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { return delay(__cb(_, __frame, 3, 0, function ___(__0, __3) { result = __2 * __3; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }, true, false)); }); }); do { __loop(); } while (__more); __more = true; }(function __$f() { - - return _(null, result); }); }, true, false), 2); }); }, 24); - _(); }); }); - - asyncTest('break in loop', 1, function __8(_) { var __frame = { name: '__8', line: 86 }; return __func(_, this, arguments, __8, 0, __frame, function __$__8() { - evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 87 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; - i = 1; - var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < 10; if (__3) { - if (i == 5) { return __break(); } - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + return _(null, result); }); }, true, false), 2); }); }, 24); + _(); }); }); + +asyncTest('break in loop', 1, function __8(_) { var __frame = { name: '__8', line: 86 }; return __func(_, this, arguments, __8, 0, __frame, function __$__8() { + evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 87 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; + + i = 1; var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < 10; if (__3) { + if (i == 5) { return __break(); } + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 24); + _(); }); }); + +asyncTest('continue', 1, function __9(_) { var __frame = { name: '__9', line: 96 }; return __func(_, this, arguments, __9, 0, __frame, function __$__9() { + evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 97 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; + + i = 1; var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < 10; if (__3) { + if (i >= 5) { while (__more) { __loop(); } __more = true; return; } + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 24); + _(); }); }); + +asyncTest('break in while', 1, function __10(_) { var __frame = { name: '__10', line: 106 }; return __func(_, this, arguments, __10, 0, __frame, function __$__10() { + evalTest(function f(_) { var i, result; var __frame = { name: 'f', line: 107 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 1; + result = 1; + + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __3 = i < 10; if (__3) { + if (i == 5) { return __break(); } + return delay(__cb(_, __frame, 5, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 5, 0, function ___(__0, __2) { result = __1 * __2; + i++; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 24); + _(); }); }); + +asyncTest('continue in while', 1, function __11(_) { var __frame = { name: '__11', line: 118 }; return __func(_, this, arguments, __11, 0, __frame, function __$__11() { + evalTest(function f(_) { var i, result; var __frame = { name: 'f', line: 119 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 1; + result = 1; + + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __3 = i < 10; if (__3) { + i++; + if (i >= 5) { while (__more) { __loop(); } __more = true; return; } + return delay(__cb(_, __frame, 6, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, 24); + _(); }); }); + +asyncTest('for (;;)', 1, function __12(_) { var __frame = { name: '__12', line: 130 }; return __func(_, this, arguments, __12, 0, __frame, function __$__12() { + evalTest(function f(_) { var i; var __frame = { name: 'f', line: 131 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 0; + + return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __3 = 1; if (__3) { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { var __1 = __2 === 10; return function __$f(__then) { if (__1) { return _(null, i); } else { __then(); } }(function __$f() { while (__more) { __loop(); } __more = true; }); }, true, false), ++i); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(_); }); }, 10); + + _(); }); }); + +asyncTest('eval lazy', 1, function __13(_) { var __frame = { name: '__13', line: 138 }; return __func(_, this, arguments, __13, 0, __frame, function __$__13() { + evalTest(function f(_) { var result; var __frame = { name: 'f', line: 139 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; + + return function __$f(_) { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __4) { var __2 = __4; if (!__2) { return _(null, __2); } return _(null, true); }, true, false), __3 < 5); }, true, false), result + 8); }(__cb(_, __frame, 2, 0, function ___(__0, __3) { var __1 = __3; if (__1) { return _(null, 2); } return _(null, 4); }, true, false)); }(__cb(_, __frame, 2, 0, _, true, false)); }); }, 4); + _(); }); }); + +asyncTest('eval lazy full async', 1, function __14(_) { var __frame = { name: '__14', line: 144 }; return __func(_, this, arguments, __14, 0, __frame, function __$__14() { + evalTest(function f(_) { var result; var __frame = { name: 'f', line: 145 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; + + return function __$f(_) { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __4) { var __2 = __4; if (!__2) { return _(null, __2); } return _(null, true); }, true, false), __3 < 5); }, true, false), result + 8); }(__cb(_, __frame, 2, 0, function ___(__0, __3) { var __1 = __3; return function __$f(__then) { if (__1) { return delay(__cb(_, __frame, 2, 0, _, true, false), 2); } else { __then(); } }(function __$f() { return delay(__cb(_, __frame, 2, 0, _, true, false), 4); }); }, true, false)); }(__cb(_, __frame, 2, 0, _, true, false)); }); }, 4); + _(); }); }); + +asyncTest('try catch 1', 1, function __15(_) { var __frame = { name: '__15', line: 150 }; return __func(_, this, arguments, __15, 0, __frame, function __$__15() { + evalTest(function f(_) { var __frame = { name: 'f', line: 151 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 2, 0, _, true, false), 'ok'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 4, 0, _, true, false), 'err'); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'ok'); + + _(); }); }); + +asyncTest('try catch 2', 1, function __16(_) { var __frame = { name: '__16', line: 159 }; return __func(_, this, arguments, __16, 0, __frame, function __$__16() { + evalTest(function f(_) { var __frame = { name: 'f', line: 160 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return _(__1); }, true, false), 'thrown'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 + ex; return _(null, __3); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught thrown'); + + _(); }); }); + +asyncTest('try catch 3', 1, function __17(_) { var __frame = { name: '__17', line: 168 }; return __func(_, this, arguments, __17, 0, __frame, function __$__17() { + evalTest(function f(_) { var __frame = { name: 'f', line: 169 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return _(__1); }, true, false), 'thrown'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 + ex; return _(null, __3); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught thrown'); + + _(); }); }); + +asyncTest('try catch 5', 1, function __18(_) { var __frame = { name: '__18', line: 177 }; return __func(_, this, arguments, __18, 0, __frame, function __$__18() { + evalTest(function f(_) { var __frame = { name: 'f', line: 178 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delayFail(__cb(_, __frame, 2, 0, __then, true, false), 'delay fail'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __2) { var __1 = __2 + ex; return _(null, __1); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught delay fail'); + + _(); }); }); + +asyncTest('try catch 6', 1, function __19(_) { var __frame = { name: '__19', line: 186 }; return __func(_, this, arguments, __19, 0, __frame, function __$__19() { + evalTest(function f(_) { var __frame = { name: 'f', line: 187 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + throwError('direct'); + return delay(__cb(_, __frame, 3, 0, _, true, false), 'ok'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 5, 0, function ___(__0, __4) { var __3 = __4 + ex.message; return _(null, __3); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught direct'); + + _(); }); }); + +asyncTest('try catch 7', 1, function __20(_) { var __frame = { name: '__20', line: 196 }; return __func(_, this, arguments, __20, 0, __frame, function __$__20() { + evalTest(function f(_) { var message; var __frame = { name: 'f', line: 197 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { message = __1; + throwError(message); + return delay(__cb(_, __frame, 4, 0, _, true, false), 'ok'); }, true, false), 'indirect'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 6, 0, function ___(__0, __5) { var __4 = __5 + ex.message; return _(null, __4); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught indirect'); + + _(); }); }); + +asyncTest('try finally 1', 1, function __21(_) { var __frame = { name: '__21', line: 207 }; return __func(_, this, arguments, __21, 0, __frame, function __$__21() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 208 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 5, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return _(null, result); }); }); }, 24); - _(); }); }); - - asyncTest('continue', 1, function __9(_) { var __frame = { name: '__9', line: 96 }; return __func(_, this, arguments, __9, 0, __frame, function __$__9() { - evalTest(function f(_) { var result, i; var __frame = { name: 'f', line: 97 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; - i = 1; - var __4 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; if (__4) { i++; } else { __4 = true; } var __3 = i < 10; if (__3) { - if (i >= 5) { while (__more) { __loop(); } __more = true; return; } - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + x += ' end'; + return _(null, x); }); }); }); }, 'try finally end'); + _(); }); }); + +asyncTest('try finally 2', 1, function __22(_) { var __frame = { name: '__22', line: 219 }; return __func(_, this, arguments, __22, 0, __frame, function __$__22() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 220 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; + return _(null, x); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return _(null, result); }); }); }, 24); - _(); }); }); - - asyncTest('break in while', 1, function __10(_) { var __frame = { name: '__10', line: 106 }; return __func(_, this, arguments, __10, 0, __frame, function __$__10() { - evalTest(function f(_) { var i, result; var __frame = { name: 'f', line: 107 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 1; - result = 1; - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __3 = i < 10; - if (__3) { - if (i == 5) { return __break(); } - return delay(__cb(_, __frame, 5, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 5, 0, function ___(__0, __2) { result = __1 * __2; - i++; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + x += ' end'; + return _(null, x); }); }); }); }, 'try'); + _(); }); }); + +asyncTest('try finally 3', 1, function __23(_) { var __frame = { name: '__23', line: 232 }; return __func(_, this, arguments, __23, 0, __frame, function __$__23() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 233 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; + return _('bad try'); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return _(null, result); }); }); }, 24); - _(); }); }); - - asyncTest('continue in while', 1, function __11(_) { var __frame = { name: '__11', line: 118 }; return __func(_, this, arguments, __11, 0, __frame, function __$__11() { - evalTest(function f(_) { var i, result; var __frame = { name: 'f', line: 119 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 1; - result = 1; - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __3 = i < 10; - if (__3) { - i++; - if (i >= 5) { while (__more) { __loop(); } __more = true; return; } - return delay(__cb(_, __frame, 6, 0, function ___(__0, __1) { return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { result = __1 * __2; while (__more) { __loop(); } __more = true; }, true, false), i); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + x += ' end'; + return _(null, x); }); }); }); }, 'ERR: bad try'); + _(); }); }); + +asyncTest('try finally 4', 1, function __24(_) { var __frame = { name: '__24', line: 245 }; return __func(_, this, arguments, __24, 0, __frame, function __$__24() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 246 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; + throwError('except'); _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return _(null, result); }); }); }, 24); - _(); }); }); - - asyncTest('for (;;)', 1, function __12(_) { var __frame = { name: '__12', line: 130 }; return __func(_, this, arguments, __12, 0, __frame, function __$__12() { - evalTest(function f(_) { var i; var __frame = { name: 'f', line: 131 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { i = 0; - - return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$f() { __more = false; var __3 = 1; if (__3) { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { var __1 = __2 === 10; return function __$f(__then) { if (__1) { return _(null, i); } else { __then(); } }(function __$f() { while (__more) { __loop(); } __more = true; }); }, true, false), ++i); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(_); }); }, 10); - - _(); }); }); - - asyncTest('eval lazy', 1, function __13(_) { var __frame = { name: '__13', line: 138 }; return __func(_, this, arguments, __13, 0, __frame, function __$__13() { - evalTest(function f(_) { var result; var __frame = { name: 'f', line: 139 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; - - return function __$f(_) { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __4) { var __2 = __4; if (!__2) { return _(null, __2); } return _(null, true); }, true, false), __3 < 5); }, true, false), result + 8); }(__cb(_, __frame, 0, 0, function ___(__0, __3) { var __1 = __3; if (__1) { return _(null, 2); } return _(null, 4); }, true, false)); }(__cb(_, __frame, 0, 0, _, true, false)); }); }, 4); - _(); }); }); - - asyncTest('eval lazy full async', 1, function __14(_) { var __frame = { name: '__14', line: 144 }; return __func(_, this, arguments, __14, 0, __frame, function __$__14() { - evalTest(function f(_) { var result; var __frame = { name: 'f', line: 145 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = 1; - - return function __$f(_) { return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __4) { var __2 = __4; if (!__2) { return _(null, __2); } return _(null, true); }, true, false), __3 < 5); }, true, false), result + 8); }(__cb(_, __frame, 0, 0, function ___(__0, __3) { var __1 = __3; return function __$f(__then) { if (__1) { return delay(__cb(_, __frame, 2, 0, _, true, false), 2); } else { __then(); } }(function __$f() { return delay(__cb(_, __frame, 2, 0, _, true, false), 4); }); }, true, false)); }(__cb(_, __frame, 0, 0, _, true, false)); }); }, 4); - _(); }); }); - - asyncTest('try catch 1', 1, function __15(_) { var __frame = { name: '__15', line: 150 }; return __func(_, this, arguments, __15, 0, __frame, function __$__15() { - evalTest(function f(_) { var __frame = { name: 'f', line: 151 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 2, 0, _, true, false), 'ok'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 4, 0, _, true, false), 'err'); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'ok'); - - _(); }); }); - - asyncTest('try catch 2', 1, function __16(_) { var __frame = { name: '__16', line: 159 }; return __func(_, this, arguments, __16, 0, __frame, function __$__16() { - evalTest(function f(_) { var __frame = { name: 'f', line: 160 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return _(__1); }, true, false), 'thrown'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 + ex; return _(null, __3); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught thrown'); - - _(); }); }); - - asyncTest('try catch 3', 1, function __17(_) { var __frame = { name: '__17', line: 168 }; return __func(_, this, arguments, __17, 0, __frame, function __$__17() { - evalTest(function f(_) { var __frame = { name: 'f', line: 169 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return _(__1); }, true, false), 'thrown'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __4) { var __3 = __4 + ex; return _(null, __3); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught thrown'); - - _(); }); }); - - asyncTest('try catch 5', 1, function __18(_) { var __frame = { name: '__18', line: 177 }; return __func(_, this, arguments, __18, 0, __frame, function __$__18() { - evalTest(function f(_) { var __frame = { name: 'f', line: 178 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delayFail(__cb(_, __frame, 2, 0, __then, true, false), 'delay fail'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __2) { var __1 = __2 + ex; return _(null, __1); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught delay fail'); - - _(); }); }); - - asyncTest('try catch 6', 1, function __19(_) { var __frame = { name: '__19', line: 186 }; return __func(_, this, arguments, __19, 0, __frame, function __$__19() { - evalTest(function f(_) { var __frame = { name: 'f', line: 187 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - throwError('direct'); - return delay(__cb(_, __frame, 3, 0, _, true, false), 'ok'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 5, 0, function ___(__0, __4) { var __3 = __4 + ex.message; return _(null, __3); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught direct'); - - _(); }); }); - - asyncTest('try catch 7', 1, function __20(_) { var __frame = { name: '__20', line: 196 }; return __func(_, this, arguments, __20, 0, __frame, function __$__20() { - evalTest(function f(_) { var message; var __frame = { name: 'f', line: 197 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { message = __1; - throwError(message); - return delay(__cb(_, __frame, 4, 0, _, true, false), 'ok'); }, true, false), 'indirect'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __5) { var __4 = __5 + ex.message; return _(null, __4); }, true, false), 'caught '); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'caught indirect'); - - _(); }); }); - - asyncTest('try finally 1', 1, function __21(_) { var __frame = { name: '__21', line: 207 }; return __func(_, this, arguments, __21, 0, __frame, function __$__21() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 208 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + x += ' end'; + return _(null, x); }); }); }); }, 'ERR: Error: except'); + _(); }); }); + +asyncTest('try finally 5', 1, function __25(_) { var __frame = { name: '__25', line: 258 }; return __func(_, this, arguments, __25, 0, __frame, function __$__25() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 259 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; + throwError('except'); + x += ' unreached'; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 8, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 5, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }, 'try finally end'); - _(); }); }); - - asyncTest('try finally 2', 1, function __22(_) { var __frame = { name: '__22', line: 219 }; return __func(_, this, arguments, __22, 0, __frame, function __$__22() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 220 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; - return _(null, x); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + x += ' end'; + return _(null, x); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + '/' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try finally/except'); + + _(); }); }); + +asyncTest('try catch finally 1', 1, function __26(_) { var __frame = { name: '__26', line: 276 }; return __func(_, this, arguments, __26, 0, __frame, function __$__26() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 277 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; + return _(new Error('except')); }, true, false), 'try'); }); }(function ___(ex, __result) { + + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 8, 0, function ___(__0, __2) { x += __2; + return _(ex); }, true, false), ' catch ' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(null, null, true); }); }); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 11, 0, function ___(__0, __3) { x += __3; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }, 'try'); - _(); }); }); - - asyncTest('try finally 3', 1, function __23(_) { var __frame = { name: '__23', line: 232 }; return __func(_, this, arguments, __23, 0, __frame, function __$__23() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 233 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; - return _('bad try'); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + x += ' end'; + return _(null, x); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + '/' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try catch except finally/except'); + + _(); }); }); + +asyncTest('try catch finally 2', 1, function __27(_) { var __frame = { name: '__27', line: 297 }; return __func(_, this, arguments, __27, 0, __frame, function __$__27() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 298 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; + throwError('except'); + x += ' unreached'; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + x += ' catch ' + ex.message; + return _(ex); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(null, null, true); }); }); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + x += ' finally'; __then(); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }, 'ERR: bad try'); - _(); }); }); - - asyncTest('try finally 4', 1, function __24(_) { var __frame = { name: '__24', line: 245 }; return __func(_, this, arguments, __24, 0, __frame, function __$__24() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 246 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { x += __1; - throwError('except'); _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + x += ' end'; + return _(null, x); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + '/' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try catch except finally/except'); + + _(); }); }); + +asyncTest('nested try/catch 1', 1, function __28(_) { var __frame = { name: '__28', line: 318 }; return __func(_, this, arguments, __28, 0, __frame, function __$__28() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 319 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner catch ' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }, 'ERR: Error: except'); - _(); }); }); - - asyncTest('try finally 5', 1, function __25(_) { var __frame = { name: '__25', line: 258 }; return __func(_, this, arguments, __25, 0, __frame, function __$__25() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 259 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; - throwError('except'); - x += ' unreached'; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { - - return delay(__cb(_, __frame, 8, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + '/' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try finally/except'); - - _(); }); }); - - asyncTest('try catch finally 1', 1, function __26(_) { var __frame = { name: '__26', line: 276 }; return __func(_, this, arguments, __26, 0, __frame, function __$__26() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 277 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; - return _(new Error('except')); }, true, false), 'try'); }); }(function ___(ex, __result) { - - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 8, 0, function ___(__0, __2) { x += __2; - return _(ex); }, true, false), ' catch ' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(null, null, true); }); }); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { - - return delay(__cb(_, __frame, 11, 0, function ___(__0, __3) { x += __3; __then(); }, true, false), ' finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + '/' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try catch except finally/except'); - - _(); }); }); - - asyncTest('try catch finally 2', 1, function __27(_) { var __frame = { name: '__27', line: 297 }; return __func(_, this, arguments, __27, 0, __frame, function __$__27() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 298 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; - throwError('except'); - x += ' unreached'; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - x += ' catch ' + ex.message; - return _(ex); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(null, null, true); }); }); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { - - x += ' finally'; __then(); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - x += ' end'; - return _(null, x); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + '/' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try catch except finally/except'); - - _(); }); }); - - asyncTest('nested try/catch 1', 1, function __28(_) { var __frame = { name: '__28', line: 318 }; return __func(_, this, arguments, __28, 0, __frame, function __$__28() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 319 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner catch ' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { - - throwError(' except'); __then(); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try outer catch except'); - - _(); }); }); - - asyncTest('nested try/catch 2', 1, function __29(_) { var __frame = { name: '__29', line: 333 }; return __func(_, this, arguments, __29, 0, __frame, function __$__29() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 334 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - x += ' inner catch ' + ex.message; __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { - - return _(new Error(' except')); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try outer catch except'); - - _(); }); }); - - asyncTest('nested try/catch 3', 1, function __30(_) { var __frame = { name: '__30', line: 348 }; return __func(_, this, arguments, __30, 0, __frame, function __$__30() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 349 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner catch ' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { - - return _(new Error(' except')); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try outer catch except'); - - _(); }); }); - - asyncTest('nested try/finally 1', 1, function __31(_) { var __frame = { name: '__31', line: 363 }; return __func(_, this, arguments, __31, 0, __frame, function __$__31() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 364 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { - - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - throwError(' except'); __then(); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try inner finally outer catch except'); - - _(); }); }); - - asyncTest('nested try/finally 2', 1, function __32(_) { var __frame = { name: '__32', line: 378 }; return __func(_, this, arguments, __32, 0, __frame, function __$__32() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 379 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { - - x += ' inner finally'; __then(); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - throwError(' except'); __then(); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try inner finally outer catch except'); - - _(); }); }); - - asyncTest('nested try/finally 3', 1, function __33(_) { var __frame = { name: '__33', line: 393 }; return __func(_, this, arguments, __33, 0, __frame, function __$__33() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 394 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { - - return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - - return _(new Error(' except')); }); }); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try inner finally outer catch except'); - - _(); }); }); - - asyncTest('and ok', 1, function __34(_) { var __frame = { name: '__34', line: 408 }; return __func(_, this, arguments, __34, 0, __frame, function __$__34() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 409 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = '<<'; - - return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; if (!__1) { return _(null, __1); } return delay(__cb(_, __frame, 2, 0, _, true, false), true); }, true, false), true); }(__cb(_, __frame, 0, 0, function ___(__0, __7) { var __6 = __7; return function __$f(__then) { if (__6) { x += 'T1'; __then(); } else { - x += 'F1'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __3) { var __2 = __3; if (!__2) { return _(null, __2); } return delay(__cb(_, __frame, 4, 0, _, true, false), false); }, true, false), true); }(__cb(_, __frame, 0, 0, function ___(__0, __9) { var __8 = __9; return function __$f(__then) { if (__8) { x += 'T2'; __then(); } else { - x += 'F2'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 6, 0, function ___(__0, __4) { var __3 = __4; if (!__3) { return _(null, __3); } return delay(__cb(_, __frame, 6, 0, _, true, false), true); }, true, false), false); }(__cb(_, __frame, 0, 0, function ___(__0, __11) { var __10 = __11; return function __$f(__then) { if (__10) { x += 'T3'; __then(); } else { - x += 'F3'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 8, 0, function ___(__0, __5) { var __4 = __5; if (!__4) { return _(null, __4); } return delay(__cb(_, __frame, 8, 0, _, true, false), false); }, true, false), false); }(__cb(_, __frame, 0, 0, function ___(__0, __13) { var __12 = __13; return function __$f(__then) { if (__12) { x += 'T4'; __then(); } else { - x += 'F4'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 10, 0, function ___(__0, __6) { var __5 = __6; if (!__5) { return _(null, __5); } return delayFail(__cb(_, __frame, 10, 0, _, true, false), 'bad'); }, true, false), false); }(__cb(_, __frame, 0, 0, function ___(__0, __15) { var __14 = __15; return function __$f(__then) { if (__14) { x += 'T5'; __then(); } else { - x += 'F5'; __then(); } }(function __$f() { - x += '>>'; - return _(null, x); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, '<>'); - _(); }); }); - - asyncTest('or ok', 1, function __35(_) { var __frame = { name: '__35', line: 425 }; return __func(_, this, arguments, __35, 0, __frame, function __$__35() { - evalTest(function f(_) { var x; var __frame = { name: 'f', line: 426 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = '<<'; - - return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; if (__1) { return _(null, __1); } return delay(__cb(_, __frame, 2, 0, _, true, false), true); }, true, false), true); }(__cb(_, __frame, 0, 0, function ___(__0, __7) { var __6 = __7; return function __$f(__then) { if (__6) { x += 'T1'; __then(); } else { - x += 'F1'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __3) { var __2 = __3; if (__2) { return _(null, __2); } return delay(__cb(_, __frame, 4, 0, _, true, false), false); }, true, false), true); }(__cb(_, __frame, 0, 0, function ___(__0, __9) { var __8 = __9; return function __$f(__then) { if (__8) { x += 'T2'; __then(); } else { - x += 'F2'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 6, 0, function ___(__0, __4) { var __3 = __4; if (__3) { return _(null, __3); } return delay(__cb(_, __frame, 6, 0, _, true, false), true); }, true, false), false); }(__cb(_, __frame, 0, 0, function ___(__0, __11) { var __10 = __11; return function __$f(__then) { if (__10) { x += 'T3'; __then(); } else { - x += 'F3'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 8, 0, function ___(__0, __5) { var __4 = __5; if (__4) { return _(null, __4); } return delay(__cb(_, __frame, 8, 0, _, true, false), false); }, true, false), false); }(__cb(_, __frame, 0, 0, function ___(__0, __13) { var __12 = __13; return function __$f(__then) { if (__12) { x += 'T4'; __then(); } else { - x += 'F4'; __then(); } }(function __$f() { - return function __$f(_) { return delay(__cb(_, __frame, 10, 0, function ___(__0, __6) { var __5 = __6; if (__5) { return _(null, __5); } return delayFail(__cb(_, __frame, 10, 0, _, true, false), 'bad'); }, true, false), true); }(__cb(_, __frame, 0, 0, function ___(__0, __15) { var __14 = __15; return function __$f(__then) { if (__14) { x += 'T5'; __then(); } else { - x += 'F5'; __then(); } }(function __$f() { - x += '>>'; - return _(null, x); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, '<>'); - _(); }); }); - - asyncTest('switch with default', 1, function __36(_) { var __frame = { name: '__36', line: 442 }; return __func(_, this, arguments, __36, 0, __frame, function __$__36() { - evalTest(function f(_) { - function g(_, i) { var result; var __frame = { name: 'g', line: 444 }; return __func(_, this, arguments, g, 0, __frame, function __$g() { result = 'a'; - - return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return function __$g(__break) { switch (__1) { case - 1: - return delay(__cb(_, __frame, 4, 0, function ___(__0, __3) { result = __3; - return __break(); }, true, false), 'b'); case - 2: - return delay(__cb(_, __frame, 7, 0, _, true, false), 'c'); case - 3: case - 4: - return delay(__cb(_, __frame, 10, 0, function ___(__0, __6) { result = __6; - return __break(); }, true, false), 'd'); default: + throwError(' except'); __then(); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try outer catch except'); + + _(); }); }); + +asyncTest('nested try/catch 2', 1, function __29(_) { var __frame = { name: '__29', line: 333 }; return __func(_, this, arguments, __29, 0, __frame, function __$__29() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 334 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + x += ' inner catch ' + ex.message; __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { - return delay(__cb(_, __frame, 13, 0, function ___(__0, __7) { result = __7; return __break(); }, true, false), 'e'); } }(function __$g() { - - return _(null, result); }); }, true, false), i); }); } var __frame = { name: 'f', line: 443 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - - return g(__cb(_, __frame, 19, 0, function ___(__0, __2) { return g(__cb(_, __frame, 19, 0, function ___(__0, __3) { return g(__cb(_, __frame, 19, 0, function ___(__0, __4) { return g(__cb(_, __frame, 19, 0, function ___(__0, __5) { return g(__cb(_, __frame, 19, 0, function ___(__0, __6) { return g(__cb(_, __frame, 19, 0, function ___(__0, __7) { var __1 = __2 + __3 + __4 + __5 + __6 + __7; return _(null, __1); }, true, false), 5); }, true, false), 4); }, true, false), 3); }, true, false), 2); }, true, false), 1); }, true, false), 0); }); }, 'ebcdde'); - _(); }); }); - - asyncTest('switch without default', 1, function __37(_) { var __frame = { name: '__37', line: 465 }; return __func(_, this, arguments, __37, 0, __frame, function __$__37() { - evalTest(function f(_) { - function g(_, i) { var result; var __frame = { name: 'g', line: 467 }; return __func(_, this, arguments, g, 0, __frame, function __$g() { result = 'a'; - - return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return function __$g(__break) { switch (__1) { case - 1: - result = 'b'; - return __break(); case - 2: - return _(null, 'c'); case - 3: case - 4: - result = 'd'; - return __break(); default: return __break(); } }(function __$g() { - - return _(null, result); }); }, true, false), i); }); } var __frame = { name: 'f', line: 466 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - - return g(__cb(_, __frame, 17, 0, function ___(__0, __2) { return g(__cb(_, __frame, 17, 0, function ___(__0, __3) { return g(__cb(_, __frame, 17, 0, function ___(__0, __4) { return g(__cb(_, __frame, 17, 0, function ___(__0, __5) { return g(__cb(_, __frame, 17, 0, function ___(__0, __6) { return g(__cb(_, __frame, 17, 0, function ___(__0, __7) { var __1 = __2 + __3 + __4 + __5 + __6 + __7; return _(null, __1); }, true, false), 5); }, true, false), 4); }, true, false), 3); }, true, false), 2); }, true, false), 1); }, true, false), 0); }); }, 'abcdda'); - _(); }); }); - - asyncTest('switch with fall through', 1, function __38(_) { var __frame = { name: '__38', line: 486 }; return __func(_, this, arguments, __38, 0, __frame, function __$__38() { - evalTest(function f(_) { - function g(_, i) { var result; var __frame = { name: 'g', line: 488 }; return __func(_, this, arguments, g, 0, __frame, function __$g() { result = '/'; - - return delay(__cb(_, __frame, 2, 0, function ___(__0, __6) { var __5 = __6; return function __$g(__break) { switch (__5) { case - 1: - return delay(__cb(_, __frame, 4, 0, function ___(__0, __7) { result += __7; - return __break(); }, true, false), 'b'); case - 2: var __1 = true; case + return _(new Error(' except')); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try outer catch except'); + + _(); }); }); + +asyncTest('nested try/catch 3', 1, function __30(_) { var __frame = { name: '__30', line: 348 }; return __func(_, this, arguments, __30, 0, __frame, function __$__30() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 349 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; __then(); }, true, false), 'try'); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner catch ' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { - 3: var __2 = true; case - 4: var __3 = true; case + return _(new Error(' except')); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try outer catch except'); + + _(); }); }); + +asyncTest('nested try/finally 1', 1, function __31(_) { var __frame = { name: '__31', line: 363 }; return __func(_, this, arguments, __31, 0, __frame, function __$__31() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 364 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - 5: return function __$g(__then) { if (__3) { return function __$g(__then) { if (__2) { return function __$g(__then) { if (__1) { return delay(__cb(_, __frame, 7, 0, function ___(__0, __8) { result += __8; __then(); }, true, false), 'c'); } else { __then(); } }(__then); } else { __then(); } }(function __$g() { result += 'd'; __then(); }); } else { __then(); } }(function __$g() { - return delay(__cb(_, __frame, 12, 0, function ___(__0, __9) { result += __9; - return __break(); }, true, false), 'e'); }); case - 6: var __4 = true; default: + throwError(' except'); __then(); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try inner finally outer catch except'); + + _(); }); }); + +asyncTest('nested try/finally 2', 1, function __32(_) { var __frame = { name: '__32', line: 378 }; return __func(_, this, arguments, __32, 0, __frame, function __$__32() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 379 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + x += ' inner finally'; __then(); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { - return function __$g(__then) { if (__4) { return delay(__cb(_, __frame, 15, 0, function ___(__0, __10) { result += __10; __then(); }, true, false), 'f'); } else { __then(); } }(function __$g() { - return delay(__cb(_, __frame, 17, 0, function ___(__0, __11) { result += __11; return __break(); }, true, false), 'g'); }); } }(function __$g() { + throwError(' except'); __then(); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try inner finally outer catch except'); + + _(); }); }); + +asyncTest('nested try/finally 3', 1, function __33(_) { var __frame = { name: '__33', line: 393 }; return __func(_, this, arguments, __33, 0, __frame, function __$__33() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 394 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = ''; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { x += __1; _(null, null, true); }, true, false), 'try'); }); }(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$f() { + + return delay(__cb(_, __frame, 6, 0, function ___(__0, __2) { x += __2; __then(); }, true, false), ' inner finally'); }); }(function ___() { __tryCatch(_, function ___() { if (__cont) __then(); else _(__e, __r); }); })); })); }(function ___() { __tryCatch(_, function __$f() { + + return _(new Error(' except')); }); }); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, x + ' outer catch' + ex.message); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'try inner finally outer catch except'); + + _(); }); }); + +asyncTest('and ok', 1, function __34(_) { var __frame = { name: '__34', line: 408 }; return __func(_, this, arguments, __34, 0, __frame, function __$__34() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 409 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = '<<'; + + return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; if (!__1) { return _(null, __1); } return delay(__cb(_, __frame, 2, 0, _, true, false), true); }, true, false), true); }(__cb(_, __frame, 2, 0, function ___(__0, __7) { var __6 = __7; return function __$f(__then) { if (__6) { x += 'T1'; __then(); } else { + x += 'F1'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __3) { var __2 = __3; if (!__2) { return _(null, __2); } return delay(__cb(_, __frame, 4, 0, _, true, false), false); }, true, false), true); }(__cb(_, __frame, 4, 0, function ___(__0, __9) { var __8 = __9; return function __$f(__then) { if (__8) { x += 'T2'; __then(); } else { + x += 'F2'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 6, 0, function ___(__0, __4) { var __3 = __4; if (!__3) { return _(null, __3); } return delay(__cb(_, __frame, 6, 0, _, true, false), true); }, true, false), false); }(__cb(_, __frame, 6, 0, function ___(__0, __11) { var __10 = __11; return function __$f(__then) { if (__10) { x += 'T3'; __then(); } else { + x += 'F3'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 8, 0, function ___(__0, __5) { var __4 = __5; if (!__4) { return _(null, __4); } return delay(__cb(_, __frame, 8, 0, _, true, false), false); }, true, false), false); }(__cb(_, __frame, 8, 0, function ___(__0, __13) { var __12 = __13; return function __$f(__then) { if (__12) { x += 'T4'; __then(); } else { + x += 'F4'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 10, 0, function ___(__0, __6) { var __5 = __6; if (!__5) { return _(null, __5); } return delayFail(__cb(_, __frame, 10, 0, _, true, false), 'bad'); }, true, false), false); }(__cb(_, __frame, 10, 0, function ___(__0, __15) { var __14 = __15; return function __$f(__then) { if (__14) { x += 'T5'; __then(); } else { + x += 'F5'; __then(); } }(function __$f() { + x += '>>'; + return _(null, x); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, '<>'); + _(); }); }); + +asyncTest('or ok', 1, function __35(_) { var __frame = { name: '__35', line: 425 }; return __func(_, this, arguments, __35, 0, __frame, function __$__35() { + evalTest(function f(_) { var x; var __frame = { name: 'f', line: 426 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { x = '<<'; + + return function __$f(_) { return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; if (__1) { return _(null, __1); } return delay(__cb(_, __frame, 2, 0, _, true, false), true); }, true, false), true); }(__cb(_, __frame, 2, 0, function ___(__0, __7) { var __6 = __7; return function __$f(__then) { if (__6) { x += 'T1'; __then(); } else { + x += 'F1'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 4, 0, function ___(__0, __3) { var __2 = __3; if (__2) { return _(null, __2); } return delay(__cb(_, __frame, 4, 0, _, true, false), false); }, true, false), true); }(__cb(_, __frame, 4, 0, function ___(__0, __9) { var __8 = __9; return function __$f(__then) { if (__8) { x += 'T2'; __then(); } else { + x += 'F2'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 6, 0, function ___(__0, __4) { var __3 = __4; if (__3) { return _(null, __3); } return delay(__cb(_, __frame, 6, 0, _, true, false), true); }, true, false), false); }(__cb(_, __frame, 6, 0, function ___(__0, __11) { var __10 = __11; return function __$f(__then) { if (__10) { x += 'T3'; __then(); } else { + x += 'F3'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 8, 0, function ___(__0, __5) { var __4 = __5; if (__4) { return _(null, __4); } return delay(__cb(_, __frame, 8, 0, _, true, false), false); }, true, false), false); }(__cb(_, __frame, 8, 0, function ___(__0, __13) { var __12 = __13; return function __$f(__then) { if (__12) { x += 'T4'; __then(); } else { + x += 'F4'; __then(); } }(function __$f() { + return function __$f(_) { return delay(__cb(_, __frame, 10, 0, function ___(__0, __6) { var __5 = __6; if (__5) { return _(null, __5); } return delayFail(__cb(_, __frame, 10, 0, _, true, false), 'bad'); }, true, false), true); }(__cb(_, __frame, 10, 0, function ___(__0, __15) { var __14 = __15; return function __$f(__then) { if (__14) { x += 'T5'; __then(); } else { + x += 'F5'; __then(); } }(function __$f() { + x += '>>'; + return _(null, x); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, true, false)); }); }, '<>'); + _(); }); }); + +asyncTest('switch with default', 1, function __36(_) { var __frame = { name: '__36', line: 442 }; return __func(_, this, arguments, __36, 0, __frame, function __$__36() { + evalTest(function f(_) { + function g(_, i) { var result; var __frame = { name: 'g', line: 444 }; return __func(_, this, arguments, g, 0, __frame, function __$g() { result = 'a'; + + return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return function __$g(__break) { switch (__1) { case + 1: + return delay(__cb(_, __frame, 4, 0, function ___(__0, __3) { result = __3; + return __break(); }, true, false), 'b'); case + 2: + return delay(__cb(_, __frame, 7, 0, _, true, false), 'c'); case + 3: case + 4: + return delay(__cb(_, __frame, 10, 0, function ___(__0, __6) { result = __6; + return __break(); }, true, false), 'd'); default: - return _(null, result); }); }, true, false), i); }); } var __frame = { name: 'f', line: 487 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - - return g(__cb(_, __frame, 23, 0, function ___(__0, __2) { return g(__cb(_, __frame, 23, 0, function ___(__0, __3) { return g(__cb(_, __frame, 23, 0, function ___(__0, __4) { return g(__cb(_, __frame, 23, 0, function ___(__0, __5) { return g(__cb(_, __frame, 23, 0, function ___(__0, __6) { return g(__cb(_, __frame, 23, 0, function ___(__0, __7) { return g(__cb(_, __frame, 23, 0, function ___(__0, __8) { return g(__cb(_, __frame, 23, 0, function ___(__0, __9) { var __1 = __2 + __3 + __4 + __5 + __6 + __7 + __8 + __9; return _(null, __1); }, true, false), 7); }, true, false), 6); }, true, false), 5); }, true, false), 4); }, true, false), 3); }, true, false), 2); }, true, false), 1); }, true, false), 0); }); }, '/g/b/cde/de/de/e/fg/g'); - _(); }); }); - - asyncTest('this', 5, function __39(_) { var __frame = { name: '__39', line: 513 }; return __func(_, this, arguments, __39, 0, __frame, function __$__39() { - evalTest(function f(_) { var o; - function O(x) { - this.x = x; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function delay2(val, _) { var __frame = { name: 'delay2', line: 545 }; return __func(_, this, arguments, delay2, 1, __frame, function __$delay2() { - return delay(__cb(_, __frame, 1, 0, _, true, false), val); }); } var __frame = { name: 'f', line: 514 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { O.prototype.test1 = function O_prototype_test1__1(_) { var self, __this = this; var __frame = { name: 'O_prototype_test1__1', line: 519 }; return __func(_, this, arguments, O_prototype_test1__1, 0, __frame, function __$O_prototype_test1__1() { self = __this; return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { __this.x = __1; strictEqual(__this, self); _(); }, true, false), __this.x + 1); }); }; O.prototype.test2 = function O_prototype_test2__2(_) { var self, __this = this; var __frame = { name: 'O_prototype_test2__2', line: 524 }; return __func(_, this, arguments, O_prototype_test2__2, 0, __frame, function __$O_prototype_test2__2() { self = __this; return function ___(__then) { (function ___(_) { __tryCatch(_, function __$O_prototype_test2__2() { return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { __this.x = __1; strictEqual(__this, self); __then(); }, true, false), __this.x + 1); }); }(function ___(ex, __result) { __catch(function __$O_prototype_test2__2() { if (ex) { ok(false); __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$O_prototype_test2__2() { _(); }); }); }); }; O.prototype.test3 = function O_prototype_test3__3(_) { var self, __this = this; var __frame = { name: 'O_prototype_test3__3', line: 533 }; return __func(_, this, arguments, O_prototype_test3__3, 0, __frame, function __$O_prototype_test3__3() { self = __this; return function ___(__then) { (function ___(_) { __tryCatch(_, function __$O_prototype_test3__3() { return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { __this.x = __1; throwError('test3'); ok(false); __then(); }, true, false), __this.x + 1); }); }(function ___(ex, __result) { __catch(function __$O_prototype_test3__3() { if (ex) { strictEqual(__this, self); return delay(__cb(_, __frame, 8, 0, function ___(__0, __2) { __this.x = __2; __then(); }, true, false), __this.x + 1); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$O_prototype_test3__3() { _(); }); }); }); }; - - - O.prototype.test4 = function O_prototype_test4__4(_) { var self, v1, v2, __this = this; var __frame = { name: 'O_prototype_test4__4', line: 549 }; return __func(_, this, arguments, O_prototype_test4__4, 0, __frame, function __$O_prototype_test4__4() { self = __this; v1 = delay2(__this.x + 1, false); + return delay(__cb(_, __frame, 13, 0, function ___(__0, __7) { result = __7; return __break(); }, true, false), 'e'); } }(function __$g() { - v2 = delay2(1, false); + return _(null, result); }); }, true, false), i); }); } var __frame = { name: 'f', line: 443 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + + return g(__cb(_, __frame, 19, 0, function ___(__0, __2) { return g(__cb(_, __frame, 19, 0, function ___(__0, __3) { return g(__cb(_, __frame, 19, 0, function ___(__0, __4) { return g(__cb(_, __frame, 19, 0, function ___(__0, __5) { return g(__cb(_, __frame, 19, 0, function ___(__0, __6) { return g(__cb(_, __frame, 19, 0, function ___(__0, __7) { var __1 = __2 + __3 + __4 + __5 + __6 + __7; return _(null, __1); }, true, false), 5); }, true, false), 4); }, true, false), 3); }, true, false), 2); }, true, false), 1); }, true, false), 0); }); }, 'ebcdde'); + _(); }); }); + +asyncTest('switch without default', 1, function __37(_) { var __frame = { name: '__37', line: 465 }; return __func(_, this, arguments, __37, 0, __frame, function __$__37() { + evalTest(function f(_) { + function g(_, i) { var result; var __frame = { name: 'g', line: 467 }; return __func(_, this, arguments, g, 0, __frame, function __$g() { result = 'a'; + + return delay(__cb(_, __frame, 2, 0, function ___(__0, __2) { var __1 = __2; return function __$g(__break) { switch (__1) { case + 1: + result = 'b'; + return __break(); case + 2: + return _(null, 'c'); case + 3: case + 4: + result = 'd'; + return __break(); default: return __break(); } }(function __$g() { - return v1(__cb(_, __frame, 4, 0, function ___(__0, __1) { return v2(__cb(_, __frame, 4, 0, function ___(__0, __2) { __this.x = __1 + __2; - strictEqual(__this, self); _(); }, true, false)); }, true, false)); }); }; o = new O(1); - - - return o.test1(__cb(_, __frame, 43, 0, function __$f() { - return o.test2(__cb(_, __frame, 44, 0, function __$f() { - return o.test3(__cb(_, __frame, 45, 0, function __$f() { - return o.test4(__cb(_, __frame, 46, 0, function __$f() { - return _(null, o.x); }, true, false)); }, true, false)); }, true, false)); }, true, false)); }); }, 7); - _(); }); }); - - asyncTest('scoping', 1, function __40(_) { var __frame = { name: '__40', line: 564 }; return __func(_, this, arguments, __40, 0, __frame, function __$__40() { - evalTest(function f(_) { - function test(_) { var foo; - + return _(null, result); }); }, true, false), i); }); } var __frame = { name: 'f', line: 466 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + + return g(__cb(_, __frame, 17, 0, function ___(__0, __2) { return g(__cb(_, __frame, 17, 0, function ___(__0, __3) { return g(__cb(_, __frame, 17, 0, function ___(__0, __4) { return g(__cb(_, __frame, 17, 0, function ___(__0, __5) { return g(__cb(_, __frame, 17, 0, function ___(__0, __6) { return g(__cb(_, __frame, 17, 0, function ___(__0, __7) { var __1 = __2 + __3 + __4 + __5 + __6 + __7; return _(null, __1); }, true, false), 5); }, true, false), 4); }, true, false), 3); }, true, false), 2); }, true, false), 1); }, true, false), 0); }); }, 'abcdda'); + _(); }); }); + +asyncTest('switch with fall through', 1, function __38(_) { var __frame = { name: '__38', line: 486 }; return __func(_, this, arguments, __38, 0, __frame, function __$__38() { + evalTest(function f(_) { + function g(_, i) { var result; var __frame = { name: 'g', line: 488 }; return __func(_, this, arguments, g, 0, __frame, function __$g() { result = '/'; - function bar() { - return foo; } var __frame = { name: 'test', line: 566 }; return __func(_, this, arguments, test, 0, __frame, function __$test() { foo = 'abc'; - - - return delay(__cb(_, __frame, 7, 0, function __$test() { foo = 'xyz'; + return delay(__cb(_, __frame, 2, 0, function ___(__0, __6) { var __5 = __6; return function __$g(__break) { switch (__5) { case + 1: + return delay(__cb(_, __frame, 4, 0, function ___(__0, __7) { result += __7; + return __break(); }, true, false), 'b'); case + 2: var __1 = true; case + + 3: var __2 = true; case + 4: var __3 = true; case + + 5: return function __$g(__then) { if (__3) { return function __$g(__then) { if (__2) { return function __$g(__then) { if (__1) { return delay(__cb(_, __frame, 7, 0, function ___(__0, __8) { result += __8; __then(); }, true, false), 'c'); } else { __then(); } }(__then); } else { __then(); } }(function __$g() { result += 'd'; __then(); }); } else { __then(); } }(function __$g() { + return delay(__cb(_, __frame, 12, 0, function ___(__0, __9) { result += __9; + return __break(); }, true, false), 'e'); }); case + 6: var __4 = true; default: + + return function __$g(__then) { if (__4) { return delay(__cb(_, __frame, 15, 0, function ___(__0, __10) { result += __10; __then(); }, true, false), 'f'); } else { __then(); } }(function __$g() { + return delay(__cb(_, __frame, 17, 0, function ___(__0, __11) { result += __11; return __break(); }, true, false), 'g'); }); } }(function __$g() { - return _(null, bar); }, true, false)); }); } var __frame = { name: 'f', line: 565 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - - return test(__cb(_, __frame, 13, 0, function ___(__0, __2) { var __1 = __2(); return _(null, __1); }, true, false)); }); }, 'xyz'); - _(); }); }); - - asyncTest('return undefined', 1, function __41(_) { var __frame = { name: '__41', line: 581 }; return __func(_, this, arguments, __41, 0, __frame, function __$__41() { - evalTest(function f(_) { - function test(_) { var __frame = { name: 'test', line: 583 }; return __func(_, this, arguments, test, 0, __frame, function __$test() { - return delay(__cb(_, __frame, 1, 0, function __$test() { - return _(null); }, true, false)); }); } var __frame = { name: 'f', line: 582 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - - return test(__cb(_, __frame, 6, 0, _, true, false)); }); }, undefined); - _(); }); }); - - asyncTest('futures test', 1, function __42(_) { var __frame = { name: '__42', line: 591 }; return __func(_, this, arguments, __42, 0, __frame, function __$__42() { - evalTest(function f(_) { var a, b, c, d; - function delay2(val, _) { var __frame = { name: 'delay2', line: 593 }; return __func(_, this, arguments, delay2, 1, __frame, function __$delay2() { - return delay(__cb(_, __frame, 1, 0, _, true, false), val); }); } var __frame = { name: 'f', line: 592 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { a = delay2('a', false); - - - b = delay2('b', false); - c = delay2('c', false); - d = delay2('d', false); - - return a(__cb(_, __frame, 9, 0, function ___(__0, __2) { return b(__cb(_, __frame, 9, 0, function ___(__0, __3) { return d(__cb(_, __frame, 9, 0, function ___(__0, __4) { return c(__cb(_, __frame, 9, 0, function ___(__0, __5) { var __1 = __2 + __3 + __4 + __5; return _(null, __1); }, true, false)); }, true, false)); }, true, false)); }, true, false)); }); }, 'abdc'); - _(); }); }); - - asyncTest('last case without break', 1, function __43(_) { var __frame = { name: '__43', line: 604 }; return __func(_, this, arguments, __43, 0, __frame, function __$__43() { - evalTest(function f(_) { var __frame = { name: 'f', line: 605 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function __$f(__break) { switch (true) { case - true: var __1 = true; default: return function __$f(__then) { if (__1) { - return delay(__cb(_, __frame, 3, 0, __then, true, false)); } else { __then(); } }(__break); } }(function __$f() { - - return _(null, 1); }); }); }, 1); - _(); }); }); - - - asyncTest('async comma operator', 1, function __44(_) { var __frame = { name: '__44', line: 614 }; return __func(_, this, arguments, __44, 0, __frame, function __$__44() { - evalTest(function f(_) { var a; var __frame = { name: 'f', line: 615 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - return function __$f(_) { a = 4; a++; return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { a = __1; return delay(__cb(_, __frame, 2, 0, _, true, false), a + 1); }, true, false), 2 * a); }(__cb(_, __frame, 0, 0, _, true, false)); }); }, 11); - _(); }); }); - - - asyncTest('async constructor', 1, function __45(_) { var __frame = { name: '__45', line: 621 }; return __func(_, this, arguments, __45, 0, __frame, function __$__45() { - evalTest(function f(_) { - function Foo(val, _) { var __this = this; var __frame = { name: 'Foo', line: 623 }; return __func(_, this, arguments, Foo, 1, __frame, function __$Foo() { - return delay(__cb(_, __frame, 1, 0, function __$Foo() { - __this.x = val; _(); }, true, false)); }); } var __frame = { name: 'f', line: 622 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - Foo.prototype.y = function () { - return this.x + 1; }; - - return __construct(Foo, 1)(5, __cb(_, __frame, 8, 0, function ___(__0, __2) { var __1 = __2.y(); return _(null, __1); }, true, false)); }); }, 6); - _(); }); }); - - - asyncTest('fibo false async', 1, function __46(_) { var __frame = { name: '__46', line: 634 }; return __func(_, this, arguments, __46, 0, __frame, function __$__46() { - evalTest(function f(_) { - function fibo(_, n) { var __frame = { name: 'fibo', line: 636 }; return __func(_, this, arguments, fibo, 0, __frame, function __$fibo() { - return function __$fibo(_) { var __1 = n > 1; return function __$fibo(__then) { if (__1) { return fibo(__cb(_, __frame, 1, 0, function ___(__0, __3) { return fibo(__cb(_, __frame, 1, 0, function ___(__0, __4) { var __2 = __3 + __4; return _(null, __2); }, true, false), n - 2); }, true, false), n - 1); } else { __then(); } }(function __$fibo() { return _(null, 1); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); } var __frame = { name: 'f', line: 635 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - - return fibo(__cb(_, __frame, 4, 0, _, true, false), 16); }); }, 1597); - _(); }); }); - - - asyncTest('coffeescript wrapper 1', 1, function __47(_) { var __frame = { name: '__47', line: 643 }; return __func(_, this, arguments, __47, 0, __frame, function __$__47() { - evalTest(function f(_) { var __frame = { name: 'f', line: 644 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___closure(_) { - return delay(__cb(_, __frame, 1, 0, _, true, false), 'cs1'); }(__cb(_, __frame, 1, 0, _, true, false)); }); }, 'cs1'); + return _(null, result); }); }, true, false), i); }); } var __frame = { name: 'f', line: 487 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + + return g(__cb(_, __frame, 23, 0, function ___(__0, __2) { return g(__cb(_, __frame, 23, 0, function ___(__0, __3) { return g(__cb(_, __frame, 23, 0, function ___(__0, __4) { return g(__cb(_, __frame, 23, 0, function ___(__0, __5) { return g(__cb(_, __frame, 23, 0, function ___(__0, __6) { return g(__cb(_, __frame, 23, 0, function ___(__0, __7) { return g(__cb(_, __frame, 23, 0, function ___(__0, __8) { return g(__cb(_, __frame, 23, 0, function ___(__0, __9) { var __1 = __2 + __3 + __4 + __5 + __6 + __7 + __8 + __9; return _(null, __1); }, true, false), 7); }, true, false), 6); }, true, false), 5); }, true, false), 4); }, true, false), 3); }, true, false), 2); }, true, false), 1); }, true, false), 0); }); }, '/g/b/cde/de/de/e/fg/g'); + _(); }); }); + +asyncTest('this', 5, function __39(_) { var __frame = { name: '__39', line: 513 }; return __func(_, this, arguments, __39, 0, __frame, function __$__39() { + evalTest(function f(_) { var o; + function O(x) { + this.x = x; } - _(); }); }); - - - asyncTest('coffeescript wrapper 2', 1, function __48(_) { var __frame = { name: '__48', line: 651 }; return __func(_, this, arguments, __48, 0, __frame, function __$__48() { - evalTest(function f(_) { var __this = this; var __frame = { name: 'f', line: 652 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___closure(_) { - return delay(__cb(_, __frame, 1, 0, _, true, false), 'cs2'); }(__cb(_, __frame, 1, 0, _, true, false)); }); }, 'cs2'); - _(); }); }); - - - asyncTest('coffeescript wrapper 3', 1, function __49(_) { var __frame = { name: '__49', line: 659 }; return __func(_, this, arguments, __49, 0, __frame, function __$__49() { - evalTest(function f(_) { var __this = this, __arguments = arguments; var __frame = { name: 'f', line: 660 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___closure(_) { - return delay(__cb(_, __frame, 1, 0, _, true, false), 'cs3'); }(__cb(_, __frame, 1, 0, _, true, false)); }); }, 'cs3'); - _(); }); }); - - - asyncTest('sync try/catch in async', 1, function __50(_) { var __frame = { name: '__50', line: 667 }; return __func(_, this, arguments, __50, 0, __frame, function __$__50() { - evalTest(function f(_) { var __frame = { name: 'f', line: 668 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { - return _(new Error('catch me')); }); }(function ___(ex, __result) { - __catch(function __$f() { if (ex) { - return _(null, 'got it'); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'got it'); - - _(); }); }); - - - asyncTest('sync try/catch inside conditional', 1, function __51(_) { var __frame = { name: '__51', line: 677 }; return __func(_, this, arguments, __51, 0, __frame, function __$__51() { - evalTest(function f(_) { var __frame = { name: 'f', line: 678 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return function __$f(__then) { if (true) { - return function ___(__then) { (function ___(_) { __tryCatch(_, __then); }(function ___(ex, __result) { __catch(function __$f() { if (ex) { __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(_); }); }, undefined); - _(); }); }); - - - asyncTest('labelled break', 1, function __52(_) { var __frame = { name: '__52', line: 685 }; return __func(_, this, arguments, __52, 0, __frame, function __$__52() { - evalTest(function f(_) { var result, i, j; var __frame = { name: 'f', line: 686 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = ''; - i = 1; - - var __7 = false; return function ___(__break) { var __more, __more__outer = { get: function () { return __more; }, set: function (v) { __more = v; } }; var __loop = __cb(_, __frame, 0, 0, function __$f() { var __break__outer = __break, __loop__outer = __loop; __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < 10; if (__6) { j = 5; - - var __9 = false; return function ___(__break) { var __more, __more__inner = { get: function () { return __more; }, set: function (v) { __more = v; } }; var __loop = __cb(_, __frame, 0, 0, function __$f() { var __break__inner = __break, __loop__inner = __loop; __more = false; if (__9) { j++; } else { __9 = true; } var __8 = j < 10; if (__8) { - return delay(__cb(_, __frame, 6, 0, function ___(__0, __1) { result = __1 + '!'; - if (i == 1 && j == 7) { return __break(); } - if (i == 2 && j == 7) { return __break__inner(); } - if (i == 3 && j == 7) { while (__more__inner.get()) { __loop__inner(); } __more__inner.set(true); return; } - if (i == 4 && j == 7) { while (__more__outer.get()) { __loop__outer(); } __more__outer.set(true); return; } - if (i == 5 && j == 7) { return __break__outer(); } - return delay(__cb(_, __frame, 12, 0, function ___(__0, __2) { return delay(__cb(_, __frame, 12, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 12, 0, function ___(__0, __4) { result = __2 + __3 + __4 + '-'; while (__more) { __loop(); } __more = true; }, true, false), j); }, true, false), i); }, true, false), result); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { - - return delay(__cb(_, __frame, 14, 0, function ___(__0, __5) { result += __5; while (__more) { __loop(); } __more = true; }, true, false), '/'); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { - - return _(null, result); }); }); }, '!15-!16-!/!25-!26-!/!35-!36-!!38-!39-/!45-!46-!!55-!56-!'); - _(); }); }); - - - asyncTest('octal literal', 1, function __53(_) { var __frame = { name: '__53', line: 706 }; return __func(_, this, arguments, __53, 0, __frame, function __$__53() { - evalTest(function f(_) { var __frame = { name: 'f', line: 707 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return _(null, 8); }); }, 8); - _(); }); }); - - - asyncTest('typeof rewriting bug (fibers)', 1, function __54(_) { var __frame = { name: '__54', line: 712 }; return __func(_, this, arguments, __54, 0, __frame, function __$__54() { - evalTest(function f(_) { var hello; var __frame = { name: 'f', line: 713 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { hello = 'hello'; - - return _(null, typeof hello); }); }, 'string'); - _(); }); }); - - - asyncTest('ASI problems', 1, function __55(_) { var __frame = { name: '__55', line: 719 }; return __func(_, this, arguments, __55, 0, __frame, function __$__55() { - evalTest(function f(_) { var s; var __frame = { name: 'f', line: 720 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { s = 'a'; - - return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { s = __1; - return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { s = __2; - return delay(__cb(_, __frame, 4, 0, function __$f() { - return delay(__cb(_, __frame, 5, 0, function __$f() { - return _(null, s); }, true, false), s); }, true, false), s); }, true, false), s); }, true, false), s); }); }, 'a'); - _(); }); }); - - - function twoResults(a, b, cb) { - setTimeout(function () { - cb(null, a, b); }, 0); } - - - - function twoResultsSync(a, b, cb) { - cb(null, a, b); } - - - asyncTest('multiple results ~_', 1, function __56(_) { var __frame = { name: '__56', line: 740 }; return __func(_, this, arguments, __56, 0, __frame, function __$__56() { - evalTest(function f(_) { var results; var __frame = { name: 'f', line: 741 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return twoResults('abc', 'def', __cb(_, __frame, 1, 0, function ___(__0, __1) { results = __1; - return _(null, results); }, true, false)); }); }, 'abc'); - _(); }); }); - - - asyncTest('multiple results [_]', 1, function __57(_) { var __frame = { name: '__57', line: 747 }; return __func(_, this, arguments, __57, 0, __frame, function __$__57() { - evalTest(function f(_) { var results; var __frame = { name: 'f', line: 748 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return twoResults('abc', 'def', __cb(_, __frame, 1, 0, function ___(__0, __1) { results = __1; - return _(null, results.join('-')); }, true, true)); }); }, 'abc-def'); - _(); }); }); - - - asyncTest('multiple results with future', 1, function __58(_) { var __frame = { name: '__58', line: 754 }; return __func(_, this, arguments, __58, 0, __frame, function __$__58() { - evalTest(function f(_) { var results; - function wrapper(a, b, _) { var __frame = { name: 'wrapper', line: 756 }; return __func(_, this, arguments, wrapper, 2, __frame, function __$wrapper() { return twoResults(a, b, __cb(_, __frame, 0, 0, _, true, true)); }); } var __frame = { name: 'f', line: 755 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return wrapper('abc', 'def', false)(__cb(_, __frame, 2, 0, function ___(__0, __1) { results = __1; - return _(null, results.join('-')); }, true, false)); }); }, 'abc-def'); - _(); }); }); - - - asyncTest('multiple results synchronously', 1, function __59(_) { var __frame = { name: '__59', line: 762 }; return __func(_, this, arguments, __59, 0, __frame, function __$__59() { - evalTest(function f(_) { var results; var __frame = { name: 'f', line: 763 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return twoResultsSync('abc', 'def', __cb(_, __frame, 1, 0, function ___(__0, __1) { results = __1; - return _(null, results.join('-')); }, true, true)); }); }, 'abc-def'); - _(); }); }); - - - asyncTest('this in futures', 2, function __60(_) { var c; var __frame = { name: '__60', line: 769 }; return __func(_, this, arguments, __60, 0, __frame, function __$__60() { c = { v: 1, test: function test__1(_) { - - - var __this = this; var __frame = { name: 'test__1', line: 772 }; return __func(_, this, arguments, test__1, 0, __frame, function __$test__1() { return _(null, __this.v); }); } }; - return c.test(__cb(_, __frame, 5, 0, function ___(__0, __2) { strictEqual(__2, 1, 'direct call'); - return c.test(false)(__cb(_, __frame, 6, 0, function ___(__0, __3) { strictEqual(__3, 1, 'future call'); - start(); _(); }, true, false)); }, true, false)); }); }); - - - asyncTest('arity of async functions', 3, function __61(_) { var f, g; var __frame = { name: '__61', line: 779 }; return __func(_, this, arguments, __61, 0, __frame, function __$__61() { f = function __1(_, a, b, c, d, e, f, g, h, i) { - var __frame = { name: '__1', line: 780 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return _(null, a + b); }); }; g = function __2(_, a) { - var __frame = { name: '__2', line: 781 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return f(__cb(_, __frame, 0, 0, _, true, false), 1, 2); }); }; - strictEqual(f.length, 10, 'f.length === 10'); - strictEqual(g.length, 2, 'g.length === 2'); - return g(__cb(_, __frame, 5, 0, function ___(__0, __3) { strictEqual(__3, 3, 'g(_) === 3'); - start(); _(); }, true, false)); }); }); - - - asyncTest('futures on _(fn, idx)', 1, function __62(_) { var f, fut; var __frame = { name: '__62', line: 788 }; return __func(_, this, arguments, __62, 0, __frame, function __$__62() { f = __rt.streamlinify(function (i, cb) { - - setTimeout(function () { - cb(null, i + 1); }, 0); }, 1); - fut = f(5, false); - return fut(__cb(_, __frame, 7, 0, function ___(__0, __1) { strictEqual(__1, 6, 'fut(_) === 6'); - start(); _(); }, true, false)); }); }); - - - asyncTest('do while', 1, function __63(_) { var i, s, v; - - function read(_) { var __frame = { name: 'read', line: 801 }; return __func(_, this, arguments, read, 0, __frame, function __$read() { - return delay(__cb(_, __frame, 1, 0, _, true, false), ++i); }); } var __frame = { name: '__63', line: 799 }; return __func(_, this, arguments, __63, 0, __frame, function __$__63() { i = 0; s = ''; - return read(__cb(_, __frame, 6, 0, function ___(__0, __3) { v = __3; var __1 = true; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__63() { __more = false; return function __$__63(_) { return function __$__63(_) { var __2 = __1; if (__2) { return _(null, __2); } - - - return read(__cb(_, __frame, 9, 0, function ___(__0, __4) { var __3 = (v = __4) < 5; return _(null, __3); }, true, false)); }(__cb(_, __frame, 0, 0, _, true, false)); }(__cb(_, __frame, 0, 0, function ___(__0, __5) { if (__5) { __1 = false; s += v; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$__63() { - strictEqual(s, '1234'); - start(); _(); }); }, true, false)); }); }); - - - asyncTest('return undefined', 1, function __64(_) { - function read(_) { var __frame = { name: 'read', line: 814 }; return __func(_, this, arguments, read, 0, __frame, function __$read() { - return delay(__cb(_, __frame, 1, 0, _, true, false), 1); }); } - - function f(_) { var __frame = { name: 'f', line: 817 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { - return read(__cb(_, __frame, 1, 0, function __$f() { _(); }, true, false)); }); } var __frame = { name: '__64', line: 813 }; return __func(_, this, arguments, __64, 0, __frame, function __$__64() { - return f(__cb(_, __frame, 7, 0, function ___(__0, __1) { strictEqual(__1, undefined); - start(); _(); }, true, false)); }); }); - - - if (typeof require !== 'undefined') { - var globals = require('streamline/lib/globals'); - var isFast = /-fast$/.test(globals.runtime); - - if (globals.Promise) asyncTest('promises', isFast ? 3 : 7, function __65(_) { var p1, p2, p3, p4; - function test(v, _) { var __frame = { name: 'test', line: 829 }; return __func(_, this, arguments, test, 1, __frame, function __$test() { - return delay(__cb(_, __frame, 1, 0, _, true, false), v); }); } var __frame = { name: '__65', line: 828 }; return __func(_, this, arguments, __65, 0, __frame, function __$__65() { - - return function __$__65(__then) { if (!isFast) { p1 = test('a'); - p2 = test('b', null); - - strictEqual(p1 && typeof p1.then, 'function'); - strictEqual(p2 && typeof p2.then, 'function'); - return __pthen(p1, 'then', __cb(_, __frame, 9, 0, function ___(__0, __1) { strictEqual(__1, 'a'); - return __pthen(p2, 'then', __cb(_, __frame, 10, 0, function ___(__0, __2) { strictEqual(__2, 'b'); __then(); }, true, false)); }, true, false)); } else { __then(); } }(function __$__65() { p3 = test('c', null); + + + + + + + + + + + + + + + + + + + function delay2(val, _) { var __frame = { name: 'delay2', line: 545 }; return __func(_, this, arguments, delay2, 1, __frame, function __$delay2() { + return delay(__cb(_, __frame, 1, 0, _, true, false), val); }); } var __frame = { name: 'f', line: 514 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { O.prototype.test1 = function O_prototype_test1__1(_) { var self, __this = this; var __frame = { name: 'O_prototype_test1__1', line: 519 }; return __func(_, this, arguments, O_prototype_test1__1, 0, __frame, function __$O_prototype_test1__1() { self = __this; return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { __this.x = __1; strictEqual(__this, self); _(); }, true, false), __this.x + 1); }); }; O.prototype.test2 = function O_prototype_test2__2(_) { var self, __this = this; var __frame = { name: 'O_prototype_test2__2', line: 524 }; return __func(_, this, arguments, O_prototype_test2__2, 0, __frame, function __$O_prototype_test2__2() { self = __this; return function ___(__then) { (function ___(_) { __tryCatch(_, function __$O_prototype_test2__2() { return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { __this.x = __1; strictEqual(__this, self); __then(); }, true, false), __this.x + 1); }); }(function ___(ex, __result) { __catch(function __$O_prototype_test2__2() { if (ex) { ok(false); __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$O_prototype_test2__2() { _(); }); }); }); }; O.prototype.test3 = function O_prototype_test3__3(_) { var self, __this = this; var __frame = { name: 'O_prototype_test3__3', line: 533 }; return __func(_, this, arguments, O_prototype_test3__3, 0, __frame, function __$O_prototype_test3__3() { self = __this; return function ___(__then) { (function ___(_) { __tryCatch(_, function __$O_prototype_test3__3() { return delay(__cb(_, __frame, 3, 0, function ___(__0, __1) { __this.x = __1; throwError('test3'); ok(false); __then(); }, true, false), __this.x + 1); }); }(function ___(ex, __result) { __catch(function __$O_prototype_test3__3() { if (ex) { strictEqual(__this, self); return delay(__cb(_, __frame, 8, 0, function ___(__0, __2) { __this.x = __2; __then(); }, true, false), __this.x + 1); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$O_prototype_test3__3() { _(); }); }); }); }; + + + O.prototype.test4 = function O_prototype_test4__4(_) { var self, v1, v2, __this = this; var __frame = { name: 'O_prototype_test4__4', line: 549 }; return __func(_, this, arguments, O_prototype_test4__4, 0, __frame, function __$O_prototype_test4__4() { self = __this; v1 = delay2(__this.x + 1, false); + v2 = delay2(1, false); - strictEqual(p3 && typeof p3.then, 'function'); - return __pthen(p3, 'then', __cb(_, __frame, 14, 0, function ___(__0, __3) { strictEqual(__3, 'c'); - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$__65() { p4 = delayFail(null, 'ERR d'); - - return __pthen(p4, 'then', __cb(_, __frame, 17, 0, function __$__65() { - ok(false); __then(); }, true, false)); }); }(function ___(ex, __result) { - __catch(function __$__65() { if (ex) { - strictEqual(ex, 'ERR d'); __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$__65() { - - start(); _(); }); }); }, true, false)); }); }); }); + return v1(__cb(_, __frame, 4, 0, function ___(__0, __1) { return v2(__cb(_, __frame, 4, 0, function ___(__0, __2) { __this.x = __1 + __2; + strictEqual(__this, self); _(); }, true, false)); }, true, false)); }); }; o = new O(1); + + + return o.test1(__cb(_, __frame, 43, 0, function __$f() { + return o.test2(__cb(_, __frame, 44, 0, function __$f() { + return o.test3(__cb(_, __frame, 45, 0, function __$f() { + return o.test4(__cb(_, __frame, 46, 0, function __$f() { + return _(null, o.x); }, true, false)); }, true, false)); }, true, false)); }, true, false)); }); }, 7); + _(); }); }); + +asyncTest('scoping', 1, function __40(_) { var __frame = { name: '__40', line: 564 }; return __func(_, this, arguments, __40, 0, __frame, function __$__40() { + evalTest(function f(_) { + function test(_) { var foo; + + + function bar() { + return foo; } var __frame = { name: 'test', line: 566 }; return __func(_, this, arguments, test, 0, __frame, function __$test() { foo = 'abc'; + + + return delay(__cb(_, __frame, 7, 0, function __$test() { foo = 'xyz'; + + return _(null, bar); }, true, false)); }); } var __frame = { name: 'f', line: 565 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + + return test(__cb(_, __frame, 13, 0, function ___(__0, __2) { var __1 = __2(); return _(null, __1); }, true, false)); }); }, 'xyz'); + _(); }); }); + +asyncTest('return undefined', 1, function __41(_) { var __frame = { name: '__41', line: 581 }; return __func(_, this, arguments, __41, 0, __frame, function __$__41() { + evalTest(function f(_) { + function test(_) { var __frame = { name: 'test', line: 583 }; return __func(_, this, arguments, test, 0, __frame, function __$test() { + return delay(__cb(_, __frame, 1, 0, function __$test() { + return _(null); }, true, false)); }); } var __frame = { name: 'f', line: 582 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + + return test(__cb(_, __frame, 6, 0, _, true, false)); }); }, undefined); + _(); }); }); + +asyncTest('futures test', 1, function __42(_) { var __frame = { name: '__42', line: 591 }; return __func(_, this, arguments, __42, 0, __frame, function __$__42() { + evalTest(function f(_) { var a, b, c, d; + function delay2(val, _) { var __frame = { name: 'delay2', line: 593 }; return __func(_, this, arguments, delay2, 1, __frame, function __$delay2() { + return delay(__cb(_, __frame, 1, 0, _, true, false), val); }); } var __frame = { name: 'f', line: 592 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { a = delay2('a', false); + + + b = delay2('b', false); + c = delay2('c', false); + d = delay2('d', false); + + return a(__cb(_, __frame, 9, 0, function ___(__0, __2) { return b(__cb(_, __frame, 9, 0, function ___(__0, __3) { return d(__cb(_, __frame, 9, 0, function ___(__0, __4) { return c(__cb(_, __frame, 9, 0, function ___(__0, __5) { var __1 = __2 + __3 + __4 + __5; return _(null, __1); }, true, false)); }, true, false)); }, true, false)); }, true, false)); }); }, 'abdc'); + _(); }); }); + +asyncTest('last case without break', 1, function __43(_) { var __frame = { name: '__43', line: 604 }; return __func(_, this, arguments, __43, 0, __frame, function __$__43() { + evalTest(function f(_) { var __frame = { name: 'f', line: 605 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function __$f(__break) { switch (true) { case + true: var __1 = true; default: return function __$f(__then) { if (__1) { + return delay(__cb(_, __frame, 3, 0, __then, true, false)); } else { __then(); } }(__break); } }(function __$f() { + + return _(null, 1); }); }); }, 1); + _(); }); }); + + +asyncTest('async comma operator', 1, function __44(_) { var __frame = { name: '__44', line: 614 }; return __func(_, this, arguments, __44, 0, __frame, function __$__44() { + evalTest(function f(_) { var a; var __frame = { name: 'f', line: 615 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + return function __$f(_) { a = 4; a++; return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { a = __1; return delay(__cb(_, __frame, 2, 0, _, true, false), a + 1); }, true, false), 2 * a); }(__cb(_, __frame, 2, 0, _, true, false)); }); }, 11); + _(); }); }); + + +asyncTest('async constructor', 1, function __45(_) { var __frame = { name: '__45', line: 621 }; return __func(_, this, arguments, __45, 0, __frame, function __$__45() { + evalTest(function f(_) { + function Foo(val, _) { var __this = this; var __frame = { name: 'Foo', line: 623 }; return __func(_, this, arguments, Foo, 1, __frame, function __$Foo() { + return delay(__cb(_, __frame, 1, 0, function __$Foo() { + __this.x = val; _(); }, true, false)); }); } var __frame = { name: 'f', line: 622 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + Foo.prototype.y = function () { + return this.x + 1; }; + + return __construct(Foo, 1)(5, __cb(_, __frame, 8, 0, function ___(__0, __2) { var __1 = __2.y(); return _(null, __1); }, true, false)); }); }, 6); + _(); }); }); + + +asyncTest('fibo false async', 1, function __46(_) { var __frame = { name: '__46', line: 634 }; return __func(_, this, arguments, __46, 0, __frame, function __$__46() { + evalTest(function f(_) { + function fibo(_, n) { var __frame = { name: 'fibo', line: 636 }; return __func(_, this, arguments, fibo, 0, __frame, function __$fibo() { + return function __$fibo(_) { var __1 = n > 1; return function __$fibo(__then) { if (__1) { return fibo(__cb(_, __frame, 1, 0, function ___(__0, __3) { return fibo(__cb(_, __frame, 1, 0, function ___(__0, __4) { var __2 = __3 + __4; return _(null, __2); }, true, false), n - 2); }, true, false), n - 1); } else { __then(); } }(function __$fibo() { return _(null, 1); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); } var __frame = { name: 'f', line: 635 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + + return fibo(__cb(_, __frame, 4, 0, _, true, false), 16); }); }, 1597); + _(); }); }); + + +asyncTest('coffeescript wrapper 1', 1, function __47(_) { var __frame = { name: '__47', line: 643 }; return __func(_, this, arguments, __47, 0, __frame, function __$__47() { + evalTest(function f(_) { var __frame = { name: 'f', line: 644 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___closure(_) { + return delay(__cb(_, __frame, 1, 0, _, true, false), 'cs1'); }(__cb(_, __frame, 1, 0, _, true, false)); }); }, 'cs1'); + + _(); }); }); + + +asyncTest('coffeescript wrapper 2', 1, function __48(_) { var __frame = { name: '__48', line: 651 }; return __func(_, this, arguments, __48, 0, __frame, function __$__48() { + evalTest(function f(_) { var __this = this; var __frame = { name: 'f', line: 652 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___closure(_) { + return delay(__cb(_, __frame, 1, 0, _, true, false), 'cs2'); }(__cb(_, __frame, 1, 0, _, true, false)); }); }, 'cs2'); + + _(); }); }); + + +asyncTest('coffeescript wrapper 3', 1, function __49(_) { var __frame = { name: '__49', line: 659 }; return __func(_, this, arguments, __49, 0, __frame, function __$__49() { + evalTest(function f(_) { var __this = this, __arguments = arguments; var __frame = { name: 'f', line: 660 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___closure(_) { + return delay(__cb(_, __frame, 1, 0, _, true, false), 'cs3'); }(__cb(_, __frame, 1, 0, _, true, false)); }); }, 'cs3'); + _(); }); }); + + +asyncTest('sync try/catch in async', 1, function __50(_) { var __frame = { name: '__50', line: 667 }; return __func(_, this, arguments, __50, 0, __frame, function __$__50() { + evalTest(function f(_) { var __frame = { name: 'f', line: 668 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$f() { + return _(new Error('catch me')); }); }(function ___(ex, __result) { + __catch(function __$f() { if (ex) { + return _(null, 'got it'); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$f() { _(); }); }); }); }, 'got it'); + _(); }); }); + + +asyncTest('sync try/catch inside conditional', 1, function __51(_) { var __frame = { name: '__51', line: 677 }; return __func(_, this, arguments, __51, 0, __frame, function __$__51() { + evalTest(function f(_) { var __frame = { name: 'f', line: 678 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return function __$f(__then) { if (true) { + return function ___(__then) { (function ___(_) { __tryCatch(_, __then); }(function ___(ex, __result) { __catch(function __$f() { if (ex) { __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, __then); }); } else { __then(); } }(_); }); }, undefined); - if (!isFast) asyncTest('coffeescript default values', 8, function __66(_) { var got, that, r, f; + _(); }); }); + + +asyncTest('labelled break', 1, function __52(_) { var __frame = { name: '__52', line: 685 }; return __func(_, this, arguments, __52, 0, __frame, function __$__52() { + evalTest(function f(_) { var result, i, j; var __frame = { name: 'f', line: 686 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { result = ''; - function fn(a, b, cb, c) { var args = Array.prototype.slice.call(arguments, 0); - if (a == null) { - args[0] = 2; } - - if (cb == null) { - args[2] = function (e, r) { - got = r; }; } return function __1(a, b, _, c) { var __this = this; var __frame = { name: '__1', line: 857 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() { - + i = 1; var __7 = false; return function ___(__break) { var __more, __more__outer = { get: function () { return __more; }, set: function (v) { __more = v; } }; var __loop = __cb(_, __frame, 0, 0, function __$f() { var __break__outer = __break, __loop__outer = __loop; __more = false; if (__7) { i++; } else { __7 = true; } var __6 = i < 10; if (__6) { - if (c == null) { - c = 5; } + j = 5; var __9 = false; return function ___(__break) { var __more, __more__inner = { get: function () { return __more; }, set: function (v) { __more = v; } }; var __loop = __cb(_, __frame, 0, 0, function __$f() { var __break__inner = __break, __loop__inner = __loop; __more = false; if (__9) { j++; } else { __9 = true; } var __8 = j < 10; if (__8) { + return delay(__cb(_, __frame, 6, 0, function ___(__0, __1) { result = __1 + '!'; + if (i == 1 && j == 7) { return __break(); } + if (i == 2 && j == 7) { return __break__inner(); } + if (i == 3 && j == 7) { while (__more__inner.get()) { __loop__inner(); } __more__inner.set(true); return; } + if (i == 4 && j == 7) { while (__more__outer.get()) { __loop__outer(); } __more__outer.set(true); return; } + if (i == 5 && j == 7) { return __break__outer(); } + return delay(__cb(_, __frame, 12, 0, function ___(__0, __2) { return delay(__cb(_, __frame, 12, 0, function ___(__0, __3) { return delay(__cb(_, __frame, 12, 0, function ___(__0, __4) { result = __2 + __3 + __4 + '-'; while (__more) { __loop(); } __more = true; }, true, false), j); }, true, false), i); }, true, false), result); }, true, false), result); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return delay(__cb(_, __frame, 14, 0, function ___(__0, __5) { result += __5; while (__more) { __loop(); } __more = true; }, true, false), '/'); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$f() { + + return _(null, result); }); }); }, '!15-!16-!/!25-!26-!/!35-!36-!!38-!39-/!45-!46-!!55-!56-!'); + _(); }); }); + + +asyncTest('octal literal', 1, function __53(_) { var __frame = { name: '__53', line: 706 }; return __func(_, this, arguments, __53, 0, __frame, function __$__53() { + evalTest(function f(_) { var __frame = { name: 'f', line: 707 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return _(null, 8); }); }, 8); + _(); }); }); + + +asyncTest('typeof rewriting bug (fibers)', 1, function __54(_) { var __frame = { name: '__54', line: 712 }; return __func(_, this, arguments, __54, 0, __frame, function __$__54() { + evalTest(function f(_) { var hello; var __frame = { name: 'f', line: 713 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { hello = 'hello'; + + return _(null, typeof hello); }); }, 'string'); + _(); }); }); + + +asyncTest('ASI problems', 1, function __55(_) { var __frame = { name: '__55', line: 719 }; return __func(_, this, arguments, __55, 0, __frame, function __$__55() { + evalTest(function f(_) { var s; var __frame = { name: 'f', line: 720 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { s = 'a'; + + return delay(__cb(_, __frame, 2, 0, function ___(__0, __1) { s = __1; + return delay(__cb(_, __frame, 3, 0, function ___(__0, __2) { s = __2; + return delay(__cb(_, __frame, 4, 0, function __$f() { + return delay(__cb(_, __frame, 5, 0, function __$f() { + return _(null, s); }, true, false), s); }, true, false), s); }, true, false), s); }, true, false), s); }); }, 'a'); + _(); }); }); + + +function twoResults(a, b, cb) { + setTimeout(function () { + cb(null, a, b); }, 0); } + + + +function twoResultsSync(a, b, cb) { + cb(null, a, b); } + + +asyncTest('multiple results ~_', 1, function __56(_) { var __frame = { name: '__56', line: 740 }; return __func(_, this, arguments, __56, 0, __frame, function __$__56() { + evalTest(function f(_) { var results; var __frame = { name: 'f', line: 741 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return twoResults('abc', 'def', __cb(_, __frame, 1, 0, function ___(__0, __1) { results = __1; + return _(null, results); }, true, false)); }); }, 'abc'); + _(); }); }); + + +asyncTest('multiple results [_]', 1, function __57(_) { var __frame = { name: '__57', line: 747 }; return __func(_, this, arguments, __57, 0, __frame, function __$__57() { + evalTest(function f(_) { var results; var __frame = { name: 'f', line: 748 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return twoResults('abc', 'def', __cb(_, __frame, 1, 0, function ___(__0, __1) { results = __1; + return _(null, results.join('-')); }, true, true)); }); }, 'abc-def'); + _(); }); }); + + +asyncTest('multiple results with future', 1, function __58(_) { var __frame = { name: '__58', line: 754 }; return __func(_, this, arguments, __58, 0, __frame, function __$__58() { + evalTest(function f(_) { var results; + function wrapper(a, b, _) { var __frame = { name: 'wrapper', line: 756 }; return __func(_, this, arguments, wrapper, 2, __frame, function __$wrapper() { return twoResults(a, b, __cb(_, __frame, 0, 0, _, true, true)); }); } var __frame = { name: 'f', line: 755 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return wrapper('abc', 'def', false)(__cb(_, __frame, 2, 0, function ___(__0, __1) { results = __1; + return _(null, results.join('-')); }, true, false)); }); }, 'abc-def'); + _(); }); }); + + +asyncTest('multiple results synchronously', 1, function __59(_) { var __frame = { name: '__59', line: 762 }; return __func(_, this, arguments, __59, 0, __frame, function __$__59() { + evalTest(function f(_) { var results; var __frame = { name: 'f', line: 763 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return twoResultsSync('abc', 'def', __cb(_, __frame, 1, 0, function ___(__0, __1) { results = __1; + return _(null, results.join('-')); }, true, true)); }); }, 'abc-def'); + _(); }); }); + + +asyncTest('this in futures', 2, function __60(_) { var c; var __frame = { name: '__60', line: 769 }; return __func(_, this, arguments, __60, 0, __frame, function __$__60() { c = { v: 1, test: function test__1(_) { + + + var __this = this; var __frame = { name: 'test__1', line: 772 }; return __func(_, this, arguments, test__1, 0, __frame, function __$test__1() { return _(null, __this.v); }); } }; + + return c.test(__cb(_, __frame, 5, 0, function ___(__0, __2) { strictEqual(__2, 1, 'direct call'); + return c.test(false)(__cb(_, __frame, 6, 0, function ___(__0, __3) { strictEqual(__3, 1, 'future call'); + start(); _(); }, true, false)); }, true, false)); }); }); + + +asyncTest('arity of async functions', 3, function __61(_) { var f, g; var __frame = { name: '__61', line: 779 }; return __func(_, this, arguments, __61, 0, __frame, function __$__61() { f = function __1(_, a, b, c, d, e, f, g, h, i) { + var __frame = { name: '__1', line: 780 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return _(null, a + b); }); }; g = function __2(_, a) { + var __frame = { name: '__2', line: 781 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return f(__cb(_, __frame, 0, 0, _, true, false), 1, 2); }); }; + strictEqual(f.length, 10, 'f.length === 10'); + strictEqual(g.length, 2, 'g.length === 2'); + return g(__cb(_, __frame, 5, 0, function ___(__0, __3) { strictEqual(__3, 3, 'g(_) === 3'); + start(); _(); }, true, false)); }); }); + + +asyncTest('futures on _(fn, idx)', 1, function __62(_) { var f, fut; var __frame = { name: '__62', line: 788 }; return __func(_, this, arguments, __62, 0, __frame, function __$__62() { f = __rt.streamlinify(function (i, cb) { + + setTimeout(function () { + cb(null, i + 1); }, 0); }, 1); + + fut = f(5, false); + + return fut(__cb(_, __frame, 7, 0, function ___(__0, __1) { strictEqual(__1, 6, 'fut(_) === 6'); + start(); _(); }, true, false)); }); }); + + +asyncTest('do while', 1, function __63(_) { var i, s, v; + + function read(_) { var __frame = { name: 'read', line: 801 }; return __func(_, this, arguments, read, 0, __frame, function __$read() { + return delay(__cb(_, __frame, 1, 0, _, true, false), ++i); }); } var __frame = { name: '__63', line: 799 }; return __func(_, this, arguments, __63, 0, __frame, function __$__63() { i = 0; s = ''; + + + return read(__cb(_, __frame, 6, 0, function ___(__0, __3) { v = __3; + var __1 = true; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__63() { __more = false; return function __$__63(_) { return function __$__63(_) { var __2 = __1; if (__2) { return _(null, __2); } - strictEqual(__this, that); - return delay(__cb(_, __frame, 13, 0, _, true, false), 'a=' + a + ', b=' + b + ', c=' + c); }); }.apply(this, args); } var __frame = { name: '__66', line: 854 }; return __func(_, this, arguments, __66, 0, __frame, function __$__66() { that = {}; - - return fn.call(that, 3, 1, __cb(_, __frame, 18, 0, function ___(__0, __1) { r = __1; - strictEqual(r, 'a=3, b=1, c=5'); f = fn.call(that); - + return read(__cb(_, __frame, 9, 0, function ___(__0, __4) { var __3 = (v = __4) < 5; return _(null, __3); }, true, false)); }(__cb(_, __frame, 7, 0, _, true, false)); }(__cb(_, __frame, 7, 0, function ___(__0, __5) { if (__5) { __1 = false; s += v; while (__more) { __loop(); } __more = true; } else { __break(); } }, true, false)); }); do { __loop(); } while (__more); __more = true; }(function __$__63() { + strictEqual(s, '1234'); + start(); _(); }); }, true, false)); }); }); + + +asyncTest('return undefined', 1, function __64(_) { + function read(_) { var __frame = { name: 'read', line: 814 }; return __func(_, this, arguments, read, 0, __frame, function __$read() { + return delay(__cb(_, __frame, 1, 0, _, true, false), 1); }); } + + function f(_) { var __frame = { name: 'f', line: 817 }; return __func(_, this, arguments, f, 0, __frame, function __$f() { + return read(__cb(_, __frame, 1, 0, function __$f() { _(); }, true, false)); }); } var __frame = { name: '__64', line: 813 }; return __func(_, this, arguments, __64, 0, __frame, function __$__64() { + + return f(__cb(_, __frame, 7, 0, function ___(__0, __1) { strictEqual(__1, undefined); + start(); _(); }, true, false)); }); }); + + +if (typeof require !== 'undefined') { + var globals = require('streamline/lib/globals'); + var isFast = /-fast$/.test(globals.runtime); + + if (globals.Promise) asyncTest('promises', isFast ? 3 : 7, function __65(_) { var p1, p2, p3, p4; + function test(v, _) { var __frame = { name: 'test', line: 829 }; return __func(_, this, arguments, test, 1, __frame, function __$test() { + return delay(__cb(_, __frame, 1, 0, _, true, false), v); }); } var __frame = { name: '__65', line: 828 }; return __func(_, this, arguments, __65, 0, __frame, function __$__65() { + + return function __$__65(__then) { if (!isFast) { p1 = test('a'); + p2 = test('b', null); - strictEqual(f, undefined); - strictEqual(got, undefined); - return delay(__cb(_, __frame, 24, 0, function __$__66() { - strictEqual(got, 'a=2, b=undefined, c=5'); - fn.call(that, 8, 3); - return delay(__cb(_, __frame, 27, 0, function __$__66() { - strictEqual(got, 'a=8, b=3, c=5'); - start(); _(); }, true, false)); }, true, false)); }, true, false)); }); }); } + strictEqual(p1 && typeof p1.then, 'function'); + strictEqual(p2 && typeof p2.then, 'function'); + return __pthen(p1, 'then', __cb(_, __frame, 9, 0, function ___(__0, __1) { strictEqual(__1, 'a'); + return __pthen(p2, 'then', __cb(_, __frame, 10, 0, function ___(__0, __2) { strictEqual(__2, 'b'); __then(); }, true, false)); }, true, false)); } else { __then(); } }(function __$__65() { p3 = test('c', null); + + + strictEqual(p3 && typeof p3.then, 'function'); + return __pthen(p3, 'then', __cb(_, __frame, 14, 0, function ___(__0, __3) { strictEqual(__3, 'c'); + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$__65() { p4 = delayFail(null, 'ERR d'); + + return __pthen(p4, 'then', __cb(_, __frame, 17, 0, function __$__65() { + ok(false); __then(); }, true, false)); }); }(function ___(ex, __result) { + __catch(function __$__65() { if (ex) { + strictEqual(ex, 'ERR d'); __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$__65() { + + start(); _(); }); }); }, true, false)); }); }); }); - asyncTest('IIFE bug in fibers mode', 1, function __67(_) { var api; var __frame = { name: '__67', line: 887 }; return __func(_, this, arguments, __67, 0, __frame, function __$__67() { - return function ___closure(_) { - function foo(_) { var __frame = { name: 'foo', line: 889 }; return __func(_, this, arguments, foo, 0, __frame, function __$foo() { - return _(null, 1); }); } - - return _(null, { foo: foo }); }(__cb(_, __frame, 1, 0, function ___(__0, __1) { - api = __1; - + if (!isFast) asyncTest('coffeescript default values', 8, function __66(_) { var got, that, r, f; + + + function fn(a, b, cb, c) { var args = Array.prototype.slice.call(arguments, 0); + if (a == null) { + args[0] = 2; } - return api.foo(__cb(_, __frame, 9, 0, function ___(__0, __2) { strictEqual(__2, 1); - start(); _(); }, true, false)); }, true, false)); }); }); - - - - - false && asyncTest('futures on non-streamline APIs', 1, function __68(_) { var fut; - function nat(cb) { - setImmediate(function () { - cb(null, 'abc'); }); } var __frame = { name: '__68', line: 902 }; return __func(_, this, arguments, __68, 0, __frame, function __$__68() { fut = nat(false); + if (cb == null) { + args[2] = function (e, r) { + got = r; }; } return function __1(a, b, _, c) { var __this = this; var __frame = { name: '__1', line: 857 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() { + + + if (c == null) { + c = 5; } + + strictEqual(__this, that); + return delay(__cb(_, __frame, 13, 0, _, true, false), 'a=' + a + ', b=' + b + ', c=' + c); }); }.apply(this, args); } var __frame = { name: '__66', line: 854 }; return __func(_, this, arguments, __66, 0, __frame, function __$__66() { that = {}; + + return fn.call(that, 3, 1, __cb(_, __frame, 18, 0, function ___(__0, __1) { r = __1; + strictEqual(r, 'a=3, b=1, c=5'); f = fn.call(that); + + + strictEqual(f, undefined); + strictEqual(got, undefined); + return delay(__cb(_, __frame, 24, 0, function __$__66() { + strictEqual(got, 'a=2, b=undefined, c=5'); + fn.call(that, 8, 3); + return delay(__cb(_, __frame, 27, 0, function __$__66() { + strictEqual(got, 'a=8, b=3, c=5'); + start(); _(); }, true, false)); }, true, false)); }, true, false)); }); }); } + + + +asyncTest('IIFE bug in fibers mode', 1, function __67(_) { var api; var __frame = { name: '__67', line: 887 }; return __func(_, this, arguments, __67, 0, __frame, function __$__67() { + return function ___closure(_) { + function foo(_) { var __frame = { name: 'foo', line: 889 }; return __func(_, this, arguments, foo, 0, __frame, function __$foo() { + return _(null, 1); }); } + return _(null, { foo: foo }); }(__cb(_, __frame, 1, 0, function ___(__0, __1) { + api = __1; - return fut(__cb(_, __frame, 7, 0, function ___(__0, __1) { strictEqual(__1, 'abc'); - start(); _(); }, true, false)); }); }); \ No newline at end of file + return api.foo(__cb(_, __frame, 9, 0, function ___(__0, __2) { strictEqual(__2, 1); + start(); _(); }, true, false)); }, true, false)); }); }); + + + + +false && asyncTest('futures on non-streamline APIs', 1, function __68(_) { var fut; + function nat(cb) { + setImmediate(function () { + cb(null, 'abc'); }); } var __frame = { name: '__68', line: 902 }; return __func(_, this, arguments, __68, 0, __frame, function __$__68() { fut = nat(false); + + + + return fut(__cb(_, __frame, 7, 0, function ___(__0, __1) { strictEqual(__1, 'abc'); + start(); _(); }, true, false)); }); }); \ No newline at end of file diff --git a/test/common/callbacks/flows-test.js b/test/common/callbacks/flows-test.js index bc072612..7b400ea1 100644 --- a/test/common/callbacks/flows-test.js +++ b/test/common/callbacks/flows-test.js @@ -1,465 +1,465 @@ -/*** 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); - 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() { - return flows.nextTick(__cb(_, __frame, 1, 0, function __$delay() { - return _(null, val); }, true, false)); }); } - - - function delayFail(_, err) { var __frame = { name: 'delayFail', line: 9 }; return __func(_, this, arguments, delayFail, 0, __frame, function __$delayFail() { - return flows.nextTick(__cb(_, __frame, 1, 0, function __$delayFail() { - return _(err); }, true, false)); }); } - - - function sparse() { - var a = []; - a[3] = 33; - a[4] = 44; - a[9] = 99; - return a; } - - - function dump(a) { - return a.reduce(function (s, v) { - return s + '/' + v; }, ''); } - - - - asyncTest('each', 7, function __1(_) { var result; var __frame = { name: '__1', line: 28 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { result = 1; +/*** 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); +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() { + return flows.nextTick(__cb(_, __frame, 1, 0, function __$delay() { + return _(null, val); }, true, false)); }); } + + +function delayFail(_, err) { var __frame = { name: 'delayFail', line: 9 }; return __func(_, this, arguments, delayFail, 0, __frame, function __$delayFail() { + return flows.nextTick(__cb(_, __frame, 1, 0, function __$delayFail() { + return _(err); }, true, false)); }); } + + +function sparse() { + var a = []; + a[3] = 33; + a[4] = 44; + a[9] = 99; + return a; } + + +function dump(a) { + return a.reduce(function (s, v) { + return s + '/' + v; }, ''); } + + + +asyncTest('each', 7, function __1(_) { var result; var __frame = { name: '__1', line: 28 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { result = 1; + + return flows.each(__cb(_, __frame, 2, 0, function __$__1() { + - return flows.each(__cb(_, __frame, 2, 0, function __$__1() { + strictEqual(result, 24); + result = 1; + return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 7, 0, function __$__1() { + strictEqual(result, 24); result = 1; - return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 7, 0, function __$__1() { + return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 13, 0, function __$__1() { strictEqual(result, 24); result = 1; - return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 13, 0, function __$__1() { + return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 19, 0, function __$__1() { + + strictEqual(result, 24); result = 1; - return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 19, 0, function __$__1() { - - + return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 27, 0, function __$__1() { strictEqual(result, 24); - result = 1; - return [ 1, 2, 3, 4 ].forEach_(__cb(_, __frame, 27, 0, function __$__1() { + result = ''; + return sparse().forEach_(__cb(_, __frame, 33, 0, function __$__1() { - strictEqual(result, 24); + strictEqual(result, '/3:33/4:44/9:99'); result = ''; - return sparse().forEach_(__cb(_, __frame, 33, 0, function __$__1() { + return sparse().forEach_(__cb(_, __frame, 39, 0, function __$__1() { strictEqual(result, '/3:33/4:44/9:99'); - result = ''; - return sparse().forEach_(__cb(_, __frame, 39, 0, function __$__1() { - - - - strictEqual(result, '/3:33/4:44/9:99'); - start(); _(); }, true, false), -1, function __7(_, val, i) { var v; var __frame = { name: '__7', line: 67 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result + '/' + i + ':' + v; _(); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var v; var __frame = { name: '__6', line: 61 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result + '/' + i + ':' + v; _(); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var v; var __frame = { name: '__5', line: 55 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var v; var __frame = { name: '__4', line: 49 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var v; var __frame = { name: '__3', line: 41 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), function __2(_, val) { var v; var __frame = { name: '__2', line: 35 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 30 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { result = result * __1; _(); }, true, false), val); }); }); }); }); - - asyncTest('map', 9, function __2(_) { var result; var __frame = { name: '__2', line: 74 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { - return flows.map(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + start(); _(); }, true, false), -1, function __7(_, val, i) { var v; var __frame = { name: '__7', line: 67 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result + '/' + i + ':' + v; _(); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var v; var __frame = { name: '__6', line: 61 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result + '/' + i + ':' + v; _(); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var v; var __frame = { name: '__5', line: 55 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var v; var __frame = { name: '__4', line: 49 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var v; var __frame = { name: '__3', line: 41 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), function __2(_, val) { var v; var __frame = { name: '__2', line: 35 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; result = result * v; _(); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 30 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { result = result * __1; _(); }, true, false), val); }); }); }); }); + +asyncTest('map', 9, function __2(_) { var result; var __frame = { name: '__2', line: 74 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { + return flows.map(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + + + deepEqual(result, [ 2, 4, 6, 8 ]); + return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; deepEqual(result, [ 2, 4, 6, 8 ]); - return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; + return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; deepEqual(result, [ 2, 4, 6, 8 ]); - return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; + return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; + + deepEqual(result, [ 2, 4, 6, 8 ]); - return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; - - + return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; deepEqual(result, [ 2, 4, 6, 8 ]); - return [ 1, 2, 3, 4 ].map_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; + return sparse().map_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + - deepEqual(result, [ 2, 4, 6, 8 ]); - return sparse().map_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + strictEqual(result.length, 10); + strictEqual(dump(result), '/3:33/4:44/9:99'); + return sparse().map_(__cb(_, __frame, 29, 0, function ___(__0, __14) { result = __14; strictEqual(result.length, 10); strictEqual(dump(result), '/3:33/4:44/9:99'); - return sparse().map_(__cb(_, __frame, 29, 0, function ___(__0, __14) { result = __14; - - - - strictEqual(result.length, 10); - strictEqual(dump(result), '/3:33/4:44/9:99'); - start(); _(); }, true, false), -1, function __7(_, val, i) { var v; var __frame = { name: '__7', line: 103 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; return _(null, i + ':' + v); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var v; var __frame = { name: '__6', line: 97 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; return _(null, i + ':' + v); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 93 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 89 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 83 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 79 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 75 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }); }); - - asyncTest('filter', 9, function __3(_) { var result; var __frame = { name: '__3', line: 111 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { - return flows.filter(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + start(); _(); }, true, false), -1, function __7(_, val, i) { var v; var __frame = { name: '__7', line: 103 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; return _(null, i + ':' + v); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var v; var __frame = { name: '__6', line: 97 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __1) { v = __1; return _(null, i + ':' + v); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 93 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 89 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 83 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 79 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 75 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = 2 * __2; return _(null, __1); }, true, false), val); }); }); }); }); + +asyncTest('filter', 9, function __3(_) { var result; var __frame = { name: '__3', line: 111 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { + return flows.filter(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + + + deepEqual(result, [ 1, 3 ]); + return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; deepEqual(result, [ 1, 3 ]); - return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; + return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; deepEqual(result, [ 1, 3 ]); - return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; + return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; + + deepEqual(result, [ 1, 3 ]); - return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; - - + return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; deepEqual(result, [ 1, 3 ]); - return [ 1, 2, 3, 4 ].filter_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; + return sparse().filter_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; - deepEqual(result, [ 1, 3 ]); - return sparse().filter_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + strictEqual(result.length, 2); + deepEqual(result, [ 33, 99 ]); + return sparse().filter_(__cb(_, __frame, 28, 0, function ___(__0, __14) { result = __14; strictEqual(result.length, 2); deepEqual(result, [ 33, 99 ]); - return sparse().filter_(__cb(_, __frame, 28, 0, function ___(__0, __14) { result = __14; - - - strictEqual(result.length, 2); - deepEqual(result, [ 33, 99 ]); - start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 139 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 134 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 130 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 126 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 120 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 116 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 112 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }); }); - - asyncTest('every true', 7, function __4(_) { var result; var __frame = { name: '__4', line: 146 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { - return flows.every(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 139 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 134 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 130 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 126 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 120 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 116 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 112 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 % 2; return _(null, __1); }, true, false), val); }); }); }); }); + +asyncTest('every true', 7, function __4(_) { var result; var __frame = { name: '__4', line: 146 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { + return flows.every(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + + + strictEqual(result, true); + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; strictEqual(result, true); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; strictEqual(result, true); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; + + strictEqual(result, true); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; - - + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; strictEqual(result, true); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; + return sparse().every_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; strictEqual(result, true); - return sparse().every_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + return sparse().every_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; strictEqual(result, true); - return sparse().every_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; - - - strictEqual(result, true); - start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 173 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 169 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 165 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 161 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 155 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 151 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 147 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }); }); - - asyncTest('every false', 7, function __5(_) { var result; var __frame = { name: '__5', line: 179 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { - return flows.every(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 173 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 169 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 165 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 161 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 155 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 151 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 147 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 5; return _(null, __1); }, true, false), val); }); }); }); }); + +asyncTest('every false', 7, function __5(_) { var result; var __frame = { name: '__5', line: 179 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { + return flows.every(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + + + strictEqual(result, false); + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; strictEqual(result, false); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; strictEqual(result, false); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; + + strictEqual(result, false); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; - - + return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; strictEqual(result, false); - return [ 1, 2, 3, 4 ].every_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; + return sparse().every_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; strictEqual(result, false); - return sparse().every_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + return sparse().every_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; strictEqual(result, false); - return sparse().every_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; - - - strictEqual(result, false); - start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 206 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 40; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 202 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 40; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 198 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 194 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 188 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 184 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 180 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }); }); - - asyncTest('some true', 7, function __6(_) { var result; var __frame = { name: '__6', line: 212 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { - return flows.some(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 206 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 40; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 202 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 40; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 198 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 194 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 188 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 184 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 180 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }); }); + +asyncTest('some true', 7, function __6(_) { var result; var __frame = { name: '__6', line: 212 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { + return flows.some(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + + + strictEqual(result, true); + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; strictEqual(result, true); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; strictEqual(result, true); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; + + strictEqual(result, true); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; - - + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; strictEqual(result, true); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; + return sparse().some_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; strictEqual(result, true); - return sparse().some_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + return sparse().some_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; strictEqual(result, true); - return sparse().some_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; - - - strictEqual(result, true); - start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 239 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 235 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 231 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 227 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 221 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 217 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 213 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }); }); - - asyncTest('some false', 7, function __7(_) { var result; var __frame = { name: '__7', line: 245 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { - return flows.some(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 239 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 235 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 > 30; return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 231 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 227 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 221 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 217 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 213 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 3; return _(null, __1); }, true, false), val); }); }); }); }); + +asyncTest('some false', 7, function __7(_) { var result; var __frame = { name: '__7', line: 245 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { + return flows.some(__cb(_, __frame, 1, 0, function ___(__0, __8) { result = __8; + + + strictEqual(result, false); + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; strictEqual(result, false); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 5, 0, function ___(__0, __9) { result = __9; + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; strictEqual(result, false); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 9, 0, function ___(__0, __10) { result = __10; + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; + + strictEqual(result, false); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 13, 0, function ___(__0, __11) { result = __11; - - + return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; strictEqual(result, false); - return [ 1, 2, 3, 4 ].some_(__cb(_, __frame, 19, 0, function ___(__0, __12) { result = __12; + return sparse().some_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; strictEqual(result, false); - return sparse().some_(__cb(_, __frame, 23, 0, function ___(__0, __13) { result = __13; + return sparse().some_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; strictEqual(result, false); - return sparse().some_(__cb(_, __frame, 27, 0, function ___(__0, __14) { result = __14; - - - strictEqual(result, false); - start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 272 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = !(__2 > 20); return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 268 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = !(__2 > 20); return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 264 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 260 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 254 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 250 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 246 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }); }); - - asyncTest('reduce', 3, function __8(_) { var result; var __frame = { name: '__8', line: 278 }; return __func(_, this, arguments, __8, 0, __frame, function __$__8() { - return flows.reduce(__cb(_, __frame, 1, 0, function ___(__0, __4) { result = __4; + start(); _(); }, true, false), -1, function __7(_, val, i) { var __frame = { name: '__7', line: 272 }; return __func(_, this, arguments, __7, 0, __frame, function __$__7() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = !(__2 > 20); return _(null, __1); }, true, false), val); }); }); }, true, false), function __6(_, val, i) { var __frame = { name: '__6', line: 268 }; return __func(_, this, arguments, __6, 0, __frame, function __$__6() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = !(__2 > 20); return _(null, __1); }, true, false), val); }); }); }, true, false), -1, function __5(_, val) { var __frame = { name: '__5', line: 264 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), { parallel: 2 }, function __4(_, val) { var __frame = { name: '__4', line: 260 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), 2, function __3(_, val) { var __frame = { name: '__3', line: 254 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), function __2(_, val) { var __frame = { name: '__2', line: 250 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }, true, false), [ 1, 2, 3, 4 ], function __1(_, val) { var __frame = { name: '__1', line: 246 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = __2 < 0; return _(null, __1); }, true, false), val); }); }); }); }); + +asyncTest('reduce', 3, function __8(_) { var result; var __frame = { name: '__8', line: 278 }; return __func(_, this, arguments, __8, 0, __frame, function __$__8() { + return flows.reduce(__cb(_, __frame, 1, 0, function ___(__0, __4) { result = __4; + + + strictEqual(result, 24); + return [ 1, 2, 3, 4 ].reduce_(__cb(_, __frame, 5, 0, function ___(__0, __5) { result = __5; strictEqual(result, 24); - return [ 1, 2, 3, 4 ].reduce_(__cb(_, __frame, 5, 0, function ___(__0, __5) { result = __5; + return sparse().reduce_(__cb(_, __frame, 9, 0, function ___(__0, __6) { result = __6; - strictEqual(result, 24); - return sparse().reduce_(__cb(_, __frame, 9, 0, function ___(__0, __6) { result = __6; - - - strictEqual(result, '/33/44/99'); - start(); _(); }, true, false), function __3(_, v, val) { var __frame = { name: '__3', line: 287 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v + '/' + __2; return _(null, __1); }, true, false), val); }); }, ''); }, true, false), function __2(_, v, val) { var __frame = { name: '__2', line: 283 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }, true, false), [ 1, 2, 3, 4 ], function __1(_, v, val) { var __frame = { name: '__1', line: 279 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }); }); - - asyncTest('reduceRight', 3, function __9(_) { var result; var __frame = { name: '__9', line: 293 }; return __func(_, this, arguments, __9, 0, __frame, function __$__9() { - return flows.reduceRight(__cb(_, __frame, 1, 0, function ___(__0, __4) { result = __4; + strictEqual(result, '/33/44/99'); + start(); _(); }, true, false), function __3(_, v, val) { var __frame = { name: '__3', line: 287 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v + '/' + __2; return _(null, __1); }, true, false), val); }); }, ''); }, true, false), function __2(_, v, val) { var __frame = { name: '__2', line: 283 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }, true, false), [ 1, 2, 3, 4 ], function __1(_, v, val) { var __frame = { name: '__1', line: 279 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }); }); + +asyncTest('reduceRight', 3, function __9(_) { var result; var __frame = { name: '__9', line: 293 }; return __func(_, this, arguments, __9, 0, __frame, function __$__9() { + return flows.reduceRight(__cb(_, __frame, 1, 0, function ___(__0, __4) { result = __4; + + + strictEqual(result, 24); + return [ 1, 2, 3, 4 ].reduceRight_(__cb(_, __frame, 5, 0, function ___(__0, __5) { result = __5; strictEqual(result, 24); - return [ 1, 2, 3, 4 ].reduceRight_(__cb(_, __frame, 5, 0, function ___(__0, __5) { result = __5; + return sparse().reduceRight_(__cb(_, __frame, 9, 0, function ___(__0, __6) { result = __6; - strictEqual(result, 24); - return sparse().reduceRight_(__cb(_, __frame, 9, 0, function ___(__0, __6) { result = __6; - - - strictEqual(result, '/99/44/33'); - start(); _(); }, true, false), function __3(_, v, val) { var __frame = { name: '__3', line: 302 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v + '/' + __2; return _(null, __1); }, true, false), val); }); }, ''); }, true, false), function __2(_, v, val) { var __frame = { name: '__2', line: 298 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }, true, false), [ 1, 2, 3, 4 ], function __1(_, v, val) { var __frame = { name: '__1', line: 294 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }); }); - - asyncTest('sort', 4, function __10(_) { var array; var __frame = { name: '__10', line: 308 }; return __func(_, this, arguments, __10, 0, __frame, function __$__10() { array = [ 1, 2, 3, 4 ]; + strictEqual(result, '/99/44/33'); + start(); _(); }, true, false), function __3(_, v, val) { var __frame = { name: '__3', line: 302 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v + '/' + __2; return _(null, __1); }, true, false), val); }); }, ''); }, true, false), function __2(_, v, val) { var __frame = { name: '__2', line: 298 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }, true, false), [ 1, 2, 3, 4 ], function __1(_, v, val) { var __frame = { name: '__1', line: 294 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, function ___(__0, __2) { var __1 = v * __2; return _(null, __1); }, true, false), val); }); }, 1); }); }); + +asyncTest('sort', 4, function __10(_) { var array; var __frame = { name: '__10', line: 308 }; return __func(_, this, arguments, __10, 0, __frame, function __$__10() { array = [ 1, 2, 3, 4 ]; + + return flows.sort(__cb(_, __frame, 2, 0, function __$__10() { + - return flows.sort(__cb(_, __frame, 2, 0, function __$__10() { + deepEqual(array, [ 1, 2, 3, 4 ], 'In order array sort ok'); + return array.sort_(__cb(_, __frame, 6, 0, function __$__10() { deepEqual(array, [ 1, 2, 3, 4 ], 'In order array sort ok'); - return array.sort_(__cb(_, __frame, 6, 0, function __$__10() { + array = [ 4, 3, 2, 1 ]; + return array.sort_(__cb(_, __frame, 11, 0, function __$__10() { - deepEqual(array, [ 1, 2, 3, 4 ], 'In order array sort ok'); - array = [ 4, 3, 2, 1 ]; - return array.sort_(__cb(_, __frame, 11, 0, function __$__10() { + deepEqual(array, [ 1, 2, 3, 4 ], 'Reverse array sort ok'); + array = [ 3, 1, 2, 4 ]; + return array.sort_(__cb(_, __frame, 16, 0, function __$__10() { - deepEqual(array, [ 1, 2, 3, 4 ], 'Reverse array sort ok'); - array = [ 3, 1, 2, 4 ]; - return array.sort_(__cb(_, __frame, 16, 0, function __$__10() { - - - deepEqual(array, [ 1, 2, 3, 4 ], 'Random array sort ok'); - start(); _(); }, true, false), function __4(_, a, b) { var __frame = { name: '__4', line: 324 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }, true, false), function __3(_, a, b) { var __frame = { name: '__3', line: 319 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }, true, false), function __2(_, a, b) { var __frame = { name: '__2', line: 314 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }, true, false), array, function __1(_, a, b) { var __frame = { name: '__1', line: 310 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }); }); + deepEqual(array, [ 1, 2, 3, 4 ], 'Random array sort ok'); + start(); _(); }, true, false), function __4(_, a, b) { var __frame = { name: '__4', line: 324 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }, true, false), function __3(_, a, b) { var __frame = { name: '__3', line: 319 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }, true, false), function __2(_, a, b) { var __frame = { name: '__2', line: 314 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }, true, false), array, function __1(_, a, b) { var __frame = { name: '__1', line: 310 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return delay(__cb(_, __frame, 1, 0, _, true, false), a - b); }); }); }); }); + +asyncTest('collectAll', 4, function __11(_) { var total, peak, count, results; - asyncTest('collectAll', 4, function __11(_) { var total, peak, count, results; - + + + + function doIt(i) { + return function __1(_) { var __frame = { name: '__1', line: 336 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + count++; + peak = Math.max(count, peak); + return setTimeout(__cb(_, __frame, 3, 0, function __$__1() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { total = __1 + total; + count--; + return _(null, 2 * i); }, true, false), i); }, true, false), 10); }); }; } var __frame = { name: '__11', line: 330 }; return __func(_, this, arguments, __11, 0, __frame, function __$__11() { total = 0; peak = 0; count = 0; - function doIt(i) { - return function __1(_) { var __frame = { name: '__1', line: 336 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - count++; - peak = Math.max(count, peak); - return setTimeout(__cb(_, __frame, 3, 0, function __$__1() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { total = __1 + total; - count--; - return _(null, 2 * i); }, true, false), i); }, true, false), 10); }); }; } var __frame = { name: '__11', line: 330 }; return __func(_, this, arguments, __11, 0, __frame, function __$__11() { total = 0; peak = 0; count = 0; - - - - return flows.spray([ doIt(1), doIt(2), doIt(3) ]).collectAll(__cb(_, __frame, 16, 0, function ___(__0, __1) { results = __1; - equal(total, 6); - ok(peak >= 2); - equal(count, 0); - deepEqual(results, [ 2, 4, 6 ]); - start(); _(); }, true, false)); }); }); + return flows.spray([ doIt(1), doIt(2), doIt(3) ]).collectAll(__cb(_, __frame, 16, 0, function ___(__0, __1) { results = __1; + equal(total, 6); + ok(peak >= 2); + equal(count, 0); + deepEqual(results, [ 2, 4, 6 ]); + start(); _(); }, true, false)); }); }); + +asyncTest('collectOne', 4, function __12(_) { var total, peak, count, result; - asyncTest('collectOne', 4, function __12(_) { var total, peak, count, result; - + + + + function doIt(i) { + return function __1(_) { var __frame = { name: '__1', line: 359 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + count++; + peak = Math.max(count, peak); + return setTimeout(__cb(_, __frame, 3, 0, function __$__1() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { total = __1 + total; + count--; + return _(null, 2 * i); }, true, false), i); }, true, false), 10); }); }; } var __frame = { name: '__12', line: 353 }; return __func(_, this, arguments, __12, 0, __frame, function __$__12() { total = 0; peak = 0; count = 0; - function doIt(i) { - return function __1(_) { var __frame = { name: '__1', line: 359 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - count++; - peak = Math.max(count, peak); - return setTimeout(__cb(_, __frame, 3, 0, function __$__1() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { total = __1 + total; - count--; - return _(null, 2 * i); }, true, false), i); }, true, false), 10); }); }; } var __frame = { name: '__12', line: 353 }; return __func(_, this, arguments, __12, 0, __frame, function __$__12() { total = 0; peak = 0; count = 0; - - - - return flows.spray([ doIt(1), doIt(2), doIt(3) ]).collectOne(__cb(_, __frame, 16, 0, function ___(__0, __1) { result = __1; - ok(total == 1 || total == 2); - ok(peak >= 2); - ok(count > 0); - ok(result == 2 || result == 4); - start(); _(); }, true, false)); }); }); + return flows.spray([ doIt(1), doIt(2), doIt(3) ]).collectOne(__cb(_, __frame, 16, 0, function ___(__0, __1) { result = __1; + ok(total == 1 || total == 2); + ok(peak >= 2); + ok(count > 0); + ok(result == 2 || result == 4); + start(); _(); }, true, false)); }); }); + +asyncTest('collectAll with limit', 1, function __13(_) { var total, peak, count, results; - asyncTest('collectAll with limit', 1, function __13(_) { var total, peak, count, results; - + + + + function doIt(i) { + return function __1(_) { var __frame = { name: '__1', line: 382 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + count++; + peak = Math.max(count, peak); + return setTimeout(__cb(_, __frame, 3, 0, function __$__1() { + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { total = __1 + total; + count--; + return _(null, 2 * i); }, true, false), i); }, true, false), 10); }); }; } var __frame = { name: '__13', line: 376 }; return __func(_, this, arguments, __13, 0, __frame, function __$__13() { total = 0; peak = 0; count = 0; - function doIt(i) { - return function __1(_) { var __frame = { name: '__1', line: 382 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - count++; - peak = Math.max(count, peak); - return setTimeout(__cb(_, __frame, 3, 0, function __$__1() { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { total = __1 + total; - count--; - return _(null, 2 * i); }, true, false), i); }, true, false), 10); }); }; } var __frame = { name: '__13', line: 376 }; return __func(_, this, arguments, __13, 0, __frame, function __$__13() { total = 0; peak = 0; count = 0; - + return flows.spray([ doIt(1), doIt(2), doIt(3) ], 2).collectAll(__cb(_, __frame, 16, 0, function ___(__0, __1) { results = __1; + deepEqual([ total, peak, count, results ], [ 6, 2, 0, [ 2, 4, 6 ] ]); + start(); _(); }, true, false)); }); }); + +asyncTest('contexts', 3, function __14(_) { var result; + function testContext(_, x) { var y; var __frame = { name: 'testContext', line: 397 }; return __func(_, this, arguments, testContext, 0, __frame, function __$testContext() { + flows.setContext({ val: x }); - return flows.spray([ doIt(1), doIt(2), doIt(3) ], 2).collectAll(__cb(_, __frame, 16, 0, function ___(__0, __1) { results = __1; - deepEqual([ total, peak, count, results ], [ 6, 2, 0, [ 2, 4, 6 ] ]); - start(); _(); }, true, false)); }); }); - - asyncTest('contexts', 3, function __14(_) { var result; - function testContext(_, x) { var y; var __frame = { name: 'testContext', line: 397 }; return __func(_, this, arguments, testContext, 0, __frame, function __$testContext() { - flows.setContext({ val: x }); + return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { y = __1; + strictEqual(y, 2 * flows.getContext().val); + return _(null, y + 1); }, true, false), 2 * x); }); } var __frame = { name: '__14', line: 396 }; return __func(_, this, arguments, __14, 0, __frame, function __$__14() { + + + return flows.spray([ function __1(_) { + + var __frame = { name: '__1', line: 408 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return testContext(__cb(_, __frame, 1, 0, _, true, false), 3); }); }, function __2(_) { - return delay(__cb(_, __frame, 4, 0, function ___(__0, __1) { y = __1; - strictEqual(y, 2 * flows.getContext().val); - return _(null, y + 1); }, true, false), 2 * x); }); } var __frame = { name: '__14', line: 396 }; return __func(_, this, arguments, __14, 0, __frame, function __$__14() { + var __frame = { name: '__2', line: 412 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { + return testContext(__cb(_, __frame, 1, 0, _, true, false), 5); }); } ]).collectAll(__cb(_, __frame, 20, 0, function ___(__0, __3) { - return flows.spray([ function __1(_) { - - var __frame = { name: '__1', line: 408 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return testContext(__cb(_, __frame, 1, 0, _, true, false), 3); }); }, function __2(_) { - - - var __frame = { name: '__2', line: 412 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { - return testContext(__cb(_, __frame, 1, 0, _, true, false), 5); }); } ]).collectAll(__cb(_, __frame, 20, 0, function ___(__0, __3) { - - - result = __3; - deepEqual(result, [ 7, 11 ]); - start(); _(); }, true, false)); }); }); + result = __3; + deepEqual(result, [ 7, 11 ]); + start(); _(); }, true, false)); }); }); + + +asyncTest('futures multiplex', 3, function __15(_) { var result1, result2, result3, f1, f10; - asyncTest('futures multiplex', 3, function __15(_) { var result1, result2, result3, f1, f10; + + + function doIt(future, _) { var __frame = { name: 'doIt', line: 426 }; return __func(_, this, arguments, doIt, 1, __frame, function __$doIt() { + return future(__cb(_, __frame, 1, 0, function ___(__0, __1) { result1 = __1 + result1; + return future(__cb(_, __frame, 2, 0, function ___(__0, __2) { result2 = __2 + result2; + return delay(__cb(_, __frame, 3, 0, function __$doIt() { + return future(__cb(_, __frame, 4, 0, function ___(__0, __3) { result3 = __3 + result3; _(); }, true, false)); }, true, false)); }, true, false)); }, true, false)); }); } var __frame = { name: '__15', line: 421 }; return __func(_, this, arguments, __15, 0, __frame, function __$__15() { result1 = 0; result2 = 0; result3 = 0; f1 = delay(false, 1); + f10 = delay(false, 10); - function doIt(future, _) { var __frame = { name: 'doIt', line: 426 }; return __func(_, this, arguments, doIt, 1, __frame, function __$doIt() { - return future(__cb(_, __frame, 1, 0, function ___(__0, __1) { result1 = __1 + result1; - return future(__cb(_, __frame, 2, 0, function ___(__0, __2) { result2 = __2 + result2; - return delay(__cb(_, __frame, 3, 0, function __$doIt() { - return future(__cb(_, __frame, 4, 0, function ___(__0, __3) { result3 = __3 + result3; _(); }, true, false)); }, true, false)); }, true, false)); }, true, false)); }); } var __frame = { name: '__15', line: 421 }; return __func(_, this, arguments, __15, 0, __frame, function __$__15() { result1 = 0; result2 = 0; result3 = 0; f1 = delay(false, 1); - - - f10 = delay(false, 10); - - - return flows.collect(__cb(_, __frame, 15, 0, function __$__15() { - - deepEqual(result1, 12); - deepEqual(result2, 12); - deepEqual(result3, 12); - start(); _(); }, true, false), [ doIt(f1, false), doIt(f10, false), doIt(f1, false) ]); }); }); - - - asyncTest('trampoline', 1, function __16(_) { - function sums(_, n) { var fn; var __frame = { name: 'sums', line: 445 }; return __func(_, this, arguments, sums, 0, __frame, function __$sums() { fn = function __1(_) { - var __frame = { name: '__1', line: 446 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return function __$__1(_) { var __1 = n > 0; return function __$__1(__then) { if (__1) { return sums(__cb(_, __frame, 1, 0, function ___(__0, __3) { var __2 = n + __3; return _(null, __2); }, true, false), n - 1); } else { __then(); } }(function __$__1() { return _(null, 0); }); }(__cb(_, __frame, 0, 0, _, true, false)); }); }; - - return function __$sums(__then) { if (n % 1000 === 0) { return flows.trampoline(__cb(_, __frame, 4, 0, _, true, false), fn); } else { - return fn(__cb(_, __frame, 5, 0, _, true, false)); } }(_); }); } var __frame = { name: '__16', line: 444 }; return __func(_, this, arguments, __16, 0, __frame, function __$__16() { + return flows.collect(__cb(_, __frame, 15, 0, function __$__15() { - return sums(__cb(_, __frame, 8, 0, function ___(__0, __1) { equals(__1, 50000 * 100001); - start(); _(); }, true, false), 100000); }); }); - - - asyncTest('trampoline preserves context', 2, function __17(_) { var globals, fn, result; var __frame = { name: '__17', line: 456 }; return __func(_, this, arguments, __17, 0, __frame, function __$__17() { globals = require('streamline/lib/globals'); - fn = function __1(_) { - var __frame = { name: '__1', line: 458 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return _(null, globals.context.val); }); }; + deepEqual(result1, 12); + deepEqual(result2, 12); + deepEqual(result3, 12); + start(); _(); }, true, false), [ doIt(f1, false), doIt(f10, false), doIt(f1, false) ]); }); }); + + +asyncTest('trampoline', 1, function __16(_) { + function sums(_, n) { var fn; var __frame = { name: 'sums', line: 445 }; return __func(_, this, arguments, sums, 0, __frame, function __$sums() { fn = function __1(_) { + var __frame = { name: '__1', line: 446 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return function __$__1(_) { var __1 = n > 0; return function __$__1(__then) { if (__1) { return sums(__cb(_, __frame, 1, 0, function ___(__0, __3) { var __2 = n + __3; return _(null, __2); }, true, false), n - 1); } else { __then(); } }(function __$__1() { return _(null, 0); }); }(__cb(_, __frame, 1, 0, _, true, false)); }); }; - globals.context.val = 'abc'; - return flows.trampoline(__cb(_, __frame, 6, 0, function ___(__0, __2) { result = __2; - strictEqual(result, 'abc'); - strictEqual(globals.context.val, 'abc'); - start(); _(); }, true, false), fn); }); }); \ No newline at end of file + return function __$sums(__then) { if (n % 1000 === 0) { return flows.trampoline(__cb(_, __frame, 4, 0, _, true, false), fn); } else { + return fn(__cb(_, __frame, 5, 0, _, true, false)); } }(_); }); } var __frame = { name: '__16', line: 444 }; return __func(_, this, arguments, __16, 0, __frame, function __$__16() { + + return sums(__cb(_, __frame, 8, 0, function ___(__0, __1) { equals(__1, 50000 * 100001); + start(); _(); }, true, false), 100000); }); }); + + +asyncTest('trampoline preserves context', 2, function __17(_) { var globals, fn, result; var __frame = { name: '__17', line: 456 }; return __func(_, this, arguments, __17, 0, __frame, function __$__17() { globals = require('streamline/lib/globals'); + fn = function __1(_) { + var __frame = { name: '__1', line: 458 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return _(null, globals.context.val); }); }; + + globals.context.val = 'abc'; + return flows.trampoline(__cb(_, __frame, 6, 0, function ___(__0, __2) { result = __2; + strictEqual(result, 'abc'); + strictEqual(globals.context.val, 'abc'); + start(); _(); }, true, false), fn); }); }); \ No newline at end of file diff --git a/test/common/callbacks/futures-test.js b/test/common/callbacks/futures-test.js index ae6a2c6c..f0660bf2 100644 --- a/test/common/callbacks/futures-test.js +++ b/test/common/callbacks/futures-test.js @@ -1,11 +1,11 @@ -/*** 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); - - 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() { - return _(null, val); }, true, false), millis); }); } - - - asyncTest('no timeout', 1, function __1(_) { var f; var __frame = { name: '__1', line: 8 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { f = delay(1, 'a', false); - - return f(__cb(_, __frame, 2, 0, function ___(__0, __1) { equals(__1, 'a', 'no timeout'); - start(); _(); }, true, false)); }); }); \ No newline at end of file +/*** 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); + +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() { + return _(null, val); }, true, false), millis); }); } + + +asyncTest('no timeout', 1, function __1(_) { var f; var __frame = { name: '__1', line: 8 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { f = delay(1, 'a', false); + + return f(__cb(_, __frame, 2, 0, function ___(__0, __1) { equals(__1, 'a', 'no timeout'); + start(); _(); }, true, false)); }); }); \ No newline at end of file diff --git a/test/common/callbacks/stack-test.js b/test/common/callbacks/stack-test.js index 0a929ff5..636d33b2 100644 --- a/test/common/callbacks/stack-test.js +++ b/test/common/callbacks/stack-test.js @@ -1,234 +1,234 @@ -/*** 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; - - - QUnit.module(module.id); - - var nextTick = __rt.streamlinify(function (cb) { - setTimeout(function () { - cb(); }, 0); }, 0); - - - - - - function failAsync(_, code) { var __frame = { name: 'failAsync', line: 14 }; return __func(_, this, arguments, failAsync, 0, __frame, function __$failAsync() { - return _(new Error(code)); }); } - - - function failSync(_, code) { - - function fail(dummy) { throw new Error(code); } var __frame = { name: 'failSync', line: 18 }; return __func(_, this, arguments, failSync, 0, __frame, function __$failSync() { - fail(0); _(); }); } - - - var fail; - - function A(_, code) { var i; var __frame = { name: 'A', line: 26 }; return __func(_, this, arguments, A, 0, __frame, function __$A() { - return function __$A(__then) { if (code == 1) { - return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(function __$A() { - return function __$A(__then) { if (code == 2) { - return fail(__cb(_, __frame, 4, 0, __then, true, false), code); } else { __then(); } }(function __$A() { - return nextTick(__cb(_, __frame, 5, 0, function __$A() { - return function __$A(__then) { if (code == 3) { - return fail(__cb(_, __frame, 7, 0, __then, true, false), code); } else { __then(); } }(function __$A() { i = 0; - var __6 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$A() { __more = false; if (__6) { i++; } else { __6 = true; } var __5 = i < 6; if (__5) { - return function __$A(__then) { if (code == i) { - return fail(__cb(_, __frame, 10, 0, __then, true, false), code); } else { __then(); } }(function __$A() { - return nextTick(__cb(_, __frame, 11, 0, function __$A() { while (__more) { __loop(); } __more = true; }, true, false)); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$A() { - - return function __$A(__then) { if (code == 6) { - return fail(__cb(_, __frame, 14, 0, __then, true, false), code); } else { __then(); } }(function __$A() { - return nextTick(__cb(_, __frame, 15, 0, function __$A() { - return B(__cb(_, __frame, 16, 0, function __$A() { - return nextTick(__cb(_, __frame, 17, 0, function __$A() { - return _(null, 'END'); }, true, false)); }, true, false), code); }, true, false)); }); }); }); }, true, false)); }); }); }); } - - - function B(_, code) { var __frame = { name: 'B', line: 47 }; return __func(_, this, arguments, B, 0, __frame, function __$B() { - return function __$B(__then) { if (code == 7) { - return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(function __$B() { - return C(__cb(_, __frame, 3, 0, function __$B() { - return nextTick(__cb(_, __frame, 4, 0, function __$B() { - return C(__cb(_, __frame, 5, 0, function __$B() { - return D(__cb(_, __frame, 6, 0, function __$B() { _(); }, true, false), code); }, true, false), code); }, true, false)); }, true, false), code); }); }); } - - - function C(_, code) { var __frame = { name: 'C', line: 56 }; return __func(_, this, arguments, C, 0, __frame, function __$C() { - return function __$C(__then) { if (code == 8) { - return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(_); }); } - - - function D(_, code) { var __frame = { name: 'D', line: 61 }; return __func(_, this, arguments, D, 0, __frame, function __$D() { - return function __$D(__then) { if (code == 9) { - return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(_); }); } - - - function E(_, code) { var __frame = { name: 'E', line: 66 }; return __func(_, this, arguments, E, 0, __frame, function __$E() { - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$E() { - return fail(__cb(_, __frame, 2, 0, __then, true, false), code); }); }(function ___(ex, __result) { - - __catch(function __$E() { if (ex) { - return function __$E(__then) { if (code % 3 == 1) { - return fail(__cb(_, __frame, 6, 0, __then, true, false), code); } else { - return function __$E(__then) { if (code % 3 == 2) { - return A(__cb(_, __frame, 8, 0, __then, true, false), code); } else { - - return _(null, 'OK ' + code); } }(__then); } }(__then); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$E() { _(); }); }); }); } - - - - function F(_, code) { var f1, f2; var __frame = { name: 'F', line: 80 }; return __func(_, this, arguments, F, 0, __frame, function __$F() { f1 = A(false, code); - f2 = A(false, code + 1); - - return f1(__cb(_, __frame, 3, 0, function ___(__0, __2) { return f2(__cb(_, __frame, 3, 0, function ___(__0, __3) { var __1 = __2 + ' & ' + __3; return _(null, __1); }, true, false)); }, true, false)); }); } - - - function G(_, code) { var __frame = { name: 'G', line: 86 }; return __func(_, this, arguments, G, 0, __frame, function __$G() { - return function __$G(__then) { if (code == 5) { - return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(function __$G() { - return _(null, '' + code); }); }); } - - - function H(_, code) { var __frame = { name: 'H', line: 92 }; return __func(_, this, arguments, H, 0, __frame, function __$H() { - return function __$H(__then) { if (code % 2 == 0) { - return nextTick(__cb(_, __frame, 2, 0, __then, true, false)); } else { __then(); } }(function __$H() { - return G(__cb(_, __frame, 3, 0, _, true, false), code); }); }); } - - - function I(_, code) { var s, i; var __frame = { name: 'I', line: 98 }; return __func(_, this, arguments, I, 0, __frame, function __$I() { s = ''; - i = 0; - var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$I() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < code; if (__2) { - return H(__cb(_, __frame, 3, 0, function ___(__0, __1) { s += __1; while (__more) { __loop(); } __more = true; }, true, false), i); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$I() { - return _(null, s); }); }); } - - - function issue233(_, code) { - function customThrow() { - throw new Error('foo'); } var __frame = { name: 'issue233', line: 105 }; return __func(_, this, arguments, issue233, 0, __frame, function __$issue233() { - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$issue233() { - return _(new Error('bar')); }); }(function ___(e, __result) { - __catch(function __$issue233() { if (e) { - customThrow(); __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$issue233() { _(); }); }); }); } - - - - - - function T(_, fn, code, failFn) { var s, end; var __frame = { name: 'T', line: 118 }; return __func(_, this, arguments, T, 0, __frame, function __$T() { - fail = failFn; s = '{'; - - return function ___(__then) { (function ___(_) { __tryCatch(_, function __$T() { - return fn(__cb(_, __frame, 4, 0, _, true, false), code); }); }(function ___(ex, __result) { - - __catch(function __$T() { if (ex) { s = ex.stack; - - s = s.split('\n').filter(function (l) { return l.indexOf('<<<') < 0; }).map(function (l) { - var m = /^\s+at (\w+).*:(\d+)\:[^:]+$/.exec(l); - if (m) return m[1] + ':' + m[2]; - - return l; }).join('/'); - end = s.indexOf('/T:'); +/*** 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; + + +QUnit.module(module.id); + +var nextTick = __rt.streamlinify(function (cb) { + setTimeout(function () { + cb(); }, 0); }, 0); + + + + + +function failAsync(_, code) { var __frame = { name: 'failAsync', line: 14 }; return __func(_, this, arguments, failAsync, 0, __frame, function __$failAsync() { + return _(new Error(code)); }); } + + +function failSync(_, code) { + + function fail(dummy) { throw new Error(code); } var __frame = { name: 'failSync', line: 18 }; return __func(_, this, arguments, failSync, 0, __frame, function __$failSync() { + fail(0); _(); }); } + + +var fail; + +function A(_, code) { var i; var __frame = { name: 'A', line: 26 }; return __func(_, this, arguments, A, 0, __frame, function __$A() { + return function __$A(__then) { if (code == 1) { + return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(function __$A() { + return function __$A(__then) { if (code == 2) { + return fail(__cb(_, __frame, 4, 0, __then, true, false), code); } else { __then(); } }(function __$A() { + return nextTick(__cb(_, __frame, 5, 0, function __$A() { + return function __$A(__then) { if (code == 3) { + return fail(__cb(_, __frame, 7, 0, __then, true, false), code); } else { __then(); } }(function __$A() { + i = 0; var __6 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$A() { __more = false; if (__6) { i++; } else { __6 = true; } var __5 = i < 6; if (__5) { + return function __$A(__then) { if (code == i) { + return fail(__cb(_, __frame, 10, 0, __then, true, false), code); } else { __then(); } }(function __$A() { + return nextTick(__cb(_, __frame, 11, 0, function __$A() { while (__more) { __loop(); } __more = true; }, true, false)); }); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$A() { - return _(null, end < 0 ? s + '-- end frame missing' : s.substring(0, end)); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$T() { _(); }); }); }); } - - - - function stackEqual(got, expect) { - if (typeof T_ === 'function' && T_.gstreamlineFunction) { got = got.substring(0, 25); expect = expect.substring(0, 25); } - strictEqual(got, expect, expect); } - - - var rawStack = new Error().stack ? function (raw) { - return raw; } : function () { + return function __$A(__then) { if (code == 6) { + return fail(__cb(_, __frame, 14, 0, __then, true, false), code); } else { __then(); } }(function __$A() { + return nextTick(__cb(_, __frame, 15, 0, function __$A() { + return B(__cb(_, __frame, 16, 0, function __$A() { + return nextTick(__cb(_, __frame, 17, 0, function __$A() { + return _(null, 'END'); }, true, false)); }, true, false), code); }, true, false)); }); }); }); }, true, false)); }); }); }); } + + +function B(_, code) { var __frame = { name: 'B', line: 47 }; return __func(_, this, arguments, B, 0, __frame, function __$B() { + return function __$B(__then) { if (code == 7) { + return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(function __$B() { + return C(__cb(_, __frame, 3, 0, function __$B() { + return nextTick(__cb(_, __frame, 4, 0, function __$B() { + return C(__cb(_, __frame, 5, 0, function __$B() { + return D(__cb(_, __frame, 6, 0, function __$B() { _(); }, true, false), code); }, true, false), code); }, true, false)); }, true, false), code); }); }); } + + +function C(_, code) { var __frame = { name: 'C', line: 56 }; return __func(_, this, arguments, C, 0, __frame, function __$C() { + return function __$C(__then) { if (code == 8) { + return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(_); }); } + + +function D(_, code) { var __frame = { name: 'D', line: 61 }; return __func(_, this, arguments, D, 0, __frame, function __$D() { + return function __$D(__then) { if (code == 9) { + return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(_); }); } + + +function E(_, code) { var __frame = { name: 'E', line: 66 }; return __func(_, this, arguments, E, 0, __frame, function __$E() { + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$E() { + return fail(__cb(_, __frame, 2, 0, __then, true, false), code); }); }(function ___(ex, __result) { + + __catch(function __$E() { if (ex) { + return function __$E(__then) { if (code % 3 == 1) { + return fail(__cb(_, __frame, 6, 0, __then, true, false), code); } else { + return function __$E(__then) { if (code % 3 == 2) { + return A(__cb(_, __frame, 8, 0, __then, true, false), code); } else { + + return _(null, 'OK ' + code); } }(__then); } }(__then); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$E() { _(); }); }); }); } + + + +function F(_, code) { var f1, f2; var __frame = { name: 'F', line: 80 }; return __func(_, this, arguments, F, 0, __frame, function __$F() { f1 = A(false, code); + f2 = A(false, code + 1); - return 'raw stack unavailable'; }; - - - asyncTest('stacks', 20, function __1(_) { var __frame = { name: '__1', line: 148 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { - return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, rawStack('Error: 1/failAsync:15') + '/A:28'); - return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, rawStack('Error: 1/fail:20/failSync:21') + '/A:28'); - return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, rawStack('Error: 2/failAsync:15') + '/A:30'); - return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, rawStack('Error: 2/fail:20/failSync:21') + '/A:30'); - return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, rawStack('Error: 3/failAsync:15') + '/A:33'); - return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, rawStack('Error: 3/fail:20/failSync:21') + '/A:33'); - return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 4/failAsync:15') + '/A:36'); - return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 4/fail:20/failSync:21') + '/A:36'); - return T(__cb(_, __frame, 9, 0, function ___(__0, __9) { stackEqual(__9, rawStack('Error: 5/failAsync:15') + '/A:36'); - return T(__cb(_, __frame, 10, 0, function ___(__0, __10) { stackEqual(__10, rawStack('Error: 5/fail:20/failSync:21') + '/A:36'); - return T(__cb(_, __frame, 11, 0, function ___(__0, __11) { stackEqual(__11, rawStack('Error: 6/failAsync:15') + '/A:40'); - return T(__cb(_, __frame, 12, 0, function ___(__0, __12) { stackEqual(__12, rawStack('Error: 6/fail:20/failSync:21') + '/A:40'); - return T(__cb(_, __frame, 13, 0, function ___(__0, __13) { stackEqual(__13, rawStack('Error: 7/failAsync:15') + '/B:49/A:42'); - return T(__cb(_, __frame, 14, 0, function ___(__0, __14) { stackEqual(__14, rawStack('Error: 7/fail:20/failSync:21') + '/B:49/A:42'); - return T(__cb(_, __frame, 15, 0, function ___(__0, __15) { stackEqual(__15, rawStack('Error: 8/failAsync:15') + '/C:58/B:50/A:42'); - return T(__cb(_, __frame, 16, 0, function ___(__0, __16) { stackEqual(__16, rawStack('Error: 8/fail:20/failSync:21') + '/C:58/B:50/A:42'); - return T(__cb(_, __frame, 17, 0, function ___(__0, __17) { stackEqual(__17, rawStack('Error: 9/failAsync:15') + '/D:63/B:53/A:42'); - return T(__cb(_, __frame, 18, 0, function ___(__0, __18) { stackEqual(__18, rawStack('Error: 9/fail:20/failSync:21') + '/D:63/B:53/A:42'); - return T(__cb(_, __frame, 19, 0, function ___(__0, __19) { stackEqual(__19, 'END'); - return T(__cb(_, __frame, 20, 0, function ___(__0, __20) { stackEqual(__20, 'END'); - start(); _(); }, true, false), A, 10, failSync); }, true, false), A, 10, failAsync); }, true, false), A, 9, failSync); }, true, false), A, 9, failAsync); }, true, false), A, 8, failSync); }, true, false), A, 8, failAsync); }, true, false), A, 7, failSync); }, true, false), A, 7, failAsync); }, true, false), A, 6, failSync); }, true, false), A, 6, failAsync); }, true, false), A, 5, failSync); }, true, false), A, 5, failAsync); }, true, false), A, 4, failSync); }, true, false), A, 4, failAsync); }, true, false), A, 3, failSync); }, true, false), A, 3, failAsync); }, true, false), A, 2, failSync); }, true, false), A, 2, failAsync); }, true, false), A, 1, failSync); }, true, false), A, 1, failAsync); }); }); - - - asyncTest('catch', 20, function __2(_) { var __frame = { name: '__2', line: 172 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { - return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, rawStack('Error: 1/failAsync:15') + '/E:72'); - return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, rawStack('Error: 1/fail:20/failSync:21') + '/E:72'); - return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, rawStack('Error: 2/failAsync:15') + '/A:30/E:74'); - return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, rawStack('Error: 2/fail:20/failSync:21') + '/A:30/E:74'); - return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, 'OK 3'); - return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, 'OK 3'); - return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 4/failAsync:15') + '/E:72'); - return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 4/fail:20/failSync:21') + '/E:72'); - return T(__cb(_, __frame, 9, 0, function ___(__0, __9) { stackEqual(__9, rawStack('Error: 5/failAsync:15') + '/A:36/E:74'); - return T(__cb(_, __frame, 10, 0, function ___(__0, __10) { stackEqual(__10, rawStack('Error: 5/fail:20/failSync:21') + '/A:36/E:74'); - return T(__cb(_, __frame, 11, 0, function ___(__0, __11) { stackEqual(__11, 'OK 6'); - return T(__cb(_, __frame, 12, 0, function ___(__0, __12) { stackEqual(__12, 'OK 6'); - return T(__cb(_, __frame, 13, 0, function ___(__0, __13) { stackEqual(__13, rawStack('Error: 7/failAsync:15') + '/E:72'); - return T(__cb(_, __frame, 14, 0, function ___(__0, __14) { stackEqual(__14, rawStack('Error: 7/fail:20/failSync:21') + '/E:72'); - return T(__cb(_, __frame, 15, 0, function ___(__0, __15) { stackEqual(__15, rawStack('Error: 8/failAsync:15') + '/C:58/B:50/A:42/E:74'); - return T(__cb(_, __frame, 16, 0, function ___(__0, __16) { stackEqual(__16, rawStack('Error: 8/fail:20/failSync:21') + '/C:58/B:50/A:42/E:74'); - return T(__cb(_, __frame, 17, 0, function ___(__0, __17) { stackEqual(__17, 'OK 9'); - return T(__cb(_, __frame, 18, 0, function ___(__0, __18) { stackEqual(__18, 'OK 9'); - return T(__cb(_, __frame, 19, 0, function ___(__0, __19) { stackEqual(__19, rawStack('Error: 10/failAsync:15') + '/E:72'); - return T(__cb(_, __frame, 20, 0, function ___(__0, __20) { stackEqual(__20, rawStack('Error: 10/fail:20/failSync:21') + '/E:72'); - start(); _(); }, true, false), E, 10, failSync); }, true, false), E, 10, failAsync); }, true, false), E, 9, failSync); }, true, false), E, 9, failAsync); }, true, false), E, 8, failSync); }, true, false), E, 8, failAsync); }, true, false), E, 7, failSync); }, true, false), E, 7, failAsync); }, true, false), E, 6, failSync); }, true, false), E, 6, failAsync); }, true, false), E, 5, failSync); }, true, false), E, 5, failAsync); }, true, false), E, 4, failSync); }, true, false), E, 4, failAsync); }, true, false), E, 3, failSync); }, true, false), E, 3, failAsync); }, true, false), E, 2, failSync); }, true, false), E, 2, failAsync); }, true, false), E, 1, failSync); }, true, false), E, 1, failAsync); }); }); - - - asyncTest('futures', 20, function __3(_) { var __frame = { name: '__3', line: 196 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { - return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, rawStack('Error: 1/failAsync:15') + '/A:28/F:83'); - return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, rawStack('Error: 1/fail:20/failSync:21') + '/A:28/F:83'); - return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, rawStack('Error: 2/failAsync:15') + '/A:30/F:83'); - return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, rawStack('Error: 2/fail:20/failSync:21') + '/A:30/F:83'); - return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, rawStack('Error: 3/failAsync:15') + '/A:33/F:83'); - return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, rawStack('Error: 3/fail:20/failSync:21') + '/A:33/F:83'); - return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 4/failAsync:15') + '/A:36/F:83'); - return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 4/fail:20/failSync:21') + '/A:36/F:83'); - return T(__cb(_, __frame, 9, 0, function ___(__0, __9) { stackEqual(__9, rawStack('Error: 5/failAsync:15') + '/A:36/F:83'); - return T(__cb(_, __frame, 10, 0, function ___(__0, __10) { stackEqual(__10, rawStack('Error: 5/fail:20/failSync:21') + '/A:36/F:83'); - return T(__cb(_, __frame, 11, 0, function ___(__0, __11) { stackEqual(__11, rawStack('Error: 6/failAsync:15') + '/A:40/F:83'); - return T(__cb(_, __frame, 12, 0, function ___(__0, __12) { stackEqual(__12, rawStack('Error: 6/fail:20/failSync:21') + '/A:40/F:83'); - return T(__cb(_, __frame, 13, 0, function ___(__0, __13) { stackEqual(__13, rawStack('Error: 7/failAsync:15') + '/B:49/A:42/F:83'); - return T(__cb(_, __frame, 14, 0, function ___(__0, __14) { stackEqual(__14, rawStack('Error: 7/fail:20/failSync:21') + '/B:49/A:42/F:83'); - return T(__cb(_, __frame, 15, 0, function ___(__0, __15) { stackEqual(__15, rawStack('Error: 8/failAsync:15') + '/C:58/B:50/A:42/F:83'); - return T(__cb(_, __frame, 16, 0, function ___(__0, __16) { stackEqual(__16, rawStack('Error: 8/fail:20/failSync:21') + '/C:58/B:50/A:42/F:83'); - return T(__cb(_, __frame, 17, 0, function ___(__0, __17) { stackEqual(__17, rawStack('Error: 9/failAsync:15') + '/D:63/B:53/A:42/F:83'); - return T(__cb(_, __frame, 18, 0, function ___(__0, __18) { stackEqual(__18, rawStack('Error: 9/fail:20/failSync:21') + '/D:63/B:53/A:42/F:83'); - return T(__cb(_, __frame, 19, 0, function ___(__0, __19) { stackEqual(__19, 'END & END'); - return T(__cb(_, __frame, 20, 0, function ___(__0, __20) { stackEqual(__20, 'END & END'); - start(); _(); }, true, false), F, 10, failSync); }, true, false), F, 10, failAsync); }, true, false), F, 9, failSync); }, true, false), F, 9, failAsync); }, true, false), F, 8, failSync); }, true, false), F, 8, failAsync); }, true, false), F, 7, failSync); }, true, false), F, 7, failAsync); }, true, false), F, 6, failSync); }, true, false), F, 6, failAsync); }, true, false), F, 5, failSync); }, true, false), F, 5, failAsync); }, true, false), F, 4, failSync); }, true, false), F, 4, failAsync); }, true, false), F, 3, failSync); }, true, false), F, 3, failAsync); }, true, false), F, 2, failSync); }, true, false), F, 2, failAsync); }, true, false), F, 1, failSync); }, true, false), F, 1, failAsync); }); }); - - - asyncTest('loop', 8, function __4(_) { var __frame = { name: '__4', line: 220 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { - return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, '0123'); - return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, '0123'); - return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, '01234'); - return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, '01234'); - return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, rawStack('Error: 5/failAsync:15') + '/G:88/H:95/I:101'); - return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, rawStack('Error: 5/fail:20/failSync:21') + '/G:88/H:95/I:101'); - return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 5/failAsync:15') + '/G:88/H:95/I:101'); - return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 5/fail:20/failSync:21') + '/G:88/H:95/I:101'); - start(); _(); }, true, false), I, 7, failSync); }, true, false), I, 7, failAsync); }, true, false), I, 6, failSync); }, true, false), I, 6, failAsync); }, true, false), I, 5, failSync); }, true, false), I, 5, failAsync); }, true, false), I, 4, failSync); }, true, false), I, 4, failAsync); }); }); - - - asyncTest('issue233', 1, function __5(_) { var __frame = { name: '__5', line: 232 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { - return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, 'Error: foo/customThrow:107/issue233:112'); - start(); _(); }, true, false), issue233, 0, failSync); }); }); \ No newline at end of file + return f1(__cb(_, __frame, 3, 0, function ___(__0, __2) { return f2(__cb(_, __frame, 3, 0, function ___(__0, __3) { var __1 = __2 + ' & ' + __3; return _(null, __1); }, true, false)); }, true, false)); }); } + + +function G(_, code) { var __frame = { name: 'G', line: 86 }; return __func(_, this, arguments, G, 0, __frame, function __$G() { + return function __$G(__then) { if (code == 5) { + return fail(__cb(_, __frame, 2, 0, __then, true, false), code); } else { __then(); } }(function __$G() { + return _(null, '' + code); }); }); } + + +function H(_, code) { var __frame = { name: 'H', line: 92 }; return __func(_, this, arguments, H, 0, __frame, function __$H() { + return function __$H(__then) { if (code % 2 == 0) { + return nextTick(__cb(_, __frame, 2, 0, __then, true, false)); } else { __then(); } }(function __$H() { + return G(__cb(_, __frame, 3, 0, _, true, false), code); }); }); } + + +function I(_, code) { var s, i; var __frame = { name: 'I', line: 98 }; return __func(_, this, arguments, I, 0, __frame, function __$I() { s = ''; + + i = 0; var __3 = false; return function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$I() { __more = false; if (__3) { i++; } else { __3 = true; } var __2 = i < code; if (__2) { + return H(__cb(_, __frame, 3, 0, function ___(__0, __1) { s += __1; while (__more) { __loop(); } __more = true; }, true, false), i); } else { __break(); } }); do { __loop(); } while (__more); __more = true; }(function __$I() { + return _(null, s); }); }); } + + +function issue233(_, code) { + function customThrow() { + throw new Error('foo'); } var __frame = { name: 'issue233', line: 105 }; return __func(_, this, arguments, issue233, 0, __frame, function __$issue233() { + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$issue233() { + return _(new Error('bar')); }); }(function ___(e, __result) { + __catch(function __$issue233() { if (e) { + customThrow(); __then(); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$issue233() { _(); }); }); }); } + + + + + +function T(_, fn, code, failFn) { var s, end; var __frame = { name: 'T', line: 118 }; return __func(_, this, arguments, T, 0, __frame, function __$T() { + fail = failFn; s = '{'; + + return function ___(__then) { (function ___(_) { __tryCatch(_, function __$T() { + return fn(__cb(_, __frame, 4, 0, _, true, false), code); }); }(function ___(ex, __result) { + + __catch(function __$T() { if (ex) { s = ex.stack; + + s = s.split('\n').filter(function (l) { return l.indexOf('<<<') < 0; }).map(function (l) { + var m = /^\s+at (\w+).*:(\d+)\:[^:]+$/.exec(l); + if (m) return m[1] + ':' + m[2]; + + return l; }).join('/'); + end = s.indexOf('/T:'); + + return _(null, end < 0 ? s + '-- end frame missing' : s.substring(0, end)); } else { _(null, __result); } }, _); })); }(function ___() { __tryCatch(_, function __$T() { _(); }); }); }); } + + + +function stackEqual(got, expect) { + if (typeof T_ === 'function' && T_.gstreamlineFunction) { got = got.substring(0, 25); expect = expect.substring(0, 25); } + strictEqual(got, expect, expect); } + + +var rawStack = new Error().stack ? function (raw) { + return raw; } : function () { + + return 'raw stack unavailable'; }; + + +asyncTest('stacks', 20, function __1(_) { var __frame = { name: '__1', line: 148 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { + return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, rawStack('Error: 1/failAsync:15') + '/A:28'); + return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, rawStack('Error: 1/fail:20/failSync:21') + '/A:28'); + return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, rawStack('Error: 2/failAsync:15') + '/A:30'); + return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, rawStack('Error: 2/fail:20/failSync:21') + '/A:30'); + return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, rawStack('Error: 3/failAsync:15') + '/A:33'); + return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, rawStack('Error: 3/fail:20/failSync:21') + '/A:33'); + return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 4/failAsync:15') + '/A:36'); + return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 4/fail:20/failSync:21') + '/A:36'); + return T(__cb(_, __frame, 9, 0, function ___(__0, __9) { stackEqual(__9, rawStack('Error: 5/failAsync:15') + '/A:36'); + return T(__cb(_, __frame, 10, 0, function ___(__0, __10) { stackEqual(__10, rawStack('Error: 5/fail:20/failSync:21') + '/A:36'); + return T(__cb(_, __frame, 11, 0, function ___(__0, __11) { stackEqual(__11, rawStack('Error: 6/failAsync:15') + '/A:40'); + return T(__cb(_, __frame, 12, 0, function ___(__0, __12) { stackEqual(__12, rawStack('Error: 6/fail:20/failSync:21') + '/A:40'); + return T(__cb(_, __frame, 13, 0, function ___(__0, __13) { stackEqual(__13, rawStack('Error: 7/failAsync:15') + '/B:49/A:42'); + return T(__cb(_, __frame, 14, 0, function ___(__0, __14) { stackEqual(__14, rawStack('Error: 7/fail:20/failSync:21') + '/B:49/A:42'); + return T(__cb(_, __frame, 15, 0, function ___(__0, __15) { stackEqual(__15, rawStack('Error: 8/failAsync:15') + '/C:58/B:50/A:42'); + return T(__cb(_, __frame, 16, 0, function ___(__0, __16) { stackEqual(__16, rawStack('Error: 8/fail:20/failSync:21') + '/C:58/B:50/A:42'); + return T(__cb(_, __frame, 17, 0, function ___(__0, __17) { stackEqual(__17, rawStack('Error: 9/failAsync:15') + '/D:63/B:53/A:42'); + return T(__cb(_, __frame, 18, 0, function ___(__0, __18) { stackEqual(__18, rawStack('Error: 9/fail:20/failSync:21') + '/D:63/B:53/A:42'); + return T(__cb(_, __frame, 19, 0, function ___(__0, __19) { stackEqual(__19, 'END'); + return T(__cb(_, __frame, 20, 0, function ___(__0, __20) { stackEqual(__20, 'END'); + start(); _(); }, true, false), A, 10, failSync); }, true, false), A, 10, failAsync); }, true, false), A, 9, failSync); }, true, false), A, 9, failAsync); }, true, false), A, 8, failSync); }, true, false), A, 8, failAsync); }, true, false), A, 7, failSync); }, true, false), A, 7, failAsync); }, true, false), A, 6, failSync); }, true, false), A, 6, failAsync); }, true, false), A, 5, failSync); }, true, false), A, 5, failAsync); }, true, false), A, 4, failSync); }, true, false), A, 4, failAsync); }, true, false), A, 3, failSync); }, true, false), A, 3, failAsync); }, true, false), A, 2, failSync); }, true, false), A, 2, failAsync); }, true, false), A, 1, failSync); }, true, false), A, 1, failAsync); }); }); + + +asyncTest('catch', 20, function __2(_) { var __frame = { name: '__2', line: 172 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { + return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, rawStack('Error: 1/failAsync:15') + '/E:72'); + return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, rawStack('Error: 1/fail:20/failSync:21') + '/E:72'); + return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, rawStack('Error: 2/failAsync:15') + '/A:30/E:74'); + return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, rawStack('Error: 2/fail:20/failSync:21') + '/A:30/E:74'); + return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, 'OK 3'); + return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, 'OK 3'); + return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 4/failAsync:15') + '/E:72'); + return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 4/fail:20/failSync:21') + '/E:72'); + return T(__cb(_, __frame, 9, 0, function ___(__0, __9) { stackEqual(__9, rawStack('Error: 5/failAsync:15') + '/A:36/E:74'); + return T(__cb(_, __frame, 10, 0, function ___(__0, __10) { stackEqual(__10, rawStack('Error: 5/fail:20/failSync:21') + '/A:36/E:74'); + return T(__cb(_, __frame, 11, 0, function ___(__0, __11) { stackEqual(__11, 'OK 6'); + return T(__cb(_, __frame, 12, 0, function ___(__0, __12) { stackEqual(__12, 'OK 6'); + return T(__cb(_, __frame, 13, 0, function ___(__0, __13) { stackEqual(__13, rawStack('Error: 7/failAsync:15') + '/E:72'); + return T(__cb(_, __frame, 14, 0, function ___(__0, __14) { stackEqual(__14, rawStack('Error: 7/fail:20/failSync:21') + '/E:72'); + return T(__cb(_, __frame, 15, 0, function ___(__0, __15) { stackEqual(__15, rawStack('Error: 8/failAsync:15') + '/C:58/B:50/A:42/E:74'); + return T(__cb(_, __frame, 16, 0, function ___(__0, __16) { stackEqual(__16, rawStack('Error: 8/fail:20/failSync:21') + '/C:58/B:50/A:42/E:74'); + return T(__cb(_, __frame, 17, 0, function ___(__0, __17) { stackEqual(__17, 'OK 9'); + return T(__cb(_, __frame, 18, 0, function ___(__0, __18) { stackEqual(__18, 'OK 9'); + return T(__cb(_, __frame, 19, 0, function ___(__0, __19) { stackEqual(__19, rawStack('Error: 10/failAsync:15') + '/E:72'); + return T(__cb(_, __frame, 20, 0, function ___(__0, __20) { stackEqual(__20, rawStack('Error: 10/fail:20/failSync:21') + '/E:72'); + start(); _(); }, true, false), E, 10, failSync); }, true, false), E, 10, failAsync); }, true, false), E, 9, failSync); }, true, false), E, 9, failAsync); }, true, false), E, 8, failSync); }, true, false), E, 8, failAsync); }, true, false), E, 7, failSync); }, true, false), E, 7, failAsync); }, true, false), E, 6, failSync); }, true, false), E, 6, failAsync); }, true, false), E, 5, failSync); }, true, false), E, 5, failAsync); }, true, false), E, 4, failSync); }, true, false), E, 4, failAsync); }, true, false), E, 3, failSync); }, true, false), E, 3, failAsync); }, true, false), E, 2, failSync); }, true, false), E, 2, failAsync); }, true, false), E, 1, failSync); }, true, false), E, 1, failAsync); }); }); + + +asyncTest('futures', 20, function __3(_) { var __frame = { name: '__3', line: 196 }; return __func(_, this, arguments, __3, 0, __frame, function __$__3() { + return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, rawStack('Error: 1/failAsync:15') + '/A:28/F:83'); + return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, rawStack('Error: 1/fail:20/failSync:21') + '/A:28/F:83'); + return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, rawStack('Error: 2/failAsync:15') + '/A:30/F:83'); + return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, rawStack('Error: 2/fail:20/failSync:21') + '/A:30/F:83'); + return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, rawStack('Error: 3/failAsync:15') + '/A:33/F:83'); + return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, rawStack('Error: 3/fail:20/failSync:21') + '/A:33/F:83'); + return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 4/failAsync:15') + '/A:36/F:83'); + return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 4/fail:20/failSync:21') + '/A:36/F:83'); + return T(__cb(_, __frame, 9, 0, function ___(__0, __9) { stackEqual(__9, rawStack('Error: 5/failAsync:15') + '/A:36/F:83'); + return T(__cb(_, __frame, 10, 0, function ___(__0, __10) { stackEqual(__10, rawStack('Error: 5/fail:20/failSync:21') + '/A:36/F:83'); + return T(__cb(_, __frame, 11, 0, function ___(__0, __11) { stackEqual(__11, rawStack('Error: 6/failAsync:15') + '/A:40/F:83'); + return T(__cb(_, __frame, 12, 0, function ___(__0, __12) { stackEqual(__12, rawStack('Error: 6/fail:20/failSync:21') + '/A:40/F:83'); + return T(__cb(_, __frame, 13, 0, function ___(__0, __13) { stackEqual(__13, rawStack('Error: 7/failAsync:15') + '/B:49/A:42/F:83'); + return T(__cb(_, __frame, 14, 0, function ___(__0, __14) { stackEqual(__14, rawStack('Error: 7/fail:20/failSync:21') + '/B:49/A:42/F:83'); + return T(__cb(_, __frame, 15, 0, function ___(__0, __15) { stackEqual(__15, rawStack('Error: 8/failAsync:15') + '/C:58/B:50/A:42/F:83'); + return T(__cb(_, __frame, 16, 0, function ___(__0, __16) { stackEqual(__16, rawStack('Error: 8/fail:20/failSync:21') + '/C:58/B:50/A:42/F:83'); + return T(__cb(_, __frame, 17, 0, function ___(__0, __17) { stackEqual(__17, rawStack('Error: 9/failAsync:15') + '/D:63/B:53/A:42/F:83'); + return T(__cb(_, __frame, 18, 0, function ___(__0, __18) { stackEqual(__18, rawStack('Error: 9/fail:20/failSync:21') + '/D:63/B:53/A:42/F:83'); + return T(__cb(_, __frame, 19, 0, function ___(__0, __19) { stackEqual(__19, 'END & END'); + return T(__cb(_, __frame, 20, 0, function ___(__0, __20) { stackEqual(__20, 'END & END'); + start(); _(); }, true, false), F, 10, failSync); }, true, false), F, 10, failAsync); }, true, false), F, 9, failSync); }, true, false), F, 9, failAsync); }, true, false), F, 8, failSync); }, true, false), F, 8, failAsync); }, true, false), F, 7, failSync); }, true, false), F, 7, failAsync); }, true, false), F, 6, failSync); }, true, false), F, 6, failAsync); }, true, false), F, 5, failSync); }, true, false), F, 5, failAsync); }, true, false), F, 4, failSync); }, true, false), F, 4, failAsync); }, true, false), F, 3, failSync); }, true, false), F, 3, failAsync); }, true, false), F, 2, failSync); }, true, false), F, 2, failAsync); }, true, false), F, 1, failSync); }, true, false), F, 1, failAsync); }); }); + + +asyncTest('loop', 8, function __4(_) { var __frame = { name: '__4', line: 220 }; return __func(_, this, arguments, __4, 0, __frame, function __$__4() { + return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, '0123'); + return T(__cb(_, __frame, 2, 0, function ___(__0, __2) { stackEqual(__2, '0123'); + return T(__cb(_, __frame, 3, 0, function ___(__0, __3) { stackEqual(__3, '01234'); + return T(__cb(_, __frame, 4, 0, function ___(__0, __4) { stackEqual(__4, '01234'); + return T(__cb(_, __frame, 5, 0, function ___(__0, __5) { stackEqual(__5, rawStack('Error: 5/failAsync:15') + '/G:88/H:95/I:101'); + return T(__cb(_, __frame, 6, 0, function ___(__0, __6) { stackEqual(__6, rawStack('Error: 5/fail:20/failSync:21') + '/G:88/H:95/I:101'); + return T(__cb(_, __frame, 7, 0, function ___(__0, __7) { stackEqual(__7, rawStack('Error: 5/failAsync:15') + '/G:88/H:95/I:101'); + return T(__cb(_, __frame, 8, 0, function ___(__0, __8) { stackEqual(__8, rawStack('Error: 5/fail:20/failSync:21') + '/G:88/H:95/I:101'); + start(); _(); }, true, false), I, 7, failSync); }, true, false), I, 7, failAsync); }, true, false), I, 6, failSync); }, true, false), I, 6, failAsync); }, true, false), I, 5, failSync); }, true, false), I, 5, failAsync); }, true, false), I, 4, failSync); }, true, false), I, 4, failAsync); }); }); + + +asyncTest('issue233', 1, function __5(_) { var __frame = { name: '__5', line: 232 }; return __func(_, this, arguments, __5, 0, __frame, function __$__5() { + return T(__cb(_, __frame, 1, 0, function ___(__0, __1) { stackEqual(__1, 'Error: foo/customThrow:107/issue233:112'); + start(); _(); }, true, false), issue233, 0, failSync); }); }); \ No newline at end of file