JSPM

sprintf-lite

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q40326F
  • License MIT

Low-fat implementation of the sprintf() function for JavaScript.

Package Exports

  • sprintf-lite

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sprintf-lite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sprintf() lite for JavaScript

Low-fat implementation of the sprintf() function for JavaScript.

Description

string sprintf (string $format [, mixed $args [, mixed $... ]])

Returns a string produced according to the formatting string format.

Examples IRL

Example #1 Basic usage

sprintf('/my/%s/api/%s', 'awesome', 'endpoint')

The above example will output:

/my/awesome/api/endpoint

Example #2 Argument swapping and reuse

sprintf('That {location} was full of gals and only a {number} dudes, {number} dudes had a ball at that {location}.', {location: 'place', number: 'few'})

The above example will output:

That place was full of gals and only a few dudes, few dudes had a ball at that place.