Comparing version 1.4.7 to 1.5.1
{ | ||
"name": "valentine" | ||
, "description": "JavaScripts Functional Sister. Utilitiy, Iterators, type checking" | ||
, "version": "1.4.7" | ||
, "version": "1.5.1" | ||
, "homepage": "https://github.com/ded/valentine" | ||
@@ -15,4 +15,7 @@ , "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)" | ||
, "devDependencies": { | ||
"sink-test": ">= 0.0.9" | ||
"sink-test": ">= 1.0.1" | ||
} | ||
, "scripts": { | ||
"test": "make test" | ||
} | ||
} |
\ / _. | _ ._ _|_ o ._ _ | ||
\/ (_| | (/_ | | |_ | | | (/_ | ||
[![Build Status](https://secure.travis-ci.org/ded/valentine.png)](http://travis-ci.org/ded/valentine) | ||
JavaScript's Sister, and protector — providing you with type checking, functional iterators, and common utility helpers; utilizing native JavaScript methods (when available) for optimal speed. | ||
@@ -64,3 +65,4 @@ | ||
* v.trim(str) | ||
* v.bind(scope, fn) | ||
* v.bind(scope, fn, [curried args]) | ||
* v.curry(fn, [curried args]) | ||
* v.inArray(ar, needle) | ||
@@ -201,2 +203,3 @@ * v.parallel([fn args]) | ||
bind | ||
curry | ||
parallel | ||
@@ -203,0 +206,0 @@ waterfall |
@@ -13,2 +13,3 @@ var v = require('valentine') | ||
, bind: v.bind | ||
, curry: v.curry | ||
, parallel: v.parallel | ||
@@ -18,2 +19,2 @@ , waterfall: v.waterfall | ||
, queue: v.queue | ||
}) | ||
}) |
@@ -244,3 +244,3 @@ !function (name, definition) { | ||
, ele: function (el) { | ||
!!(el && el.nodeType && el.nodeType == 1) | ||
return !!(el && el.nodeType && el.nodeType == 1) | ||
} | ||
@@ -413,7 +413,16 @@ | ||
, bind: function (scope, fn) { | ||
var args = arguments.length > 2 ? slice.call(arguments, 2) : null | ||
return function () { | ||
fn.apply(scope, arguments) | ||
return fn.apply(scope, args ? args.concat(slice.call(arguments)) : arguments) | ||
} | ||
} | ||
, curry: function (fn) { | ||
if (arguments.length == 1) return fn | ||
var args = slice.call(arguments, 1) | ||
return function () { | ||
return fn.apply(null, args.concat(slice.call(arguments))) | ||
} | ||
} | ||
, parallel: function (fns, callback) { | ||
@@ -532,2 +541,2 @@ var args = o.toArray(arguments) | ||
return v | ||
}) | ||
}) |
if (typeof module !== 'undefined' && module.exports) { | ||
var s = require('sink-test') | ||
, start = s.start | ||
, sink = s.sink | ||
, v = require('../src/valentine') | ||
// these become globals to make the tests IE-friendly due to stupid hoisting | ||
start = s.start | ||
sink = s.sink | ||
v = require('../src/valentine') | ||
} | ||
@@ -249,16 +250,54 @@ | ||
test('trim', 1, function () { | ||
ok(v.trim(' \n\r omg bbq wtf \n\n ') === 'omg bbq wtf', 'string was trimmed'); | ||
ok(v.trim(' \n\r omg bbq wtf \n\n ') === 'omg bbq wtf', 'string was trimmed') | ||
}) | ||
test('bind', 1, function () { | ||
var o = { | ||
foo: 'bar' | ||
}; | ||
function wha() { | ||
ok(this.foo == 'bar', 'this.foo == "bar"'); | ||
// bind() and curry() are the same except bind() takes a scope argument at the begining | ||
function testBindAndCurry(type) { | ||
var expected, o = { foo: 'bar' }, ret = { bar: 'foo' } | ||
// our function to curry | ||
function itburns() { | ||
type === 'bind' && ok(this === o && this.foo === 'bar', 'bound to correct object') | ||
ok(arguments.length === expected.length, expected.length + ' arguments supplied from curried function') | ||
var isok = true | ||
for (var i = 0; i < expected.length; i++) { | ||
if (expected[i] !== arguments[i]) | ||
isok = false | ||
} | ||
ok(isok, 'arguments identical to expected') | ||
return ret | ||
} | ||
var bound = v.bind(o, wha) | ||
bound(); | ||
// test executor, first arg is what we pass to curry()/bind() as the curry arguments | ||
// second arg is what we call the curried/bound function with, both of these arguments | ||
// together should be what we get in 'expected' | ||
function runtest(curriedargs, calledargs) { | ||
var vargs = (type === 'bind' ? [ o, itburns ] : [ itburns ]).concat(curriedargs) // arguments to pass to v.bind()/v.curry() | ||
, fn = v[type].apply(null, vargs) | ||
var r = fn.apply(null, calledargs) | ||
ok(r === ret, 'returned correct object') | ||
} | ||
expected = [] | ||
runtest([], []) | ||
expected = [ 'additional' ] | ||
runtest([], [ 'additional' ]) | ||
expected = ['one', 'two', [ 'three', 'three' ]] | ||
runtest(expected, []) | ||
expected = [ 'one', 'two', [ 'three', 'three' ], 'additional', [ 'yee', 'haw' ]] | ||
runtest([ 'one', 'two', expected[2] ], [ 'additional', expected[4] ]) | ||
} | ||
test('bind', 16, function () { | ||
testBindAndCurry('bind') | ||
}) | ||
test('curry', 12, function () { | ||
testBindAndCurry('curry') | ||
}) | ||
test('parallel', 3, function () { | ||
@@ -443,83 +482,93 @@ function getTimeline(fn) { | ||
test('String', 3, function () { | ||
ok(v.is.str('hello'), 'v.is.str("hello")'); | ||
ok(v.is.str(''), 'v.is.str("")'); | ||
ok(!v.is.str(null), '!v.is.str(null)'); | ||
}); | ||
ok(v.is.str('hello'), 'v.is.str("hello")') | ||
ok(v.is.str(''), 'v.is.str("")') | ||
ok(!v.is.str(null), '!v.is.str(null)') | ||
}) | ||
test('Function', 6, function () { | ||
ok(v.is.fun(function () {}), 'function () {}'); | ||
ok(v.is.fun(Function), 'Function'); | ||
ok(v.is.fun(new Function), 'new Function'); | ||
ok(!v.is.fun({}), 'not {}'); | ||
ok(!v.is.fun([]), 'not []'); | ||
ok(!v.is.fun(''), 'not ""'); | ||
}); | ||
ok(v.is.fun(function () {}), 'function () {}') | ||
ok(v.is.fun(Function), 'Function') | ||
ok(v.is.fun(new Function), 'new Function') | ||
ok(!v.is.fun({}), 'not {}') | ||
ok(!v.is.fun([]), 'not []') | ||
ok(!v.is.fun(''), 'not ""') | ||
}) | ||
test('Array', 4, function () { | ||
ok(v.is.arr([]), '[]'); | ||
ok(v.is.arr(Array(1)), 'Array(1)'); | ||
ok(v.is.arr(new Array), 'new Array'); | ||
ok(!v.is.arr(Object), 'not Object'); | ||
}); | ||
ok(v.is.arr([]), '[]') | ||
ok(v.is.arr(Array(1)), 'Array(1)') | ||
ok(v.is.arr(new Array), 'new Array') | ||
ok(!v.is.arr(Object), 'not Object') | ||
}) | ||
test('Number', 3, function () { | ||
ok(v.is.num(1), '1'); | ||
ok(v.is.num(1.1), '1.1'); | ||
ok(!v.is.num('1'), '"1"'); | ||
}); | ||
ok(v.is.num(1), '1') | ||
ok(v.is.num(1.1), '1.1') | ||
ok(!v.is.num('1'), '"1"') | ||
}) | ||
test('Boolean', 6, function () { | ||
ok(v.is.bool(false), 'false'); | ||
ok(v.is.bool(true), 'true'); | ||
ok(v.is.bool(!0), '!0'); | ||
ok(v.is.bool(!!1), '!!1'); | ||
ok(!v.is.bool('true'), '"true"'); | ||
ok(!v.is.bool('false'), '"false"'); | ||
}); | ||
ok(v.is.bool(false), 'false') | ||
ok(v.is.bool(true), 'true') | ||
ok(v.is.bool(!0), '!0') | ||
ok(v.is.bool(!!1), '!!1') | ||
ok(!v.is.bool('true'), '"true"') | ||
ok(!v.is.bool('false'), '"false"') | ||
}) | ||
test('Arguments', 1, function () { | ||
(function () { | ||
ok(v.is.args(arguments), 'arguments'); | ||
})(); | ||
}); | ||
ok(v.is.args(arguments), 'arguments') | ||
})() | ||
}) | ||
test('Empty', 6, function () { | ||
ok(v.is.emp({}), '{}'); | ||
ok(v.is.emp([]), '[]'); | ||
ok(v.is.emp(''), '""'); | ||
ok(!v.is.emp({foo:'bar'}), '{foo:bar}'); | ||
ok(!v.is.emp([1]), '[1]'); | ||
ok(!v.is.emp('i'), '"i"'); | ||
}); | ||
ok(v.is.emp({}), '{}') | ||
ok(v.is.emp([]), '[]') | ||
ok(v.is.emp(''), '""') | ||
ok(!v.is.emp({foo:'bar'}), '{foo:bar}') | ||
ok(!v.is.emp([1]), '[1]') | ||
ok(!v.is.emp('i'), '"i"') | ||
}) | ||
test('Date', 1, function () { | ||
ok(v.is.dat(new Date), 'new Date'); | ||
}); | ||
ok(v.is.dat(new Date), 'new Date') | ||
}) | ||
test('RegExp', 2, function () { | ||
ok(v.is.reg(/i/), '/i/'); | ||
ok(v.is.reg(new RegExp("i")), 'new RegExp("i")'); | ||
}); | ||
ok(v.is.reg(/i/), '/i/') | ||
ok(v.is.reg(new RegExp("i")), 'new RegExp("i")') | ||
}) | ||
test('Null', 3, function () { | ||
ok(v.is.nil(null), 'null'); | ||
ok(!v.is.nil(""), '""'); | ||
ok(!v.is.nil(), 'undefined'); | ||
}); | ||
ok(v.is.nil(null), 'null') | ||
ok(!v.is.nil(""), '""') | ||
ok(!v.is.nil(), 'undefined') | ||
}) | ||
test('Undefined', 3, function () { | ||
ok(v.is.und(), 'no args'); | ||
ok(v.is.und(undefined), 'undefined'); | ||
ok(!v.is.und(null), 'undefined'); | ||
}); | ||
ok(v.is.und(), 'no args') | ||
ok(v.is.und(undefined), 'undefined') | ||
ok(!v.is.und(null), 'undefined') | ||
}) | ||
test('Object', 4, function () { | ||
ok(v.is.obj({}), '{}'); | ||
ok(v.is.obj(new Object), 'Object'); | ||
ok(!v.is.obj([]), 'not []'); | ||
ok(!v.is.obj(function() {}), 'not function(){}'); | ||
}); | ||
ok(v.is.obj({}), '{}') | ||
ok(v.is.obj(new Object), 'Object') | ||
ok(!v.is.obj([]), 'not []') | ||
ok(!v.is.obj(function() {}), 'not function(){}') | ||
}) | ||
}); | ||
if (typeof window !== 'undefined' && window.document) { | ||
test('Element', 5, function () { | ||
ok(v.is.ele(document.body), 'document.body') | ||
ok(v.is.ele(document.createElement('div')), 'createElement("div")') | ||
ok(!v.is.ele({}), 'not {}') | ||
ok(!v.is.ele([]), 'not []') | ||
ok(!v.is.ele(document.getElementsByTagName('body')), 'not getElementsByTagName()') | ||
}) | ||
} | ||
}) | ||
sink('OO Style and chaining', function (test, ok) { | ||
@@ -553,2 +602,2 @@ | ||
start() | ||
start() |
@@ -251,3 +251,3 @@ /*! | ||
, ele: function (el) { | ||
!!(el && el.nodeType && el.nodeType == 1) | ||
return !!(el && el.nodeType && el.nodeType == 1) | ||
} | ||
@@ -420,7 +420,16 @@ | ||
, bind: function (scope, fn) { | ||
var args = arguments.length > 2 ? slice.call(arguments, 2) : null | ||
return function () { | ||
fn.apply(scope, arguments) | ||
return fn.apply(scope, args ? args.concat(slice.call(arguments)) : arguments) | ||
} | ||
} | ||
, curry: function (fn) { | ||
if (arguments.length == 1) return fn | ||
var args = slice.call(arguments, 1) | ||
return function () { | ||
return fn.apply(null, args.concat(slice.call(arguments))) | ||
} | ||
} | ||
, parallel: function (fns, callback) { | ||
@@ -539,2 +548,2 @@ var args = o.toArray(arguments) | ||
return v | ||
}) | ||
}) |
@@ -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={},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;for(var d=0;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){var b=[],c,d;a:for(c=0;c<a.length;c++){for(d=0;d<b.length;d++)if(b[d]==a[c])continue a;b[b.length]=a[c]}return b},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){!!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.hasOwnProperty.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.hasOwnProperty.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.hasOwnProperty.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.hasOwnProperty.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){return function(){b.apply(a,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={},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;for(var d=0;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){var b=[],c,d;a:for(c=0;c<a.length;c++){for(d=0;d<b.length;d++)if(b[d]==a[c])continue a;b[b.length]=a[c]}return b},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.hasOwnProperty.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.hasOwnProperty.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.hasOwnProperty.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.hasOwnProperty.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}) |
Sorry, the diff of this file is not supported yet
53879
13
1518
228