streamline
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -1,8 +0,8 @@ | ||
/*** Generated by streamline --lines-mark 0.1.8 - DO NOT EDIT ***/ | ||
/*** Generated by streamline --lines-mark 0.1.9 - DO NOT EDIT ***/ | ||
var __global = typeof global !== 'undefined' ? global : window; | ||
function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); return fn(null, result); } } | ||
function __nt(_, fn){ var i = 0; var cb = __cb(_, fn); var safeCb = function(){ try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function(){ if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function(){ if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; } | ||
function __propagate(_, err){ try { _(err); } catch (ex) { __trap(ex); } } | ||
function __trap(err){ if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } | ||
function __cb(_, fn) { var ctx = __global.__context; return function(err, result) { __global.__context = ctx; if (err) return _(err); return fn(null, result); } } | ||
function __nt(_, fn) { var i = 0; var cb = __cb(_, fn); var safeCb = function() { try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function() { if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function() { if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; } | ||
function __propagate(_, err) { try { _(err); } catch (ex) { __trap(ex); } } | ||
function __trap(err) { if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } | ||
(function(_) { | ||
@@ -9,0 +9,0 @@ var __ = (_ = (_ || __trap)); |
@@ -1,6 +0,6 @@ | ||
/*** Generated by streamline --lines-mark 0.1.8 - DO NOT EDIT ***/ | ||
/*** Generated by streamline --lines-mark 0.1.9 - DO NOT EDIT ***/ | ||
var __global = typeof global !== 'undefined' ? global : window; | ||
function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); return fn(null, result); } } | ||
function __trap(err){ if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } | ||
function __cb(_, fn) { var ctx = __global.__context; return function(err, result) { __global.__context = ctx; if (err) return _(err); return fn(null, result); } } | ||
function __trap(err) { if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } | ||
(function(_) { | ||
@@ -7,0 +7,0 @@ var __ = (_ = (_ || __trap)); |
@@ -1,3 +0,3 @@ | ||
/*** Generated by streamline --lines-preserve 0.1.8 - DO NOT EDIT ***/ | ||
var __global = typeof global !== 'undefined' ? global : window; function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); return fn(null, result); } } function __trap(err){ if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } var fs = require("fs"); | ||
/*** Generated by streamline --lines-preserve 0.1.9 - DO NOT EDIT ***/ | ||
var __global = typeof global !== 'undefined' ? global : window; function __cb(_, fn) { var ctx = __global.__context; return function(err, result) { __global.__context = ctx; if (err) return _(err); return fn(null, result); } } function __trap(err) { if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } var fs = require("fs"); | ||
var path = require("path"); | ||
@@ -4,0 +4,0 @@ var streamline = require("streamline"); |
@@ -1,3 +0,3 @@ | ||
/*** Generated by streamline --lines-preserve 0.1.8 - DO NOT EDIT ***/ | ||
var __global = typeof global !== 'undefined' ? global : window; function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); return fn(null, result); } } function __nt(_, fn){ var i = 0; var cb = __cb(_, fn); var safeCb = function(){ try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function(){ if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function(){ if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; } function __propagate(_, err){ try { _(err); } catch (ex) { __trap(ex); } } function __trap(err){ if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } function __forIn(object){ var array = []; for (var obj in object) { array.push(obj); } return array; } (function(exports) { | ||
/*** Generated by streamline --lines-preserve 0.1.9 - DO NOT EDIT ***/ | ||
var __global = typeof global !== 'undefined' ? global : window; function __cb(_, fn) { var ctx = __global.__context; return function(err, result) { __global.__context = ctx; if (err) return _(err); return fn(null, result); } } function __nt(_, fn) { var i = 0; var cb = __cb(_, fn); var safeCb = function() { try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function() { if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function() { if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; } function __propagate(_, err) { try { _(err); } catch (ex) { __trap(ex); } } function __trap(err) { if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } } function __forIn(object) { var array = []; for (var obj in object) { array.push(obj); } return array; } (function(exports) { | ||
@@ -42,3 +42,3 @@ | ||
exports.each = function(_, array, fn) { var __ = (_ = (_ || __trap)); | ||
exports.each = function(_, array, fn, thisObj) { var __ = (_ = (_ || __trap)); | ||
if ((!array || !array.length)) { return _(null) }; | ||
@@ -48,7 +48,7 @@ | ||
var i = 0; var __2 = false; return function(__break) { var __loop = __nt(_, function() { var __ = __loop; if (__2) { i++; } else { __2 = true; } ; if ((i < len)) { | ||
return fn(__cb(_, __), array[i], i); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return fn.call(thisObj, __cb(_, __), array[i], i); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return _(null, array); }); }; | ||
exports.map = function(_, array, fn) { var __ = (_ = (_ || __trap)); | ||
exports.map = function(_, array, fn, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!array) { | ||
@@ -59,7 +59,7 @@ return _(null, array) }; | ||
var i = 0; var __2 = false; return function(__break) { var __loop = __nt(_, function() { var __ = __loop; if (__2) { i++; } else { __2 = true; } ; if ((i < len)) { | ||
return fn(__cb(_, function(__0, __1) { result[i] = __1; return __(); }), array[i], i); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return fn.call(thisObj, __cb(_, function(__0, __1) { result[i] = __1; return __(); }), array[i], i); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return _(null, result); }); }; | ||
exports.filter = function(_, array, fn) { var __ = (_ = (_ || __trap)); | ||
exports.filter = function(_, array, fn, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!array) { | ||
@@ -71,3 +71,3 @@ return _(null, array) }; | ||
var elt = array[i]; | ||
return fn(__cb(_, function(__0, __1) { if (__1) { | ||
return fn.call(thisObj, __cb(_, function(__0, __1) { if (__1) { | ||
result.push(elt); } ; return __(); }), elt); } else { return __break(); } ; }); return __loop(); }(function() { | ||
@@ -78,3 +78,3 @@ | ||
exports.every = function(_, array, fn) { var __ = (_ = (_ || __trap)); | ||
exports.every = function(_, array, fn, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!array) { return _(null) }; | ||
@@ -84,3 +84,3 @@ | ||
var i = 0; var __2 = false; return function(__break) { var __loop = __nt(_, function() { var __ = __loop; if (__2) { i++; } else { __2 = true; } ; if ((i < len)) { | ||
return fn(__cb(_, function(__0, __1) { if (!__1) { | ||
return fn.call(thisObj, __cb(_, function(__0, __1) { if (!__1) { | ||
return _(null, false); } ; return __(); }), array[i]); } else { return __break(); } ; }); return __loop(); }(function() { | ||
@@ -91,3 +91,3 @@ | ||
exports.some = function(_, array, fn) { var __ = (_ = (_ || __trap)); | ||
exports.some = function(_, array, fn, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!array) { return _(null) }; | ||
@@ -97,3 +97,3 @@ | ||
var i = 0; var __2 = false; return function(__break) { var __loop = __nt(_, function() { var __ = __loop; if (__2) { i++; } else { __2 = true; } ; if ((i < len)) { | ||
return fn(__cb(_, function(__0, __1) { if (__1) { | ||
return fn.call(thisObj, __cb(_, function(__0, __1) { if (__1) { | ||
return _(null, true); } ; return __(); }), array[i]); } else { return __break(); } ; }); return __loop(); }(function() { | ||
@@ -104,3 +104,23 @@ | ||
exports.eachKey = function(_, obj, fn) { var __ = (_ = (_ || __trap)); | ||
exports.reduce = function(_, array, fn, v, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!array) { | ||
return _(null, v) }; | ||
var len = array.length; | ||
var i = 0; var __2 = false; return function(__break) { var __loop = __nt(_, function() { var __ = __loop; if (__2) { i++; } else { __2 = true; } ; if ((i < len)) { | ||
return fn.call(thisObj, __cb(_, function(__0, __1) { v = __1; return __(); }), v, array[i], i, array); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return _(null, v); }); }; | ||
exports.reduceRight = function(_, array, fn, v, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!array) { | ||
return _(null, v) }; | ||
var len = array.length; | ||
var i = (len - 1); var __2 = false; return function(__break) { var __loop = __nt(_, function() { var __ = __loop; if (__2) { i--; } else { __2 = true; } ; if ((i >= 0)) { | ||
return fn.call(thisObj, __cb(_, function(__0, __1) { v = __1; return __(); }), v, array[i], i, array); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return _(null, v); }); }; | ||
exports.eachKey = function(_, obj, fn, thisObj) { var __ = (_ = (_ || __trap)); | ||
if (!obj) { | ||
@@ -110,3 +130,3 @@ return _(null, obj) }; | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
return fn(__cb(_, __), key, obj[key]); } ; return __(); } else { return __break(); } ; }); return __loop(); }(function() { | ||
return fn.call(thisObj, __cb(_, __), key, obj[key]); } ; return __(); } else { return __break(); } ; }); return __loop(); }(function() { | ||
@@ -113,0 +133,0 @@ return _(null, obj); }); }; |
@@ -244,32 +244,2 @@ /** | ||
/* | ||
* compat stuff | ||
*/ | ||
function _compat(node) { | ||
function _endsWithUnderscore(str) { | ||
return typeof str == "string" && str.length > 0 && str[str.length - 1] == '_'; | ||
} | ||
function _removeUnderscore(str) { | ||
return str.substring(0, str.length - 1); | ||
} | ||
if (node.type == CALL) { | ||
var ident = node.children[0]; | ||
if (ident.type == DOT) | ||
ident = ident.children[1]; | ||
if (_endsWithUnderscore(ident.value)) { | ||
console.log("Old style streamline.js call: " + ident.value); | ||
node.children[1].children.push(_identifier('_')); | ||
ident.value = _removeUnderscore(ident.value); | ||
} | ||
} else if (node.type == FUNCTION) { | ||
if (_endsWithUnderscore(node.name)) { | ||
console.log("Old style streamline.js function definition: " + node.name); | ||
node.params.push('_'); | ||
node.name = _removeUnderscore(node.name); | ||
} | ||
} | ||
} | ||
/* | ||
* Mark source nodes so we can map line numbers | ||
@@ -302,3 +272,2 @@ */ | ||
function _analyzeOne(node, scope) { | ||
_compat(node); | ||
//console.log("ANALYZING: " + _tag(node)); | ||
@@ -305,0 +274,0 @@ if (node.type == SCRIPT) { |
{ | ||
"name": "streamline", | ||
"description": "Asynchronous Javascript for dummies", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"engines": { "node": ">=0.2.1" }, | ||
@@ -6,0 +6,0 @@ "dependencies": { "narcissus": "=0.0.1" }, |
@@ -90,3 +90,19 @@ $(document).ready(function(){ | ||
asyncTest("reduce", 1, function(){ | ||
evalTest(function f(_){ | ||
return flows.reduce(_, [1, 2, 3, 4], function(_, v, val){ | ||
return v * delay(_, val); | ||
}, 1); | ||
}, 24); | ||
}); | ||
asyncTest("reduceRight", 1, function(){ | ||
evalTest(function f(_){ | ||
return flows.reduceRight(_, [1, 2, 3, 4], function(_, v, val){ | ||
return v * delay(_, val); | ||
}, 1); | ||
}, 24); | ||
}); | ||
module("flow"); | ||
@@ -93,0 +109,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
915394