Sha256: 6a6f6316313cea9dc5a0a62dcf22930cd47815633806f158fdd3b35b9f360641

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

var
    esPhinx;


(function($) {
    "use strict";


    $.extend({
        Collection: {}
    });

    $.Extender.extend($.Collection, true, {
        new: function(collection) {
            var
                asArray,
                self = $.Collection,
                ConstructorReference = self.new,

                callback = function(object1, object2) {
                    // debugger
                    // if (Object.classForName(Object.className(object1))
                    if (object1.constructor
                        .implementsMethod("compareTo")) {
                        return object1.compareTo(object2);
                    }
                };

            if (!(this instanceof ConstructorReference)) {
                return new ConstructorReference(collection);
            }

            if(!(collection instanceof Array)) {
                asArray = Array.from(Object.asCountableLiteral(collection));
            } else {
                asArray = collection;
            }

            this.sort = function(compareFunction) {
                if (typeof compareFunction == "function") {
                    return asArray.sort(compareFunction);
                } else {
                    // callback in node1 and node2, based a some (Strategy), objects to compare and sort.
                    return asArray.sort(callback);
                }
            };

        }
    });

}(esPhinx));

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esphinx-rails-1.1.3 lib/assets/javascripts/esphinx/lib/collection.js