Show More
@@ -58,14 +58,36 String.prototype.rstrip = function(char) | |||
|
58 | 58 | return this.replace(new RegExp(''+char+'+$'),''); |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | ||
|
61 | /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill | |
|
62 | under MIT license / public domain, see | |
|
63 | https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses */ | |
|
62 | 64 | if(!Array.prototype.indexOf) { |
|
63 |
Array.prototype.indexOf = function( |
|
|
64 | for(var i = 0; i < this.length; i++) { | |
|
65 | if(this[i] === needle) { | |
|
66 | return i; | |
|
65 | Array.prototype.indexOf = function (searchElement, fromIndex) { | |
|
66 | if ( this === undefined || this === null ) { | |
|
67 | throw new TypeError( '"this" is null or not defined' ); | |
|
68 | } | |
|
69 | ||
|
70 | var length = this.length >>> 0; // Hack to convert object.length to a UInt32 | |
|
71 | ||
|
72 | fromIndex = +fromIndex || 0; | |
|
73 | ||
|
74 | if (Math.abs(fromIndex) === Infinity) { | |
|
75 | fromIndex = 0; | |
|
76 | } | |
|
77 | ||
|
78 | if (fromIndex < 0) { | |
|
79 | fromIndex += length; | |
|
80 | if (fromIndex < 0) { | |
|
81 | fromIndex = 0; | |
|
67 | 82 | } |
|
68 | 83 | } |
|
84 | ||
|
85 | for (;fromIndex < length; fromIndex++) { | |
|
86 | if (this[fromIndex] === searchElement) { | |
|
87 | return fromIndex; | |
|
88 | } | |
|
89 | } | |
|
90 | ||
|
69 | 91 | return -1; |
|
70 | 92 | }; |
|
71 | 93 | } |
General Comments 0
You need to be logged in to leave comments.
Login now