Skip to content
Browse files

Merge branch 'master' of http://github.com/scottgonzalez/JSLINQ

  • Loading branch information...
2 parents 0456e83 + e17a51b commit 07a9e4988806ea29d0cf4842b05c32e88c641b3a @Marak committed May 5, 2010
Showing with 18 additions and 27 deletions.
  1. +18 −27 lib/JSLINQ.js
View
45 lib/JSLINQ.js
@@ -18,7 +18,9 @@
// The current version of JSLINQ being used
jslinq: "2.10",
- ToArray: function() { return this.items; },
+ ToArray: function() {
+ return this.items;
+ },
Where: function(clause) {
var newArray = [];
@@ -47,25 +49,25 @@
tempArray[tempArray.length] = this.items[i];
}
return new JSLINQ(
- tempArray.sort(function(a, b) {
- var x = clause(a);
- var y = clause(b);
- return ((x < y) ? -1 : ((x > y) ? 1 : 0));
- })
- );
+ tempArray.sort(function(a, b) {
+ var x = clause(a);
+ var y = clause(b);
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+ })
+ );
},
OrderByDescending: function(clause) {
var tempArray = [];
for (var i = 0, length = this.items.length; i < length; i++) {
tempArray[tempArray.length] = this.items[i];
}
return new JSLINQ(
- tempArray.sort(function(a, b) {
- var x = clause(b);
- var y = clause(a);
- return ((x < y) ? -1 : ((x > y) ? 1 : 0));
- })
- );
+ tempArray.sort(function(a, b) {
+ var x = clause(b);
+ var y = clause(a);
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+ })
+ );
},
SelectMany: function(clause) {
var r = [];
@@ -75,10 +77,7 @@
return new JSLINQ(r);
},
Count: function(clause) {
- if (clause == null)
- return this.items.length;
- else
- return this.Where(clause).items.length;
+ return (clause == null ? this : this.Where(clause)).items.length;
},
Distinct: function(clause) {
var item;
@@ -92,7 +91,6 @@
retVal[retVal.length] = item;
}
}
- dict = null;
return new JSLINQ(retVal);
},
Any: function(clause) {
@@ -141,17 +139,10 @@
return this.items[index];
},
Concat: function(array) {
- var arr = array.items || array;
- return new JSLINQ(this.items.concat(arr));
+ return new JSLINQ(this.items.concat(array.items || array));
},
Intersect: function(secondArray, clause) {
- var clauseMethod;
- if (clause != undefined) {
- clauseMethod = clause;
- } else {
- clauseMethod = function(item, index, item2, index2) { return item == item2; };
- }
-
+ var clauseMethod = clause || function(item, index, item2, index2) { return item == item2; };
var sa = secondArray.items || secondArray;
var result = [];

0 comments on commit 07a9e49

Please sign in to comment.
Something went wrong with that request. Please try again.