Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to work around missing Array.prototype.find() in Chromium #305

Merged
merged 2 commits into from
Jun 16, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Attempt to work around missing Array.prototype.find() in Chromium
  • Loading branch information
Robert D. Vincent committed Jun 16, 2016
commit 8f347af28847e009b78298c0022319ab0124e3cf
24 changes: 24 additions & 0 deletions src/brainbrowser/volume-viewer/volume-loaders/hdf5.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,30 @@
STR: 9
};

/* The following polyfill copied verbatim from MDN 2016-06-16 */
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;
};
}

function defined(x) {
return typeof x !== 'undefined';
}
Expand Down