From e9842a9db3875246947d2e39cc22e0cf4ca417bc Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Thu, 4 Jan 2024 14:07:18 +0100 Subject: [PATCH] Revert "remove unused file" This reverts commit 9f78921ce4b16dfb96dd31544e32ff703f169c43. --- String.format.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 String.format.js diff --git a/String.format.js b/String.format.js new file mode 100644 index 0000000..8b00f40 --- /dev/null +++ b/String.format.js @@ -0,0 +1,12 @@ +// add string format method +if (!String.prototype.format) { + // eslint-disable-next-line no-extend-native + String.prototype.format = function () { + const args = arguments + return this.replace(/{(\d+)}/g, function (match, number) { + return typeof args[number] !== 'undefined' + ? args[number] + : match + }) + } +}