Linqjs and Backbone Collections

Feb 26, 2014 at 4:00 PM
I'm working with Backbone.js. Backbone uses underscore.js, which is severely lacking in it's collection sorting (not to mention no method chaining). So I want to go back to using linq.js. I want it to be enumerable so I don't want to be converting it from a backbone model to JSON and vice versa. I added a function into the linq.js file to setup the enumerator, but I can't figure out how to extend or prototype it into Backbone so I don't need to modify the source of the linq.js. Can anyone help?

The main problem I'm having is I don't now how to specify the tryGetNext function in the IEnumerator.

Here is the code i added into linq.js:
Enumerable.FromBackbone = function (obj)
        if (obj == null)
            return Enumerable.Empty();
        return new Enumerable(
            function() {
                var index = 0;
                return new IEnumerator(
                    function() {},
                    function() {
                        return (index < obj.length) ? this.Yield( : false;
                    function() {});