# extsprintf

> extended POSIX-style sprintf

Latest version **1.4.1** (published 2021-11-02) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2021-11-02 |
| First published | 2012-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/extsprintf) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Maintainers | todd.whiteman, kusor, wyatt, michael.hicks, bahamat, chudley, tchameroy, dbuell, trentm, dap, jclulow, arekinath, melloc, kellymclaughlin |

## Links

- npm: https://www.npmjs.com/package/extsprintf
- Repository: https://github.com/davepacheco/node-extsprintf
- Homepage: https://github.com/davepacheco/node-extsprintf#readme
- Issues: https://github.com/davepacheco/node-extsprintf/issues
- npm.io page: https://npm.io/package/extsprintf

## Recent versions

- 1.4.1 (latest) — 2021-11-02
- 1.4.0 — 2017-11-30
- 1.3.0 — 2015-03-07
- 1.2.1 — 2014-11-21
- 1.2.0 — 2014-06-16
- 1.1.1 — 2014-06-13
- 1.1.0 — 2014-06-06
- 1.0.3 — 2014-01-15
- 1.0.2 — 2013-02-06
- 1.0.1 — 2012-06-14
- 1.0.0 — 2012-04-18

## README

# extsprintf: extended POSIX-style sprintf

Stripped down version of s[n]printf(3c).  We make a best effort to throw an
exception when given a format string we don't understand, rather than ignoring
it, so that we won't break existing programs if/when we go implement the rest
of this.

This implementation currently supports specifying

* field alignment ('-' flag),
* zero-pad ('0' flag)
* always show numeric sign ('+' flag),
* field width
* conversions for strings, decimal integers, and floats (numbers).
* argument size specifiers.  These are all accepted but ignored, since
  Javascript has no notion of the physical size of an argument.

Everything else is currently unsupported, most notably: precision, unsigned
numbers, non-decimal numbers, and characters.

Besides the usual POSIX conversions, this implementation supports:

* `%j`: pretty-print a JSON object (using node's "inspect")
* `%r`: pretty-print an Error object

# Example

First, install it:

    # npm install extsprintf

Now, use it:

    var mod_extsprintf = require('extsprintf');
    console.log(mod_extsprintf.sprintf('hello %25s', 'world'));

outputs:

    hello                     world

# Also supported

**printf**: same args as sprintf, but prints the result to stdout

**fprintf**: same args as sprintf, preceded by a Node stream.  Prints the result
to the given stream.

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