Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string-sub

natecavanaugh673MIT0.0.1

Super lightweight string substitution module.

readme

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