Skip to content

Commit 6abded2

Browse files
authored
Merge pull request #305 from rdvincent/rdv-bugfix
Attempt to work around missing Array.prototype.find() in Chromium
2 parents 2bff8c5 + c3db5d8 commit 6abded2

File tree

1 file changed

+24
-0
lines changed
  • src/brainbrowser/volume-viewer/volume-loaders

1 file changed

+24
-0
lines changed

src/brainbrowser/volume-viewer/volume-loaders/hdf5.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,30 @@
4848
STR: 9
4949
};
5050

51+
/* The following polyfill copied verbatim from MDN 2016-06-16 */
52+
if (!Array.prototype.find) {
53+
Array.prototype.find = function(predicate) {
54+
if (this === null) {
55+
throw new TypeError('Array.prototype.find called on null or undefined');
56+
}
57+
if (typeof predicate !== 'function') {
58+
throw new TypeError('predicate must be a function');
59+
}
60+
var list = Object(this);
61+
var length = list.length >>> 0;
62+
var thisArg = arguments[1];
63+
var value;
64+
65+
for (var i = 0; i < length; i++) {
66+
value = list[i];
67+
if (predicate.call(thisArg, value, i, list)) {
68+
return value;
69+
}
70+
}
71+
return undefined;
72+
};
73+
}
74+
5175
function defined(x) {
5276
return typeof x !== 'undefined';
5377
}

0 commit comments

Comments
 (0)