# sprintfjs

> POSIX sprintf(3)-style String Formatting for JavaScript

Latest version **1.2.17** (published 2021-01-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install sprintfjs
pnpm add sprintfjs
yarn add sprintfjs
bun add sprintfjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.17 |
| Published | 2021-01-09 |
| First published | 2013-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 0 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Dr. Ralf S. Engelschall |
| Maintainers | rse |
| Keywords | sprintf, string, format |

## Links

- npm: https://www.npmjs.com/package/sprintfjs
- Repository: https://github.com/rse/sprintfjs
- Homepage: http://github.com/rse/sprintfjs
- Issues: http://github.com/rse/sprintfjs/issues
- npm.io page: https://npm.io/package/sprintfjs

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.17 (latest) — 2021-01-09
- 1.2.16 — 2020-10-11
- 1.2.15 — 2019-12-22
- 1.2.14 — 2019-06-16
- 1.2.13 — 2019-04-26
- 1.2.12 — 2018-12-22
- 1.2.11 — 2018-08-10
- 1.2.10 — 2018-06-23
- 1.2.9 — 2018-04-22
- 1.2.8 — 2018-03-26
- 1.2.7 — 2017-12-03
- 1.2.6 — 2017-06-16
- 1.2.5 — 2017-06-03
- 1.2.4 — 2017-04-10
- 1.2.3 — 2016-06-01
- … 16 more at https://npm.io/package/sprintfjs/versions

## README

sprintf.js
==========

**POSIX sprintf(3)-style String Formatting for JavaScript**

<p/>
<img src="https://nodei.co/npm/sprintfjs.png?downloads=true&stars=true" alt=""/>

<p/>
<img src="https://david-dm.org/rse/sprintfjs.png" alt=""/>

Abstract
--------

This is a JavaScript implementation of POSIX sprintf(3)-style string formatting
for use in [Node.js](http://nodejs.org/) based server and browser based client
environments.

Getting sprintf.js
------------------

You can conveniently get sprintf.js in various ways:

- Git: directly clone the official repository

  `$ git clone https://github.com/rse/sprintfjs.git`

- NPM: install as client component via the NPM package manager:

  `$ npm install sprintfjs`

- cURL: downloading only the main file from the repository

  `$ curl -O https://raw.github.com/rse/sprintfjs/master/sprintf.js`

API
---

The API is similar to POSIX [sprintf(3)](http://www.unix.com/man-page/posix/3/fprintf/).
It is exposed via AMD and CommonJS under the module name `sprintf`
and on the global `window` object in browser environments. The single
exposed API method is (in TypeScript definition notation):

    sprintf(fmt: String, ...arg: any[]): String;

It supports all standard POSIX [sprintf(3)](http://www.unix.com/man-page/posix/3/fprintf/)
features like `sprintf("%.2f", 12.3456)` &rarr; `12.35` and `sprintf("(%-6s)", "foo")` &rarr; `(foo   )` plus
(in addition to the usual positional arguments) two special argument referencing features:

- Indexed Arguments:<br/>
  `sprintf("%2$s baz %3$s baz %1$s", "foo", "bar", "quux")` &rarr; `bar baz quux baz foo`

- Named Arguments:<br/>
  `sprintf("%(bar)s baz %(quux)s baz %(foo)s", { foo: "foo", bar: "bar", quux: "quux" })` &rarr; `bar baz quux baz foo`

See Also
--------

[sprintf(3)](http://www.unix.com/man-page/posix/3/fprintf/)

License
-------

Copyright (c) 2006-2021 Dr. Ralf S. Engelschall (http://engelschall.com/)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/sprintfjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
