Show More
@@ -70,6 +70,45 if(!Array.prototype.indexOf) { | |||
|
70 | 70 | }; |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Compatibility | |
|
74 | under MIT license / public domain, see | |
|
75 | https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses */ | |
|
76 | if (!Array.prototype.filter) | |
|
77 | { | |
|
78 | Array.prototype.filter = function(fun /*, thisArg */) | |
|
79 | { | |
|
80 | "use strict"; | |
|
81 | ||
|
82 | if (this === void 0 || this === null) | |
|
83 | throw new TypeError(); | |
|
84 | ||
|
85 | var t = Object(this); | |
|
86 | var len = t.length >>> 0; | |
|
87 | if (typeof fun !== "function") | |
|
88 | throw new TypeError(); | |
|
89 | ||
|
90 | var res = []; | |
|
91 | var thisArg = arguments.length >= 2 ? arguments[1] : void 0; | |
|
92 | for (var i = 0; i < len; i++) | |
|
93 | { | |
|
94 | if (i in t) | |
|
95 | { | |
|
96 | var val = t[i]; | |
|
97 | ||
|
98 | // NOTE: Technically this should Object.defineProperty at | |
|
99 | // the next index, as push can be affected by | |
|
100 | // properties on Object.prototype and Array.prototype. | |
|
101 | // But that method's new, and collisions should be | |
|
102 | // rare, so use the more-compatible alternative. | |
|
103 | if (fun.call(thisArg, val, i, t)) | |
|
104 | res.push(val); | |
|
105 | } | |
|
106 | } | |
|
107 | ||
|
108 | return res; | |
|
109 | }; | |
|
110 | } | |
|
111 | ||
|
73 | 112 | /** |
|
74 | 113 | * A customized version of PyRoutes.JS from https://pypi.python.org/pypi/pyroutes.js/ |
|
75 | 114 | * which is copyright Stephane Klein and was made available under the BSD License. |
General Comments 0
You need to be logged in to leave comments.
Login now