# format

> printf, sprintf, and vsprintf for JavaScript

Latest version **0.2.2** (published 2016-01-27) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-01-27 |
| First published | 2011-06-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.4.x |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Sami Samhuri |
| Maintainers | sjs |

## Links

- npm: https://www.npmjs.com/package/format
- Repository: https://github.com/samsonjs/format
- Homepage: http://samhuri.net/proj/format
- Issues: https://github.com/samsonjs/format/issues
- npm.io page: https://npm.io/package/format

## Recent versions

- 0.2.2 (latest) — 2016-01-27
- 0.2.1 — 2013-09-07
- 0.2.0 — 2013-03-08
- 0.1.4 — 2011-11-06
- 0.1.3 — 2011-11-05
- 0.1.2 — 2011-07-29
- 0.1.0 — 2011-06-05
- 0.1.1 — 2011-06-05

## README

format
======

printf, sprintf, and vsprintf for JavaScript

[![version 0.2.2 on npm](https://img.shields.io/badge/npm-0.2.2-brightgreen.svg?style=flat)](https://www.npmjs.com/package/format) [![node version 0.4 and up](https://img.shields.io/badge/node->=0.4-brightgreen.svg?style=flat)](https://www.npmjs.com/package/format) [![MIT License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://sjs.mit-license.org)

Installation
============

npm install format

The code works in browsers as well, you can copy these functions into your project
or otherwise include them with your other JavaScript.

Usage
=====

    var format = require('format')
      , printf = format.printf
      , vsprintf = format.vsprintf
      // or if you want to keep it old school
      , sprintf = format

    // Print 'hello world'
    printf('%s world', 'hello')

    var what = 'life, the universe, and everything'
    format('%d is the answer to %s', 42, what)
    // => '42 is the answer to life, the universe, and everything'

    vsprintf('%d is the answer to %s', [42, what])
    // => '42 is the answer to life, the universe, and everything'

    // you can format values as JSON with %j
    var value = {answer: 42}
    format('%j', value)
    // => '{"answer":42}'

Supported format specifiers: b, c, d, f, j, o, s, x, and X.

See `man 3 printf` or `man 1 printf` for details. `j` is an extension that formats values as JSON.

Precision is supported for floating point numbers.

License
=======

Copyright 2010 - 2016 Sami Samhuri sami@samhuri.net

[MIT license](http://sjs.mit-license.org)

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