1.0.1 • Published 4 years ago

formatify v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

formatify Build Status Coverage Status

Simple text formatter for node.js and browser

Install

npm install formatify

Usage

import {format} from 'formatify'

// format with array
format('{0} is a sample {1}', ['this', 'text']) // => "this is a sample text"

// format with object
format('{key1} is a sample {key2}', {key1: 'this', key2: 'text'}) // => "this is a sample text"

// repeat twice to escape placeholders
format('{{key1}} is a sample {key2}', {key1: 'this', key2: 'text'}) // => {key1} is a sample text

// the placeholder syntax can be configured with 3rd argument
format('%0$ is a sample %1$', ['this', 'text'], {begin: '%', end: '$'}) // => "this is a sample text"
format('%p1$ is a sample %p1$', {p1: 'this', p2: 'text'}, {begin: '%', end: '$'}) // => "this is a sample text"
1.0.1

4 years ago

1.0.0

4 years ago

0.1.0

4 years ago