Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwinniehell <git@winniehell.de>2017-03-05 22:43:05 +0300
committerwinniehell <git@winniehell.de>2017-03-05 23:22:40 +0300
commit572f9782d5e8d6307784b61db0dfce48f5118445 (patch)
tree11b25c46733462729e4303b26b4895d983f14df0 /app/assets/javascripts/extensions/array.js
parent4cd2ab52548e89cd7259cfb7ce320fdfa203fe84 (diff)
Remove .es6 from file extensions (!9241)
Diffstat (limited to 'app/assets/javascripts/extensions/array.js')
-rw-r--r--app/assets/javascripts/extensions/array.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/extensions/array.js b/app/assets/javascripts/extensions/array.js
new file mode 100644
index 00000000000..f8256a8d26d
--- /dev/null
+++ b/app/assets/javascripts/extensions/array.js
@@ -0,0 +1,27 @@
+/* eslint-disable no-extend-native, func-names, space-before-function-paren, space-infix-ops, strict, max-len */
+
+'use strict';
+
+Array.prototype.first = function() {
+ return this[0];
+};
+
+Array.prototype.last = function() {
+ return this[this.length-1];
+};
+
+Array.prototype.find = Array.prototype.find || function(predicate, ...args) {
+ if (!this) throw new TypeError('Array.prototype.find called on null or undefined');
+ if (typeof predicate !== 'function') throw new TypeError('predicate must be a function');
+
+ const list = Object(this);
+ const thisArg = args[1];
+ let value = {};
+
+ for (let i = 0; i < list.length; i += 1) {
+ value = list[i];
+ if (predicate.call(thisArg, value, i, list)) return value;
+ }
+
+ return undefined;
+};