JavaScript sprintf

This is a simple JavaScript implementation of the sprintf function. This version also gives the user the option of passing the arguments as an object with named parameters rather than as positional parameters.

Parameters can be passed as either an object, array, or as individual arguments. If passed as an object, named parameters are supported.

Conversion specifiers look similar to the PHP implementation, and consist of these parts following a percent sign (%), in order:

  1. Position/name specifier, matching one of the following:
  2. Sign specifier (+): Force + sign on positive numbers.
  3. Padding specifier ((space), 0, or '[character]): Use spaces, zeroes or the character following the single quote as padding. Default is spaces.
  4. Alignment specifier (-): left-justify values instead of right-justifying them.
  5. Width specifier ([digits]): The minimum number of characters this conversion should result in. In float conversions, the number before the decimal point.
  6. Precision specifier (.[digits]): The maximum number of characters in a string, or the number of characters after the decimal point in a number.
  7. Type specifier: