This project has moved. For the latest updates, please go here.
2
Vote

Select function has problems

description

Very good work!
Some minor problems I have found has to do with the Select function, which does not allow return items to be null and also has some performance issue.
 
This is how it is now:
 
Select: function(clause) {
        var item;
        var newArray = new Array();
 
        // The clause was passed in as a Method that returns a Value
        for (var i = 0; i < this.items.length; i++) {
            if (clause(this.items[i])) {
                newArray[newArray.length] = clause(this.items[i]);
            }
        }
        return new JSLINQ(newArray);
    }
 
 
This is how i think it should be:
Select: function(clause) {
        var item;
        var newArray = new Array();
 
        // The clause was passed in as a Method that returns a Value
        for (var i = 0; i < this.items.length; i++) {
            newArray[newArray.length] = clause(this.items[i]);
        }
        return new JSLINQ(newArray);
    }
 
Actually i totally removed the check : if (clause(this.items[i])) {
I think this must be a left over from the "Where" function, where it was indeed needed.
 
Thanks!

comments

Konstantinos wrote May 1, 2015 at 4:08 PM

Good catch!
I don't see the author responding to this by any means though... :(
My findings and a fixed version are here:
https://jslinq.codeplex.com/workitem/10932
I guess we will have to make ourselves a newer version of this library...