fordth / jinqJs

jinqJs provides a simple way to perform SQL like queries on javaScript arrays, collections and web services using LINQ expressions.
Other
93 stars 29 forks source link

distinct() from array not args #4

Closed jinhduong closed 9 years ago

jinhduong commented 9 years ago

I like your lib, i used it for my project, but when use distinct() function, i want input array parameters (it is variable) not args, because sometimes it is dynamic variable. so i think in line 859, we can change it is

else {
                var argsDistinct = arguments;
                if (Array.isArray(arguments[0]))
                    argsDistinct = arguments[0];
                for (index = 0; index < len; index++) {
                    row = condenseToFields(result[index], argsDistinct);
                    for (var fieldIndex = 0; fieldIndex < argsDistinct.length; fieldIndex++) {

                        field = argsDistinct[fieldIndex];
                        if (!arrayItemFieldValueExists(collection, field, row[field])) {
                            collection.push(row);
                            break;
                        }
                    }
                }
            }

Thanks, jinhduong

fordth commented 9 years ago

Ok, thanks. I will take a look and get back to you within the week.

fordth commented 9 years ago

I am working on adding your change and should have it implemented and tested early today.

fordth commented 9 years ago

Ok, version 1.4 has been released which supports the .distinct() function taking in an array.