~cyphermox/cordova-cli/flatten

« back to all changes in this revision

Viewing changes to node_modules/cordova/node_modules/prompt/node_modules/utile/lib/format.js

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2013-12-12 05:26:53 UTC
  • Revision ID: mathieu-tl@ubuntu.com-20131212052653-eatjt8zguqua5qmq
testing the flattenage, yo

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * format.js: `util.format` enhancement to allow custom formatting parameters.
3
 
 *
4
 
 * (C) 2012, Nodejitsu Inc.
5
 
 * MIT LICENSE
6
 
 *
7
 
 */
8
 
 
9
 
var util = require('util');
10
 
 
11
 
exports = module.exports = function(str) {
12
 
  var formats = [].slice.call(arguments, 1, 3);
13
 
 
14
 
  if (!(formats[0] instanceof Array && formats[1] instanceof Array) || arguments.length > 3)
15
 
    return util.format.apply(null, arguments);
16
 
 
17
 
  var replacements = formats.pop(),
18
 
      formats = formats.shift();
19
 
 
20
 
  formats.forEach(function(format, id) {
21
 
    str = str.replace(new RegExp(format), replacements[id]);
22
 
  });
23
 
 
24
 
  return str;
25
 
};