From 8348ca437922a1566159ffe917745be8a1ef0bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 14 Apr 2025 17:22:34 +0200 Subject: [PATCH] Increase minimal ECMAScript version to 8 --- sao/eslint.config.mjs | 2 +- sao/src/sao.js | 92 +------------------------------------------ 2 files changed, 2 insertions(+), 92 deletions(-) diff --git a/sao/eslint.config.mjs b/sao/eslint.config.mjs index 3c9f42ad36..ac283aeaa7 100644 --- a/sao/eslint.config.mjs +++ b/sao/eslint.config.mjs @@ -5,7 +5,7 @@ export default [ js.configs.recommended, { languageOptions: { - ecmaVersion: 6, + ecmaVersion: 8, sourceType: "script", globals: { Mousetrap: "readonly", diff --git a/sao/src/sao.js b/sao/src/sao.js index 94be217bee..9242baaaed 100644 --- a/sao/src/sao.js +++ b/sao/src/sao.js @@ -10,103 +10,13 @@ var Sao = { (function() { 'use strict'; - // Browser compatibility: polyfill if (!('contains' in String.prototype)) { String.prototype.contains = function(str, startIndex) { return -1 !== String.prototype.indexOf.call(this, str, startIndex); }; } - if (!String.prototype.startsWith) { - Object.defineProperty(String.prototype, 'startsWith', { - enumerable: false, - configurable: false, - writable: false, - value: function(searchString, position) { - position = position || 0; - return this.indexOf(searchString, position) === position; - } - }); - } - if (!String.prototype.endsWith) { - Object.defineProperty(String.prototype, 'endsWith', { - enumerable: false, - configurable: false, - writable: false, - value: function(searchString, position) { - position = position || this.length; - position = position - searchString.length; - var lastIndex = this.lastIndexOf(searchString); - return lastIndex !== -1 && lastIndex === position; - } - }); - } - if (!String.prototype.padEnd) { - String.prototype.padEnd = function padEnd(targetLength, padString) { - targetLength = targetLength >> 0; - padString = String( - typeof padString !== 'undefined' ? padString : ' '); - if (this.length > targetLength) { - return String(this); - } else { - targetLength = targetLength - this.length; - if (targetLength > padString.length) { - padString += padString.repeat( - targetLength / padString.length); - } - return String(this) + padString.slice(0, targetLength); - } - }; - } - if (!String.prototype.padStart) { - String.prototype.padStart = function padStart(targetLength, padString) { - targetLength = targetLength >> 0; - padString = String( - typeof padString !== 'undefined' ? padString : ' '); - if (this.length > targetLength) { - return String(this); - } else { - targetLength = targetLength - this.length; - if (targetLength > padString.length) { - padString += padString.repeat( - targetLength / padString.length); - } - return padString.slice(0, targetLength) + String(this); - } - }; - } - if (!Array.prototype.some) { - Array.prototype.some = function(fun /*, thisp */) { - if (this === null) { - throw new TypeError(); - } - var thisp, i, - t = Object(this), - len = t.length >>> 0; - if (typeof fun !== 'function') { - throw new TypeError(); - } - thisp = arguments[1]; - for (i = 0; i < len; i++) { - if (i in t && fun.call(thisp, t[i], i, t)) { - return true; - } - } - return false; - }; - } - - if (!Array.from) { - Array.from = function (value) { - // Implementation is not strictly equivalent but works for most - // cases - var result = []; - for (const e of value) { - result.push(e); - } - return result; - }; - } + // Browser compatibility: polyfill if (!Set.prototype.intersection) { Set.prototype.intersection = function(other) { if (this === null) {