2014-08-05 06:55:18 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set shiftwidth=4 tabstop=4 autoindent cindent expandtab: */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
if (!Math.fround) {
|
|
|
|
Math.fround = (function() {
|
|
|
|
var fa = new Float32Array(1);
|
|
|
|
return function(v) {
|
2014-09-17 20:12:50 +04:00
|
|
|
fa[0] = v;
|
2014-08-05 06:55:18 +04:00
|
|
|
return fa[0];
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}
|
2014-08-21 21:11:58 +04:00
|
|
|
|
|
|
|
if (!String.prototype.contains) {
|
|
|
|
String.prototype.contains = function() {
|
|
|
|
return String.prototype.indexOf.apply(this, arguments) !== -1;
|
|
|
|
};
|
|
|
|
}
|
2014-11-21 01:52:07 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Array.prototype.findIndex) {
|
|
|
|
Array.prototype.findIndex = 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 i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
}
|