Simple message formatting utility for Node.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.jshintrc
.npmignore
.travis.yml
LICENSE.txt
README.md
format.js
package.json

README.md

Message format utility

Build Status

Message formatting utility function. Using a message template containing replacement markers {#} (open brace # close brace), where # is a digit between 0 and 9. Each replacement marker will be replaced by its corresponding parameter passed to the function. For example,

var format = require ("ujs-format").format;
format ("Syntax error on line {0}: Missing '{1}'", "101", ")");

will generate the result string,

Syntax error on line 101: Missing ')'

Using this approach helps with message organization (isolating message text definitions from the code they are used in) and internationalization, as the message text can be substituted with different language text, and the replacement parameters adjusted accordingly.

Installation

The program can be installed using npm, with the command,

npm install ujs-format

Project

This program is part of the Using JSON Schema project.

License

MIT