summaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/utile/lib/format.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/utile/lib/format.js')
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/utile/lib/format.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/utile/lib/format.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/utile/lib/format.js
new file mode 100644
index 00000000..3262dd51
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/utile/lib/format.js
@@ -0,0 +1,25 @@
+/*
+ * format.js: `util.format` enhancement to allow custom formatting parameters.
+ *
+ * (C) 2012, Nodejitsu Inc.
+ * MIT LICENSE
+ *
+ */
+
+var util = require('util');
+
+exports = module.exports = function(str) {
+ var formats = [].slice.call(arguments, 1, 3);
+
+ if (!(formats[0] instanceof Array && formats[1] instanceof Array) || arguments.length > 3)
+ return util.format.apply(null, arguments);
+
+ var replacements = formats.pop(),
+ formats = formats.shift();
+
+ formats.forEach(function(format, id) {
+ str = str.replace(new RegExp(format), replacements[id]);
+ });
+
+ return str;
+};