Skip to content

Instantly share code, notes, and snippets.

@swijw
Created October 29, 2012 04:18
Show Gist options
  • Save swijw/3971488 to your computer and use it in GitHub Desktop.
Save swijw/3971488 to your computer and use it in GitHub Desktop.

Revisions

  1. swijw revised this gist Oct 29, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion String.format.js
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,6 @@ String.format = function(src) {
    }
    var args = Array.prototype.slice.call(arguments, 1);
    return src.replace(/\{(\d+)\}/g, function(m, i) {
    return args[i];
    return args[i];
    });
    };
  2. swijw revised this gist Oct 29, 2012. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions String.format.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    String.format = function(src){
    if (arguments.length == 0) return null;
    String.format = function(src) {
    if (arguments.length) {
    return null;
    }
    var args = Array.prototype.slice.call(arguments, 1);
    return src.replace(/\{(\d+)\}/g, function(m, i){
    return src.replace(/\{(\d+)\}/g, function(m, i) {
    return args[i];
    });
    };
  3. swijw renamed this gist Oct 29, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. swijw revised this gist Oct 29, 2012. No changes.
  5. swijw created this gist Oct 29, 2012.
    7 changes: 7 additions & 0 deletions String.format
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    String.format = function(src){
    if (arguments.length == 0) return null;
    var args = Array.prototype.slice.call(arguments, 1);
    return src.replace(/\{(\d+)\}/g, function(m, i){
    return args[i];
    });
    };