|
|
@@ -0,0 +1,62 @@
|
|
|
+// Licensed to Cloudera, Inc. under one
|
|
|
+// or more contributor license agreements. See the NOTICE file
|
|
|
+// distributed with this work for additional information
|
|
|
+// regarding copyright ownership. Cloudera, Inc. licenses this file
|
|
|
+// to you under the Apache License, Version 2.0 (the
|
|
|
+// "License"); you may not use this file except in compliance
|
|
|
+// with the License. You may obtain a copy of the License at
|
|
|
+//
|
|
|
+// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+//
|
|
|
+// Unless required by applicable law or agreed to in writing, software
|
|
|
+// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+// See the License for the specific language governing permissions and
|
|
|
+// limitations under the License.
|
|
|
+
|
|
|
+if (!('clean' in Array.prototype)) {
|
|
|
+ Array.prototype.clean = function (deleteValue) {
|
|
|
+ for (var i = 0; i < this.length; i++) {
|
|
|
+ if (this[i] == deleteValue) {
|
|
|
+ this.splice(i, 1);
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+if (!('move' in Array.prototype)) {
|
|
|
+ Array.prototype.move = function (old_index, new_index) {
|
|
|
+ if (new_index >= this.length) {
|
|
|
+ var k = new_index - this.length;
|
|
|
+ while ((k--) + 1) {
|
|
|
+ this.push(undefined);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.splice(new_index, 0, this.splice(old_index, 1)[0]);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+if (!('indexOf' in Array.prototype)) {
|
|
|
+ Array.prototype.indexOf = function (needle) {
|
|
|
+ for (var i = 0; i < this.length; i++) {
|
|
|
+ if (this[i] === needle) {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+// adding missing .filter for IE8
|
|
|
+if (!('filter' in Array.prototype)) {
|
|
|
+ Array.prototype.filter = function (filter, that /*opt*/) {
|
|
|
+ var other = [], v;
|
|
|
+ for (var i = 0, n = this.length; i < n; i++)
|
|
|
+ if (i in this && filter.call(that, v = this[i], i, this))
|
|
|
+ other.push(v);
|
|
|
+ return other;
|
|
|
+ };
|
|
|
+}
|