{"ScriptPreparationCode":"var angularFilter = angular.injector([\u0027ng\u0027]).get(\u0027$filter\u0027)(\u0027filter\u0027);\r\n\r\n// Add array.where implementation\r\nArray.prototype.where = Array.prototype.where || function(predicate) {\r\n var results = [],\r\n len = this.length,\r\n i = 0;\r\n\r\n for (; i \u003C len; i\u002B\u002B) {\r\n var item = this[i];\r\n if (predicate(item)) {\r\n results.push(item);\r\n }\r\n }\r\n\r\n return results;\r\n};\r\n// This is because Chrome filter is slow in most cases. This is polyfill from Mozilla, but it\u0027s faster than Chrome by a least x2\r\nArray.prototype.fasterFilter = function (func, thisArg) {\r\n \u0027use strict\u0027;\r\n if (!((typeof func === \u0027Function\u0027 || typeof func === \u0027function\u0027) \u0026\u0026 this))\r\n throw new TypeError();\r\n\r\n var len = this.length \u003E\u003E\u003E 0,\r\n res = new Array(len), // preallocate array\r\n t = this, c = 0, i = -1;\r\n\r\n var kValue;\r\n if (thisArg === undefined) {\r\n while (\u002B\u002Bi !== len) {\r\n // checks to see if the key was set\r\n if (i in this) {\r\n kValue = t[i]; // in case t is changed in callback\r\n if (func(t[i], i, t)) {\r\n res[c\u002B\u002B] = kValue;\r\n }\r\n }\r\n }\r\n }\r\n else {\r\n while (\u002B\u002Bi !== len) {\r\n // checks to see if the key was set\r\n if (i in this) {\r\n kValue = t[i];\r\n if (func.call(thisArg, t[i], i, t)) {\r\n res[c\u002B\u002B] = kValue;\r\n }\r\n }\r\n }\r\n }\r\n\r\n res.length = c; // shrink down array to proper size\r\n return res;\r\n};\r\n// Generate test array\r\nwindow.array = (function() {\r\n var arr = [];\r\n for (var i = 0; i \u003C 1000; \u002B\u002Bi) {\r\n arr.push(i);\r\n }\r\n\r\n return arr;\r\n}());\r\n\r\ngrepAlone = function( elems, callback, invert ) {\r\n\t\tvar callbackInverse,\r\n\t\t\tmatches = [],\r\n\t\t\ti = 0,\r\n\t\t\tlength = elems.length,\r\n\t\t\tcallbackExpect = !invert;\r\n\r\n\t\t// Go through the array, only saving the items\r\n\t\t// that pass the validator function\r\n\t\tfor ( ; i \u003C length; i\u002B\u002B ) {\r\n\t\t\tcallbackInverse = !callback( elems[ i ], i );\r\n\t\t\tif ( callbackInverse !== callbackExpect ) {\r\n\t\t\t\tmatches.push( elems[ i ] );\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn matches;\r\n};\r\n\r\nArray.prototype.find = function(predicate) {\r\n if (this == null) {\r\n throw new TypeError(\u0027Array.prototype.find called on null or undefined\u0027);\r\n }\r\n if (typeof predicate !== \u0027function\u0027) {\r\n throw new TypeError(\u0027predicate must be a function\u0027);\r\n }\r\n var list = Object(this);\r\n var length = list.length \u003E\u003E\u003E 0;\r\n var thisArg = arguments[1];\r\n var value;\r\n\r\n for (var i = 0; i \u003C length; i\u002B\u002B) {\r\n value = list[i];\r\n if (predicate.call(thisArg, value, i, list)) {\r\n return value;\r\n }\r\n }\r\n return undefined;\r\n};\r\n\r\nfunction getValue(el) {\r\n\treturn el - 50 \u003E 31;\r\n}","TestCases":[{"Name":"$.grep","Code":"$.grep(array, getValue);","IsDeferred":false},{"Name":"array.where","Code":"array.where(getValue);","IsDeferred":false},{"Name":"angular.$filter","Code":"angularFilter(array, getValue);","IsDeferred":false},{"Name":"array.filter","Code":"array.filter(getValue);","IsDeferred":false},{"Name":"lodash.filter","Code":"_lodash.filter(array, getValue);","IsDeferred":false},{"Name":"underscore.filter","Code":"_.filter(array, getValue);","IsDeferred":false},{"Name":"grepAlone","Code":"grepAlone(array, getValue);","IsDeferred":false},{"Name":"fasterFilter","Code":"array.fasterFilter(getValue);","IsDeferred":false}]}