0.0.1 • Published 9 years ago

string-sub v0.0.1

Weekly downloads
1,205
License
MIT
Repository
github
Last release
9 years ago

string-sub Build Status

Super lightweight string substitution module.

This module is a very simple string substitution module that allows for either key names, or index positions as the placeholder.

Install

$ npm install --save string-sub

Usage

Basic usage

var sub = require('string-sub');

sub('Hello {0}!', 'world');
// => Hello world!

Using variable arguments

sub('Hello {0}, {1}!', 'world', 'nice to meet you');
// => Hello world, nice to meet you!

Using objects

sub('Hello {subject}, {greeting}!', {greeting: 'nice to meet you', subject: 'world'});
// => Hello world, nice to meet you!

Using arrays

sub('Hello {0}, {1}!', ['world', 'nice to meet you']);
// => Hello world, nice to meet you!

License

MIT © Nate Cavanaugh