string format

Format a string with '{0}','{1}'...

От 28.10.2022. Виж последната версия.

Този скрипт не може да бъде инсталиран директно. Това е библиотека за други скриптове и може да бъде използвана с мета-директива // @require https://update.greasyforks.org/scripts/453846/1110440/string%20format.js

(function () {
    "use strict";
    
    if (!String.prototype.format) {
        String.prototype.format = function () {
            var args = arguments;
            return this.replace(/{(\d+)}/g, (match, number) => {
                return typeof args[number] != 'undefined' ? args[number] : match;
            });
        };
    } else {
        throw 'String.prototype.format defined.';
    }
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。