aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/js/common.js
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-05-06 06:17:59 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-05-06 06:17:59 +0300
commit4e11e6d5364a12650b9a139495bd5a73943ae56a (patch)
tree061edcaa62c6b7f65f80109c42b2181840a89250 /js/common.js
downloadsorting-algorithms-4e11e6d5364a12650b9a139495bd5a73943ae56a.tar.gz
sorting-algorithms-4e11e6d5364a12650b9a139495bd5a73943ae56a.zip
initial commit
Diffstat (limited to '')
-rw-r--r--js/common.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/js/common.js b/js/common.js
new file mode 100644
index 0000000..07268f4
--- /dev/null
+++ b/js/common.js
@@ -0,0 +1,23 @@
+// Copyright 2015 Egor Tensin <Egor.Tensin@gmail.com>
+// This file is licensed under the terms of the MIT License.
+// See LICENSE.txt for details.
+
+if (!String.prototype.format) {
+ String.prototype.format = function() {
+ var str = this.toString();
+ if (!arguments.length)
+ return str;
+ switch (typeof arguments[0]) {
+ case 'string':
+ case 'number':
+ var args = arguments;
+ break;
+ default:
+ var args = arguments[0];
+ break;
+ }
+ for (var arg in args)
+ str = str.replace(new RegExp('\\{' + arg + '\\}', 'gi'), args[arg]);
+ return str;
+ }
+}