code: function format(str, swaps) {
    // First replace the %S strings
    var index = 0;
    str = str.replace(/%S/g, function() {
      return swaps[index++];
    });
    // Then %n$S style strings
    str = str.replace(/%([0-9])\$S/g, function(match, idx) {
      return swaps[idx - 1];
    });
    return str;
  }
docs: Perform the string swapping required by format().
  @see format() for details of the swaps performed.