String-Format-Full

View this project on npmjs.org

Use via NPM:

  1. Install:
    npm install string-format-full
  2. Import:
    import format from "string-format-full"
  3. Call:
    const pi = format("{} is {:0.2f}", "Pi", 3.1415)
    or
    format.setOptions({global: true})
    const pi = "{} is {:0.2f}".format("Pi", 3.1415)

Use Standalone:

  1. Download:
    Grab a file
  2. Include:
    <script src="index.IE11.min.js"></script>
  3. Call:
    const pi = format("{} is {:0.2f}", "Pi", 3.1415)
    or
    format.setOptions({global: true})
    const pi = "{} is {:0.2f}".format("Pi", 3.1415)

A few examples:

Code Result