aboutsummaryrefslogtreecommitdiff
path: root/htdocs/js/common/00-polyfills.js
diff options
context:
space:
mode:
Diffstat (limited to 'htdocs/js/common/00-polyfills.js')
-rw-r--r--htdocs/js/common/00-polyfills.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/htdocs/js/common/00-polyfills.js b/htdocs/js/common/00-polyfills.js
new file mode 100644
index 0000000..74ec195
--- /dev/null
+++ b/htdocs/js/common/00-polyfills.js
@@ -0,0 +1,47 @@
+if (!String.prototype.startsWith) {
+ String.prototype.startsWith = function(search, pos) {
+ pos = !pos || pos < 0 ? 0 : +pos;
+ return this.substring(pos, pos + search.length) === search;
+ };
+}
+
+if (!String.prototype.endsWith) {
+ String.prototype.endsWith = function(search, this_len) {
+ if (this_len === undefined || this_len > this.length) {
+ this_len = this.length;
+ }
+ return this.substring(this_len - search.length, this_len) === search;
+ };
+}
+
+if (!Object.assign) {
+ Object.defineProperty(Object, 'assign', {
+ enumerable: false,
+ configurable: true,
+ writable: true,
+ value: function(target, firstSource) {
+ 'use strict';
+ if (target === undefined || target === null) {
+ throw new TypeError('Cannot convert first argument to object');
+ }
+
+ var to = Object(target);
+ for (var i = 1; i < arguments.length; i++) {
+ var nextSource = arguments[i];
+ if (nextSource === undefined || nextSource === null) {
+ continue;
+ }
+
+ var keysArray = Object.keys(Object(nextSource));
+ for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
+ var nextKey = keysArray[nextIndex];
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
+ if (desc !== undefined && desc.enumerable) {
+ to[nextKey] = nextSource[nextKey];
+ }
+ }
+ }
+ return to;
+ }
+ });
+} \ No newline at end of file