Browse files

- all tests for iters and utils passing

  • Loading branch information...
1 parent a6bc76c commit 834d6ffc42fb54ce65068f23358d61475075ee20 @ded committed May 2, 2011
Showing with 278 additions and 106 deletions.
  1. +1 −0 .gitignore
  2. +7 −6 README.md
  3. +3 −3 make/build.js
  4. +1 −0 node_modules/.bin/smoosh
  5. +1 −0 node_modules/smoosh
  6. +2 −2 package.json
  7. +2 −2 src/copyright.js
  8. +58 −44 src/valentine.js
  9. +140 −0 tests/tests.js
  10. +60 −46 valentine.js
  11. +3 −3 valentine.min.js
View
1 .gitignore
@@ -0,0 +1 @@
+node_modules
View
13 README.md
@@ -1,6 +1,7 @@
-Valentine
----------
-JavaScript's Sister.
+\ / _. | _ ._ _|_ o ._ _
+ \/ (_| | (/_ | | |_ | | | (/_
+
+JavaScript's Sister, and protector. Valentine provides you with type checking, functional iterators, and basic utility helpers.
API
---
@@ -21,18 +22,18 @@ API
* v.pluck()
* v.toArray()
- * v.invoke()
* v.size()
* v.reject()
* v.find()
- * v.contains()
* v.compact()
* v.flatten()
* v.uniq()
* v.first()
* v.last()
+ * v.keys()
+ * v.trim()
-<h2>type checking</h2>
+<h3>type checking</h3>
* v.is.fun()
* v.is.str()
View
6 make/build.js
@@ -1,4 +1,4 @@
-require('../build/smoosh').config({
+require('smoosh').config({
"JAVASCRIPT": {
"DIST_DIR": "./",
"valentine": [
@@ -8,8 +8,8 @@ require('../build/smoosh').config({
},
"JSHINT_OPTS": {
"boss": true,
- "forin": true,
- "curly": true,
+ "forin": false,
+ "curly": false,
"debug": false,
"devel": false,
"evil": false,
View
1 node_modules/.bin/smoosh
View
1 node_modules/smoosh
View
4 package.json
@@ -1,9 +1,9 @@
{
"name": "valentine",
"description": "JavaScripts sister.",
- "version": "0.0.1",
+ "version": "0.0.2",
"homepage": "https://github.com/ded/valentine",
- "authors": ["Dustin Diaz <@ded>", "Jacob Thornton <@fat>"],
+ "authors": "Dustin Diaz <@ded>",
"repository": {
"type": "git",
"url": "https://github.com/ded/valentine.git"
View
4 src/copyright.js
@@ -1,6 +1,6 @@
/*!
- * Valentine: When writing JavaScript, Valentine is your sister.
- * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)
+ * Valentine: JavaScript's Sister
+ * copyright Dustin Diaz 2011 (@ded)
* https://github.com/ded/valentine
* License MIT
*/
View
102 src/valentine.js
@@ -3,8 +3,10 @@
var v = {},
ap = Array.prototype,
op = Object.prototype,
+ slice = ap.slice,
nativ = !!('map' in ap),
- nativ18 = !!('reduce' in ap);
+ nativ18 = !!('reduce' in ap),
+ trimReplace = /(^\s*|\s*$)/g;
var iters = {
each: nativ ?
@@ -67,7 +69,7 @@
},
indexOf: nativ ?
function (a, el, start) {
- return ap.indexOf.call(a, el, start);
+ return a.indexOf(el, isFinite(start) ? start : 0);
} :
function (a, el, start) {
start = start || 0;
@@ -78,9 +80,10 @@
}
return -1;
},
+
lastIndexOf: nativ ?
function (a, el, start) {
- return ap.lastIndexOf.call(a, el, start);
+ return a.lastIndexOf(el, isFinite(start) ? start : a.length);
} :
function (a, el, start) {
start = start || a.length;
@@ -93,6 +96,7 @@
}
return -1;
},
+
reduce: nativ18 ?
function (o, i, m, c) {
return ap.reduce.call(o, i, m, c);
@@ -118,10 +122,10 @@
function (o, i, m, c) {
return ap.reduceRight.call(o, i, m, c);
} :
- function (obj, iterator, memo, context) {
- !obj && (obj = []);
- var reversed = (is.arr(obj) ? obj.slice() : o.toArray(obj)).reverse();
- return iters.reduce(reversed, iterator, memo, context);
+ function (ob, i, m, c) {
+ !ob && (ob = []);
+ var reversed = (is.arr(ob) ? ob.slice() : o.toArray(ob)).reverse();
+ return iters.reduce(reversed, i, m, c);
},
find: function (obj, iterator, context) {
@@ -150,16 +154,9 @@
return o.toArray(a).length;
},
- invoke: function (obj, method) {
- var args = ap.slice.call(arguments, 2);
- return iters.map(obj, function (value) {
- return (method ? value[method] : value).apply(value, args);
- });
- },
-
- pluck: function (o, k) {
- return iters.map(o, function (v) {
- return v[k];
+ pluck: function (ar, k) {
+ return iters.map(ar, function (el) {
+ return el[k];
});
},
@@ -171,39 +168,26 @@
flatten: function (a) {
return iters.reduce(a, function (memo, value) {
- if (o.isArray(value)) {
+ if (is.arr(value)) {
return memo.concat(iters.flatten(value));
}
memo[memo.length] = value;
return memo;
}, []);
},
- contains: function (obj, target) {
- var found = false;
- if (!obj) {
- return found;
- }
- if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
- return obj.indexOf(target) != -1;
- }
- iters.some(obj, function (value) {
- if (found = value === target) {
- return true;
- }
- });
- return found;
- },
-
- uniq: function (a, isSorted) {
- return iters.reduce(a, function (memo, el, i) {
- if (0 === i || (isSorted === true ?
- iters.last(memo) != el :
- !iters.contains(memo, el))) {
- memo[memo.length] = el;
+ uniq: function (ar) {
+ var a = [], i, j;
+ label:
+ for (i = 0; i < ar.length; i++) {
+ for (j = 0; j < a.length; j++) {
+ if (a[j] == ar[i]) {
+ continue label;
+ }
}
- return memo;
- }, []);
+ a[a.length] = ar[i];
+ }
+ return a;
},
first: function (a) {
@@ -212,7 +196,37 @@
last: function (a) {
return a[a.length - 1];
- }
+ },
+
+ keys: Object.keys ?
+ function (o) {
+ return Object.keys(o);
+ } :
+ function (obj) {
+ var keys = [];
+ for (var key in obj) {
+ op.hasOwnProperty.call(obj, key) && (keys[keys.length] = key);
+ }
+ return keys;
+ },
+
+ extend: function (ob) {
+ o.each(slice.call(arguments, 1), function (source) {
+ for (var prop in source) {
+ !is.und(source[prop]) && (ob[prop] = source[prop]);
+ }
+ });
+ return ob;
+ },
+
+ trim: String.prototype.trim ?
+ function (s) {
+ return s.trim();
+ } :
+ function (s) {
+ return s.replace(trimReplace, '');
+ }
+
};
function aug(o, o2) {
@@ -303,7 +317,7 @@
return a;
}
if (is.args(a)) {
- return ap.slice.call(a);
+ return slice.call(a);
}
return iters.map(a, function (k, v) {
return k;
View
140 tests/tests.js
@@ -32,6 +32,146 @@ sink('Arrays', function(test, ok, before, after) {
ok(om[0] === 'bar' && om[1] === 'thunk', 'map of objects');
});
+
+ test('every', 2, function () {
+ var a1 = ['a', 'a', 'a'];
+ var a2 = ['a', 'a', 'b'];
+
+ ok(v.every(a1, function (el) {
+ return el == 'a'
+ }), 'all elements in array are "a"');
+
+ ok(!v.every(a2, function (el) {
+ return el == 'a'
+ }), 'all elements in array are not "a"');
+ });
+
+ test('some', 2, function () {
+ var a1 = ['a', 'a', 'a'];
+ var a2 = ['a', 'a', 'b'];
+
+ ok(!v.some(a1, function (el) {
+ return el == 'b'
+ }), 'no elements in array have "b"');
+
+ ok(v.some(a2, function (el) {
+ return el == 'b'
+ }), 'some elements in array have "b"');
+ });
+
+ test('filter', 1, function () {
+ var a = v.filter(['a', 'b', 'virus', 'c'], function (el) {
+ return el !== 'virus';
+ });
+ var expected = ['a', 'b', 'c'];
+ ok(v.every(expected, function (el, i) {
+ return el == a[i];
+ }), 'filters out viruses');
+ });
+
+ test('indexOf', 2, function () {
+ ok(v.indexOf(['a', 'b', 'c'], 'b') == 1, 'indexOf b == 1');
+ ok(v.indexOf(['x', 'y', 'z'], 'b') == -1, 'indexOf b == -1');
+ });
+
+ test('lastIndexOf', 2, function () {
+ ok(v.lastIndexOf(['a', 'b', 'c'], 'c') == 2, 'indexOf c == 2');
+ ok(v.lastIndexOf(['x', 'y', 'z'], 'b') == -1, 'indexOf b == -1');
+ });
+
+});
+
+sink('Utility', function (test, ok) {
+ test('extend', 2, function () {
+ var o = {
+ foo: 'bar'
+ };
+ var out = v.extend(o, { baz: 'thunk' });
+ ok(out.foo == 'bar', 'contains foo property');
+ ok(out.baz == 'thunk', 'contains baz property');
+ });
+
+ test('pluck', 1, function () {
+ var o = [
+ {a: 'foo'},
+ {a: 'bar'},
+ {a: 'baz'}
+ ];
+ var expected = ['foo', 'bar', 'baz'];
+ ok(v.every(v.pluck(o, 'a'), function (el, i) {
+ return el == expected[i];
+ }, 'plucked foo bar baz'));
+ });
+
+ test('toArray', 1, function () {
+ var el = document.getElementsByTagName('div');
+ ok(v.toArray(el) instanceof Array, 'element collection is now an array');
+ });
+
+ test('size', 1, function () {
+ ok(v.size(['a', 'b', 'c']) == 3, 'size is 3');
+ });
+
+ test('reject', 1, function () {
+ var a = v.reject(['a', 'b', 'virus', 'c'], function (el) {
+ return el === 'virus';
+ });
+ var expected = ['a', 'b', 'c'];
+ ok(v.every(expected, function (el, i) {
+ return el == a[i];
+ }), 'filters out viruses');
+ });
+
+ test('find', 1, function () {
+ ok(v.find(['a', 'b', 'c'], function (el) {
+ return el === 'a';
+ }) === 'a', 'found element "a"');
+ });
+
+ test('compact', 1, function () {
+ ok(v.compact([,,,1,false,0,null,'']).length == 1, 'compacted [,,,1,false,0,null,""] to [1]');
+ });
+
+ test('flatten', 1, function () {
+ var actual = v.flatten([['a', [[['b']], ['c']], 'd']]);
+ var expected = ['a', 'b', 'c', 'd'];
+ ok(v.every(actual, function (el, i) {
+ return el == expected[i];
+ }), 'flattened a really crappy looking array');
+ });
+
+ test('uniq', 1, function () {
+ var actual = v.uniq(['a', 'a', 'a', 'b', 'b', 'c']);
+ var expected = ['a', 'b', 'c'];
+ ok(v.every(actual, function (el, i) {
+ return el == expected[i];
+ }), "turned ['a', 'a', 'a', 'b', 'b', 'c'] into ['a', 'b', 'c']");
+ });
+
+ test('first', 1, function () {
+ ok(v.first(['a', 'b', 'c']) == 'a', 'a is first');
+ });
+
+ test('last', 1, function () {
+ ok(v.last(['a', 'b', 'c']) == 'c', 'c is last');
+ });
+
+ test('keys', 1, function () {
+ var actual = v.keys({
+ a: 'foo',
+ b: 'bar',
+ c: 'baz'
+ });
+ var expected = ['a', 'b', 'c'];
+ ok(v.every(actual, function (el, i) {
+ return el == expected[i];
+ }), "a, b, c were keys");
+ });
+
+ test('trim', 1, function () {
+ ok(v.trim(' omg bbq wtf ') === 'omg bbq wtf', 'string was trimmed');
+ });
+
});
start();
View
106 valentine.js
@@ -1,6 +1,6 @@
/*!
- * Valentine: When writing JavaScript, Valentine is your sister.
- * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)
+ * Valentine: JavaScript's Sister
+ * copyright Dustin Diaz 2011 (@ded)
* https://github.com/ded/valentine
* License MIT
*/
@@ -10,8 +10,10 @@
var v = {},
ap = Array.prototype,
op = Object.prototype,
+ slice = ap.slice,
nativ = !!('map' in ap),
- nativ18 = !!('reduce' in ap);
+ nativ18 = !!('reduce' in ap),
+ trimReplace = /(^\s*|\s*$)/g;
var iters = {
each: nativ ?
@@ -74,7 +76,7 @@
},
indexOf: nativ ?
function (a, el, start) {
- return ap.indexOf.call(a, el, start);
+ return a.indexOf(el, isFinite(start) ? start : 0);
} :
function (a, el, start) {
start = start || 0;
@@ -85,9 +87,10 @@
}
return -1;
},
+
lastIndexOf: nativ ?
function (a, el, start) {
- return ap.lastIndexOf.call(a, el, start);
+ return a.lastIndexOf(el, isFinite(start) ? start : a.length);
} :
function (a, el, start) {
start = start || a.length;
@@ -100,6 +103,7 @@
}
return -1;
},
+
reduce: nativ18 ?
function (o, i, m, c) {
return ap.reduce.call(o, i, m, c);
@@ -125,10 +129,10 @@
function (o, i, m, c) {
return ap.reduceRight.call(o, i, m, c);
} :
- function (obj, iterator, memo, context) {
- !obj && (obj = []);
- var reversed = (is.arr(obj) ? obj.slice() : o.toArray(obj)).reverse();
- return iters.reduce(reversed, iterator, memo, context);
+ function (ob, i, m, c) {
+ !ob && (ob = []);
+ var reversed = (is.arr(ob) ? ob.slice() : o.toArray(ob)).reverse();
+ return iters.reduce(reversed, i, m, c);
},
find: function (obj, iterator, context) {
@@ -157,16 +161,9 @@
return o.toArray(a).length;
},
- invoke: function (obj, method) {
- var args = ap.slice.call(arguments, 2);
- return iters.map(obj, function (value) {
- return (method ? value[method] : value).apply(value, args);
- });
- },
-
- pluck: function (o, k) {
- return iters.map(o, function (v) {
- return v[k];
+ pluck: function (ar, k) {
+ return iters.map(ar, function (el) {
+ return el[k];
});
},
@@ -178,39 +175,26 @@
flatten: function (a) {
return iters.reduce(a, function (memo, value) {
- if (o.isArray(value)) {
+ if (is.arr(value)) {
return memo.concat(iters.flatten(value));
}
memo[memo.length] = value;
return memo;
}, []);
},
- contains: function (obj, target) {
- var found = false;
- if (!obj) {
- return found;
- }
- if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
- return obj.indexOf(target) != -1;
- }
- iters.some(obj, function (value) {
- if (found = value === target) {
- return true;
- }
- });
- return found;
- },
-
- uniq: function (a, isSorted) {
- return iters.reduce(a, function (memo, el, i) {
- if (0 === i || (isSorted === true ?
- iters.last(memo) != el :
- !iters.contains(memo, el))) {
- memo[memo.length] = el;
+ uniq: function (ar) {
+ var a = [], i, j;
+ label:
+ for (i = 0; i < ar.length; i++) {
+ for (j = 0; j < a.length; j++) {
+ if (a[j] == ar[i]) {
+ continue label;
+ }
}
- return memo;
- }, []);
+ a[a.length] = ar[i];
+ }
+ return a;
},
first: function (a) {
@@ -219,7 +203,37 @@
last: function (a) {
return a[a.length - 1];
- }
+ },
+
+ keys: Object.keys ?
+ function (o) {
+ return Object.keys(o);
+ } :
+ function (obj) {
+ var keys = [];
+ for (var key in obj) {
+ op.hasOwnProperty.call(obj, key) && (keys[keys.length] = key);
+ }
+ return keys;
+ },
+
+ extend: function (ob) {
+ o.each(slice.call(arguments, 1), function (source) {
+ for (var prop in source) {
+ !is.und(source[prop]) && (ob[prop] = source[prop]);
+ }
+ });
+ return ob;
+ },
+
+ trim: String.prototype.trim ?
+ function (s) {
+ return s.trim();
+ } :
+ function (s) {
+ return s.replace(trimReplace, '');
+ }
+
};
function aug(o, o2) {
@@ -310,7 +324,7 @@
return a;
}
if (is.args(a)) {
- return ap.slice.call(a);
+ return slice.call(a);
}
return iters.map(a, function (k, v) {
return k;
View
6 valentine.min.js
@@ -1,7 +1,7 @@
/*!
- * Valentine: When writing JavaScript, Valentine is your sister.
- * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)
+ * Valentine: JavaScript's Sister
+ * copyright Dustin Diaz 2011 (@ded)
* https://github.com/ded/valentine
* License MIT
*/
-!function(a){function h(a,b){for(var c in b)a[c]=b[c]}var b={},c=Array.prototype,d=Object.prototype,e="map"in c,f="reduce"in c,g={each:e?function(a,b,d){c.forEach.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)b.call(c,a[d],d,a)},map:e?function(a,b,d){return c.map.call(a,b,d)}:function(a,b,c){var d=[];for(var e=0,f=a.length;e<f;e++)d[e]=b.call(c,a[e],e,a);return d},some:e?function(a,b,d){return c.some.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(b.call(c,a[d],d,a))return!0;return!1},every:e?function(a,b,d){return c.every.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(!b.call(c,a[d],d,a))return!1;return!0},filter:e?function(a,b,d){return c.filter.call(a,b,d)}:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++){if(!b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},indexOf:e?function(a,b,d){return c.indexOf.call(a,b,d)}:function(a,b,c){c=c||0;for(var d=0;d<a.length;d++)if(a[d]===b)return d;return-1},lastIndexOf:e?function(a,b,d){return c.lastIndexOf.call(a,b,d)}: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(a[d]===b)return d;return-1},reduce:f?function(a,b,d,e){return c.reduce.call(a,b,d,e)}:function(a,b,c,d){var e=!i.und(c);!a&&(a=[]),g.each(a,function(a,f,g){!e&&f===0?(c=a,e=!0):c=b.call(d,c,a,f,g)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},reduceRight:f?function(a,b,d,e){return c.reduceRight.call(a,b,d,e)}:function(a,b,c,d){!a&&(a=[]);var e=(i.arr(a)?a.slice():j.toArray(a)).reverse();return g.reduce(e,b,c,d)},find:function(a,b,c){var d;g.some(a,function(a,e,f){if(b.call(c,a,e,f)){d=a;return!0}});return d},reject:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++){if(b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},size:function(a){return j.toArray(a).length},invoke:function(a,b){var d=c.slice.call(arguments,2);return g.map(a,function(a){return(b?a[b]:a).apply(a,d)})},pluck:function(a,b){return g.map(a,function(a){return a[b]})},compact:function(a){return g.filter(a,function(a){return!!a})},flatten:function(a){return g.reduce(a,function(a,b){if(j.isArray(b))return a.concat(g.flatten(b));a[a.length]=b;return a},[])},contains:function(a,b){var c=!1;if(!a)return c;if(nativeIndexOf&&a.indexOf===nativeIndexOf)return a.indexOf(b)!=-1;g.some(a,function(a){if(c=a===b)return!0});return c},uniq:function(a,b){return g.reduce(a,function(a,c,d){if(0===d||(b===!0?g.last(a)!=c:!g.contains(a,c)))a[a.length]=c;return a},[])},first:function(a){return a[0]},last:function(a){return a[a.length-1]}},i={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},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 i.arr(a)?a.length===0:i.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===null},und:function(a){return typeof a=="undefined"}},j={each:function(a,b,c){i.arr(a)?g.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 i.arr(a)?g.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},toArray:function(a){if(!a)return[];if(a.toArray)return a.toArray();if(i.arr(a))return a;if(i.args(a))return c.slice.call(a);return g.map(a,function(a,b){return a})}};h(b,g),h(b,j),b.is=i;var k=a.v;b.noConflict=function(){a.v=k;return this},typeof module!="undefined"&&module.exports?module.exports=b:a.v=b}(this)
+!function(a){function j(a,b){for(var c in b)a[c]=b[c]}var b={},c=Array.prototype,d=Object.prototype,e=c.slice,f="map"in c,g="reduce"in c,h=/(^\s*|\s*$)/g,i={each:f?function(a,b,d){c.forEach.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)b.call(c,a[d],d,a)},map:f?function(a,b,d){return c.map.call(a,b,d)}:function(a,b,c){var d=[];for(var e=0,f=a.length;e<f;e++)d[e]=b.call(c,a[e],e,a);return d},some:f?function(a,b,d){return c.some.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(b.call(c,a[d],d,a))return!0;return!1},every:f?function(a,b,d){return c.every.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(!b.call(c,a[d],d,a))return!1;return!0},filter:f?function(a,b,d){return c.filter.call(a,b,d)}:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++){if(!b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},indexOf:f?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(a[d]===b)return d;return-1},lastIndexOf:f?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(a[d]===b)return d;return-1},reduce:g?function(a,b,d,e){return c.reduce.call(a,b,d,e)}:function(a,b,c,d){var e=!k.und(c);!a&&(a=[]),i.each(a,function(a,f,g){!e&&f===0?(c=a,e=!0):c=b.call(d,c,a,f,g)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},reduceRight:g?function(a,b,d,e){return c.reduceRight.call(a,b,d,e)}:function(a,b,c,d){!a&&(a=[]);var e=(k.arr(a)?a.slice():l.toArray(a)).reverse();return i.reduce(e,b,c,d)},find:function(a,b,c){var d;i.some(a,function(a,e,f){if(b.call(c,a,e,f)){d=a;return!0}});return d},reject:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++){if(b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},size:function(a){return l.toArray(a).length},pluck:function(a,b){return i.map(a,function(a){return a[b]})},compact:function(a){return i.filter(a,function(a){return!!a})},flatten:function(a){return i.reduce(a,function(a,b){if(k.arr(b))return a.concat(i.flatten(b));a[a.length]=b;return a},[])},uniq:function(a){var b=[],c,d;label:for(c=0;c<a.length;c++){for(d=0;d<b.length;d++)if(b[d]==a[c])continue label;b[b.length]=a[c]}return b},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=[];for(var c in a)d.hasOwnProperty.call(a,c)&&(b[b.length]=c);return b},extend:function(a){l.each(e.call(arguments,1),function(b){for(var c in b)!k.und(b[c])&&(a[c]=b[c])});return a},trim:String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(h,"")}},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},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===null},und:function(a){return typeof a=="undefined"}},l={each:function(a,b,c){k.arr(a)?i.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.arr(a)?i.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},toArray:function(a){if(!a)return[];if(a.toArray)return a.toArray();if(k.arr(a))return a;if(k.args(a))return e.call(a);return i.map(a,function(a,b){return a})}};j(b,i),j(b,l),b.is=k;var m=a.v;b.noConflict=function(){a.v=m;return this},typeof module!="undefined"&&module.exports?module.exports=b:a.v=b}(this)

0 comments on commit 834d6ff

Please sign in to comment.