lib/assets/javascripts/esphinx/lib/extensions/object.js in esphinx-rails-1.1.2 vs lib/assets/javascripts/esphinx/lib/extensions/object.js in esphinx-rails-1.1.3

- old
+ new

@@ -90,55 +90,23 @@ try { $.defineProperties($, { - clone: { - value: function(object, includeNonEnumerable) { - if (typeof includeNonEnumerable != "boolean") { - includeNonEnumerable = true; - } - - var - clone = {}, - properties = $.getOwnPropertyNames(object), - - callback = function(p) { - clone[p] = object[p]; - }; - - if (!includeNonEnumerable) { - return Object.assign(clone, object); - } - - try { - properties.forEach(callback); - } catch(e) {} - - return clone; - } + areEquivalents: { + value: areEquivalents }, - className: { + empty: { value: function(object) { - var - pattern = /[a-zA-Z$_][^\]]+/g, - string = $.prototype.toString.call(object); - - if (typeof object == "object" && - $.implementsMethods(object, "toString")) { - // if implements, then calls it - string = object.toString(); - } - - return pattern.exec(string)[0].split(" ")[1]; + return $.amount(object) === 0; } }, - classForName: { - value: function(name) { - return window[name]; + some: { + value: function(object) { + return !$.empty(object); } }, hasSameClass: { value: function(objects) { @@ -189,10 +157,97 @@ return amount == argumentsAsArray.length; } }, + hasAttributes: { + value: function(object, attributes) { + var + amount = 0, + argumentsAsArray = Array.from(arguments), + researchedAttributes = argumentsAsArray + .slice(1, argumentsAsArray.length); + + attributes = $.attributes(object, true); + + researchedAttributes.forEach(function(attribute) { + if (attributes.includes(attribute)) { + amount++; + } + }); + + return amount == researchedAttributes.length; + } + }, + + implementsMethod: { + value: function(object, methods) { + var + amount = 0, + argumentsAsArray = Array.from(arguments), + researchedMethods = argumentsAsArray + .slice(1, argumentsAsArray.length); + + methods = $.methods(object); + researchedMethods.forEach(function(method) { + if (methods.includes(method)) { + amount++; + } + }); + + return amount == researchedMethods.length; + } + }, + + clone: { + value: function(object, includeNonEnumerable) { + if (typeof includeNonEnumerable != "boolean") { + includeNonEnumerable = true; + } + + var + clone = {}, + properties = $.getOwnPropertyNames(object), + + callback = function(p) { + clone[p] = object[p]; + }; + + if (!includeNonEnumerable) { + return Object.assign(clone, object); + } + + try { + properties.forEach(callback); + } catch(e) {} + + return clone; + } + }, + + className: { + value: function(object) { + var + pattern = /[a-zA-Z$_][^\]]+/g, + string = $.prototype.toString.call(object); + + if (typeof object == "object" && + $.implementsMethod(object, "toString")) { + // if implements, then calls it + string = object.toString(); + } + + return pattern.exec(string)[0].split(" ")[1]; + } + }, + + classForName: { + value: function(name) { + return window[name]; + } + }, + firstKey: { value: function(object) { var // Object: javascript literal object keys = Object.keys(object); @@ -336,22 +391,10 @@ return amount; } }, - empty: { - value: function(object) { - return $.amount(object) === 0; - } - }, - - some: { - value: function(object) { - return !$.empty(object); - } - }, - delete: { value: function(index, object) { if (delete object[index]) { if (object.hasOwnProperty("length")) { object.length -= 1; @@ -449,52 +492,9 @@ properties = $.getOwnPropertyNames(clone); } return properties.difference($.attributes(object, true)); } - }, - - hasAttributes: { - value: function(object, attributes) { - var - amount = 0, - argumentsAsArray = Array.from(arguments), - researchedAttributes = argumentsAsArray - .slice(1, argumentsAsArray.length); - - attributes = $.attributes(object, true); - - researchedAttributes.forEach(function(attribute) { - if (attributes.includes(attribute)) { - amount++; - } - }); - - return amount == researchedAttributes.length; - } - }, - - implementsMethods: { - value: function(object, methods) { - var - amount = 0, - argumentsAsArray = Array.from(arguments), - researchedMethods = argumentsAsArray - .slice(1, argumentsAsArray.length); - - methods = $.methods(object); - researchedMethods.forEach(function(method) { - if (methods.includes(method)) { - amount++; - } - }); - - return amount == researchedMethods.length; - } - }, - - areEquivalents: { - value: areEquivalents } }); } catch(e) {}