Comparing version 1.5.4 to 1.5.5
{ | ||
"name": "valentine" | ||
, "description": "JavaScripts Functional Sister. Utilitiy, Iterators, type checking" | ||
, "version": "1.5.4" | ||
, "version": "1.5.5" | ||
, "homepage": "https://github.com/ded/valentine" | ||
@@ -6,0 +6,0 @@ , "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)" |
@@ -435,2 +435,3 @@ (function (name, definition) { | ||
if (is.arr(fns) && fns.length === 0 || (is.fun(fns) && args.length === 1)) throw new TypeError('Empty parallel array') | ||
if (!is.arr(fns)) { | ||
@@ -463,2 +464,4 @@ callback = args.pop() | ||
, index = 0 | ||
if (is.arr(fns) && fns.length === 0 || (is.fun(fns) && args.length === 1)) throw new TypeError('Empty waterfall array') | ||
if (!is.arr(fns)) { | ||
@@ -468,2 +471,3 @@ callback = args.pop() | ||
} | ||
(function f() { | ||
@@ -470,0 +474,0 @@ var args = o.toArray(arguments) |
@@ -385,2 +385,16 @@ if (typeof module !== 'undefined' && module.exports) { | ||
test('parallel should throw an exception with an empty array', 1, function () { | ||
var timer = setTimeout(function () { | ||
ok(false, 'Failed by not throwing an exception from an empty array') | ||
}, 50) | ||
try { | ||
v.parallel([], function (err) { | ||
}) | ||
} catch (ex) { | ||
clearTimeout(timer) | ||
ok(true, 'exception thrown with Empty array') | ||
} | ||
}) | ||
test('waterfall', 7, function () { | ||
@@ -436,2 +450,16 @@ var index = 0 | ||
test('waterfall with an empty array should throw exception', 1, function () { | ||
var timer = setTimeout(function () { | ||
ok(false, 'Failed by not throwing an exception from an empty array') | ||
}, 50) | ||
try { | ||
v.waterfall([], function (err) { | ||
}) | ||
} catch (ex) { | ||
clearTimeout(timer) | ||
ok(true, 'exception thrown with Empty array') | ||
} | ||
}) | ||
test('function queue', 3, function () { | ||
@@ -438,0 +466,0 @@ var results = ['first', 'second', 'third'] |
@@ -442,2 +442,3 @@ /*! | ||
if (is.arr(fns) && fns.length === 0 || (is.fun(fns) && args.length === 1)) throw new TypeError('Empty parallel array') | ||
if (!is.arr(fns)) { | ||
@@ -470,2 +471,4 @@ callback = args.pop() | ||
, index = 0 | ||
if (is.arr(fns) && fns.length === 0 || (is.fun(fns) && args.length === 1)) throw new TypeError('Empty waterfall array') | ||
if (!is.arr(fns)) { | ||
@@ -475,2 +478,3 @@ callback = args.pop() | ||
} | ||
(function f() { | ||
@@ -477,0 +481,0 @@ var args = o.toArray(arguments) |
@@ -7,2 +7,2 @@ /*! | ||
*/ | ||
(function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"?define(b):this[a]=this.v=b()})("valentine",function(){function n(a){this.values=a,this.index=0}function o(a,b){return new q(a,b)}function p(a,b){for(var c in b)a[c]=b[c]}function q(a,b){this.val=a,this._scope=b||e,this._chained=0}var a=this,b=a.v,c=[],d=Object.prototype.hasOwnProperty,e=null,f=c.slice,g="map"in c,h="reduce"in c,i=/(^\s*|\s*$)/g,j={each:g?function(a,b,d){c.forEach.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)d in a&&b.call(c,a[d],d,a)},map:g?function(a,b,d){return c.map.call(a,b,d)}:function(a,b,c){var d=[],e;for(e=0,l=a.length;e<l;e++)e in a&&(d[e]=b.call(c,a[e],e,a));return d},some:g?function(a,b,c){return a.some(b,c)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(d in a&&b.call(c,a[d],d,a))return!0;return!1},every:g?function(a,b,c){return a.every(b,c)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(d in a&&!b.call(c,a[d],d,a))return!1;return!0},filter:g?function(a,b,c){return a.filter(b,c)}:function(a,b,c){for(var d=[],e=0,f=0,g=a.length;e<g;e++)if(e in a){if(!b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},indexOf:g?function(a,b,c){return a.indexOf(b,isFinite(c)?c:0)}:function(a,b,c){c=c||0,c=c<0?0:c,c=c>a.length?a.length:c;for(var d=c;d<a.length;d++)if(d in a&&a[d]===b)return d;return-1},lastIndexOf:g?function(a,b,c){return a.lastIndexOf(b,isFinite(c)?c:a.length)}:function(a,b,c){c=c||a.length,c=c>=a.length?a.length:c<0?a.length+c:c;for(var d=c;d>=0;--d)if(d in a&&a[d]===b)return d;return-1},reduce:h?function(a,b,d,e){return c.reduce.call(a,b,d,e)}:function(a,b,c,d){a||(a=[]);var e=0,f=a.length;if(arguments.length<3)do{if(e in a){c=a[e++];break}if(++e>=f)throw new TypeError("Empty array")}while(1);for(;e<f;e++)e in a&&(c=b.call(d,c,a[e],e,a));return c},reduceRight:h?function(a,b,d,e){return c.reduceRight.call(a,b,d,e)}:function(a,b,c,d){!a&&(a=[]);var e=a.length,f=e-1;if(arguments.length<3)do{if(f in a){c=a[f--];break}if(--f<0)throw new TypeError("Empty array")}while(1);for(;f>=0;f--)f in a&&(c=b.call(d,c,a[f],f,a));return c},find:function(a,b,c){var d;return j.some(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},reject:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++)if(e in a){if(b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},size:function(a){return m.toArray(a).length},compact:function(a){return j.filter(a,function(a){return!!a})},flatten:function(a){return j.reduce(a,function(a,b){return k.arr(b)?a.concat(j.flatten(b)):(a[a.length]=b,a)},[])},uniq:function(a,b){var c=[],d,e;a=b?j.map(a,b):a;a:for(d=0;d<a.length;d++){for(e=0;e<c.length;e++)if(c[e]===a[d])continue a;c[c.length]=a[d]}return c},merge:function(a,b){var c=a.length,d=0,e;if(isFinite(b.length))for(e=b.length;d<e;d++)a[c++]=b[d];else while(b[d]!==undefined)first[c++]=second[d++];return a.length=c,a},inArray:function(a,b){return!!~j.indexOf(a,b)}},k={fun:function(a){return typeof a=="function"},str:function(a){return typeof a=="string"},ele:function(a){return!!a&&!!a.nodeType&&a.nodeType==1},arr:function(a){return a instanceof Array},arrLike:function(a){return a&&a.length&&isFinite(a.length)},num:function(a){return typeof a=="number"},bool:function(a){return a===!0||a===!1},args:function(a){return!!a&&!!d.call(a,"callee")},emp:function(a){var b=0;return k.arr(a)?a.length===0:k.obj(a)?function(){for(var c in a){b++;break}return b===0}():a===""},dat:function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)},reg:function(a){return!(!(a&&a.test&&a.exec)||!a.ignoreCase&&a.ignoreCase!==!1)},nan:function(a){return a!==a},nil:function(a){return a===e},und:function(a){return typeof a=="undefined"},def:function(a){return typeof a!="undefined"},obj:function(a){return a instanceof Object&&!k.fun(a)&&!k.arr(a)}},m={each:function(a,b,c){k.arrLike(a)?j.each(a,b,c):function(){for(var e in a)d.call(a,e)&&b.call(c,e,a[e],a)}()},map:function(a,b,c){var e=[],f=0;return k.arrLike(a)?j.map(a,b,c):!function(){for(var g in a)d.call(a,g)&&(e[f++]=b.call(c,g,a[g],a))}()&&e},pluck:function(a,b){return k.arrLike(a)?j.map(a,function(a){return a[b]}):m.map(a,function(a,c){return c[b]})},toArray:function(a){return a?k.arr(a)?a:a.toArray?a.toArray():k.args(a)?f.call(a):j.map(a,function(a){return a}):[]},first:function(a){return a[0]},last:function(a){return a[a.length-1]},keys:Object.keys?function(a){return Object.keys(a)}:function(a){var b=[],c;for(c in a)d.call(a,c)&&(b[b.length]=c);return b},values:function(a){return m.map(a,function(a,b){return b})},extend:function(){var a,b,c,d,f,g=arguments[0],h=1,i=arguments.length;for(;h<i;h++)if((a=arguments[h])!==e)for(b in a){c=g[b],d=a[b];if(g===d)continue;d&&k.obj(d)?(f=c&&k.obj(c)?c:{},g[b]=m.extend(f,d)):d!==undefined&&(g[b]=d)}return g},trim:String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(i,"")},bind:function(a,b){var c=arguments.length>2?f.call(arguments,2):null;return function(){return b.apply(a,c?c.concat(f.call(arguments)):arguments)}},curry:function(a){if(arguments.length==1)return a;var b=f.call(arguments,1);return function(){return a.apply(null,b.concat(f.call(arguments)))}},parallel:function(a,b){var c=m.toArray(arguments),d=0,f=[],g=[];k.arr(a)||(b=c.pop(),a=c),j.each(a,function(c,h){c(function(){var c=m.toArray(arguments),i=c.shift();if(i)return b(i);f[h]=c,a.length==++d&&(f.unshift(e),j.each(f,function(a){g=g.concat(a)}),b.apply(e,g))})})},waterfall:function(a,b){var c=m.toArray(arguments),d=0;k.arr(a)||(b=c.pop(),a=c),function f(){var c=m.toArray(arguments);c.push(f);var d=c.shift();!d&&a.length?a.shift().apply(e,c):(c.pop(),c.unshift(d),b.apply(e,c))}(e)},queue:function(a){return new n(k.arrLike(a)?a:m.toArray(arguments))}};return n.prototype.next=function(){return this.index<this.values.length&&this.values[this.index++](),this},p(o,j),p(o,m),o.is=k,o.v=o,o.each(o.extend({},j,m),function(a,b){q.prototype[a]=function(){var a=o.toArray(arguments);a.unshift(this.val);var c=b.apply(this._scope,a);return this.val=c,this._chained?this:c}}),p(q.prototype,{chain:function(){return this._chained=1,this},value:function(){return this.val}}),o.noConflict=function(){return a.v=b,this},o}) | ||
(function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"?define(b):this[a]=this.v=b()})("valentine",function(){function n(a){this.values=a,this.index=0}function o(a,b){return new q(a,b)}function p(a,b){for(var c in b)a[c]=b[c]}function q(a,b){this.val=a,this._scope=b||e,this._chained=0}var a=this,b=a.v,c=[],d=Object.prototype.hasOwnProperty,e=null,f=c.slice,g="map"in c,h="reduce"in c,i=/(^\s*|\s*$)/g,j={each:g?function(a,b,d){c.forEach.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)d in a&&b.call(c,a[d],d,a)},map:g?function(a,b,d){return c.map.call(a,b,d)}:function(a,b,c){var d=[],e;for(e=0,l=a.length;e<l;e++)e in a&&(d[e]=b.call(c,a[e],e,a));return d},some:g?function(a,b,c){return a.some(b,c)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(d in a&&b.call(c,a[d],d,a))return!0;return!1},every:g?function(a,b,c){return a.every(b,c)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(d in a&&!b.call(c,a[d],d,a))return!1;return!0},filter:g?function(a,b,c){return a.filter(b,c)}:function(a,b,c){for(var d=[],e=0,f=0,g=a.length;e<g;e++)if(e in a){if(!b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},indexOf:g?function(a,b,c){return a.indexOf(b,isFinite(c)?c:0)}:function(a,b,c){c=c||0,c=c<0?0:c,c=c>a.length?a.length:c;for(var d=c;d<a.length;d++)if(d in a&&a[d]===b)return d;return-1},lastIndexOf:g?function(a,b,c){return a.lastIndexOf(b,isFinite(c)?c:a.length)}:function(a,b,c){c=c||a.length,c=c>=a.length?a.length:c<0?a.length+c:c;for(var d=c;d>=0;--d)if(d in a&&a[d]===b)return d;return-1},reduce:h?function(a,b,d,e){return c.reduce.call(a,b,d,e)}:function(a,b,c,d){a||(a=[]);var e=0,f=a.length;if(arguments.length<3)do{if(e in a){c=a[e++];break}if(++e>=f)throw new TypeError("Empty array")}while(1);for(;e<f;e++)e in a&&(c=b.call(d,c,a[e],e,a));return c},reduceRight:h?function(a,b,d,e){return c.reduceRight.call(a,b,d,e)}:function(a,b,c,d){!a&&(a=[]);var e=a.length,f=e-1;if(arguments.length<3)do{if(f in a){c=a[f--];break}if(--f<0)throw new TypeError("Empty array")}while(1);for(;f>=0;f--)f in a&&(c=b.call(d,c,a[f],f,a));return c},find:function(a,b,c){var d;return j.some(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},reject:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++)if(e in a){if(b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},size:function(a){return m.toArray(a).length},compact:function(a){return j.filter(a,function(a){return!!a})},flatten:function(a){return j.reduce(a,function(a,b){return k.arr(b)?a.concat(j.flatten(b)):(a[a.length]=b,a)},[])},uniq:function(a,b){var c=[],d,e;a=b?j.map(a,b):a;a:for(d=0;d<a.length;d++){for(e=0;e<c.length;e++)if(c[e]===a[d])continue a;c[c.length]=a[d]}return c},merge:function(a,b){var c=a.length,d=0,e;if(isFinite(b.length))for(e=b.length;d<e;d++)a[c++]=b[d];else while(b[d]!==undefined)first[c++]=second[d++];return a.length=c,a},inArray:function(a,b){return!!~j.indexOf(a,b)}},k={fun:function(a){return typeof a=="function"},str:function(a){return typeof a=="string"},ele:function(a){return!!a&&!!a.nodeType&&a.nodeType==1},arr:function(a){return a instanceof Array},arrLike:function(a){return a&&a.length&&isFinite(a.length)},num:function(a){return typeof a=="number"},bool:function(a){return a===!0||a===!1},args:function(a){return!!a&&!!d.call(a,"callee")},emp:function(a){var b=0;return k.arr(a)?a.length===0:k.obj(a)?function(){for(var c in a){b++;break}return b===0}():a===""},dat:function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)},reg:function(a){return!(!(a&&a.test&&a.exec)||!a.ignoreCase&&a.ignoreCase!==!1)},nan:function(a){return a!==a},nil:function(a){return a===e},und:function(a){return typeof a=="undefined"},def:function(a){return typeof a!="undefined"},obj:function(a){return a instanceof Object&&!k.fun(a)&&!k.arr(a)}},m={each:function(a,b,c){k.arrLike(a)?j.each(a,b,c):function(){for(var e in a)d.call(a,e)&&b.call(c,e,a[e],a)}()},map:function(a,b,c){var e=[],f=0;return k.arrLike(a)?j.map(a,b,c):!function(){for(var g in a)d.call(a,g)&&(e[f++]=b.call(c,g,a[g],a))}()&&e},pluck:function(a,b){return k.arrLike(a)?j.map(a,function(a){return a[b]}):m.map(a,function(a,c){return c[b]})},toArray:function(a){return a?k.arr(a)?a:a.toArray?a.toArray():k.args(a)?f.call(a):j.map(a,function(a){return a}):[]},first:function(a){return a[0]},last:function(a){return a[a.length-1]},keys:Object.keys?function(a){return Object.keys(a)}:function(a){var b=[],c;for(c in a)d.call(a,c)&&(b[b.length]=c);return b},values:function(a){return m.map(a,function(a,b){return b})},extend:function(){var a,b,c,d,f,g=arguments[0],h=1,i=arguments.length;for(;h<i;h++)if((a=arguments[h])!==e)for(b in a){c=g[b],d=a[b];if(g===d)continue;d&&k.obj(d)?(f=c&&k.obj(c)?c:{},g[b]=m.extend(f,d)):d!==undefined&&(g[b]=d)}return g},trim:String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(i,"")},bind:function(a,b){var c=arguments.length>2?f.call(arguments,2):null;return function(){return b.apply(a,c?c.concat(f.call(arguments)):arguments)}},curry:function(a){if(arguments.length==1)return a;var b=f.call(arguments,1);return function(){return a.apply(null,b.concat(f.call(arguments)))}},parallel:function(a,b){var c=m.toArray(arguments),d=0,f=[],g=[];if(k.arr(a)&&a.length===0||k.fun(a)&&c.length===1)throw new TypeError("Empty parallel array");k.arr(a)||(b=c.pop(),a=c),j.each(a,function(c,h){c(function(){var c=m.toArray(arguments),i=c.shift();if(i)return b(i);f[h]=c,a.length==++d&&(f.unshift(e),j.each(f,function(a){g=g.concat(a)}),b.apply(e,g))})})},waterfall:function(a,b){var c=m.toArray(arguments),d=0;if(k.arr(a)&&a.length===0||k.fun(a)&&c.length===1)throw new TypeError("Empty waterfall array");k.arr(a)||(b=c.pop(),a=c),function f(){var c=m.toArray(arguments);c.push(f);var d=c.shift();!d&&a.length?a.shift().apply(e,c):(c.pop(),c.unshift(d),b.apply(e,c))}(e)},queue:function(a){return new n(k.arrLike(a)?a:m.toArray(arguments))}};return n.prototype.next=function(){return this.index<this.values.length&&this.values[this.index++](),this},p(o,j),p(o,m),o.is=k,o.v=o,o.each(o.extend({},j,m),function(a,b){q.prototype[a]=function(){var a=o.toArray(arguments);a.unshift(this.val);var c=b.apply(this._scope,a);return this.val=c,this._chained?this:c}}),p(q.prototype,{chain:function(){return this._chained=1,this},value:function(){return this.val}}),o.noConflict=function(){return a.v=b,this},o}) |
55739
1550