From bd956053c376facbb521a62ed358107636004782 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 21 Mar 2015 10:44:25 -0400 Subject: [PATCH] 2015: live: Add Array#find polyfill. --- 2015/assets/js/stream.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/2015/assets/js/stream.js b/2015/assets/js/stream.js index 9b6d67fc..a910e28e 100644 --- a/2015/assets/js/stream.js +++ b/2015/assets/js/stream.js @@ -21,6 +21,29 @@ * @licend The above is the entire license notice for the JavaScript code in this page */ +if (!Array.prototype.find) { + Array.prototype.find = function(predicate) { + if (this == null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + }; +} + var app = {}; app.icecastUrl = "//live.fsf.org"; -- 2.25.1