No description
Find a file
2013-03-07 20:09:20 -08:00
.gitignore add gitignore 2013-03-07 20:05:19 -08:00
format.js move lib/index.js to format.js 2013-03-07 20:09:20 -08:00
LICENSE add package.json and readme 2010-11-11 14:54:39 -08:00
package.json 0.1.4 2011-11-05 19:00:16 -07:00
Readme.md update readme, minor cleanup, bump version 2011-06-05 16:45:06 -07:00
test_format.js update tests (really need to be rewritten as proper tests) 2011-11-05 15:58:58 -07:00

format

printf, sprintf, and vsprintf for JavaScript

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
  , format = Format.format // aliased as sprintf as well

// 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'

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

See man 3 printf or man 1 printf for details.

License

Copyright 2010 - 2011 Sami Samhuri sami@samhuri.net

ISC (see included LICENSE)