Skip to content

natecavanaugh/string-sub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published