format

Formats a string using parameters.

Install

Install all functions of strman

yarn add strman

or just the format function

yarn add strman.format

Usage

import { format } from 'strman'
// OR
import format from 'strman.format'
Parameters:
Name Type Description
value String

Value that will be formatted.

params Array.<String>

Array with the parameters described in the string.

Source:
Returns:

Formatted string.

Type
String
Example
const select = `SELECT * FROM CONTACTS WHERE NAME LIKE '%{0}%' AND EMAIL LIKE '%{1}%'`
format(select, 'DANIEL', 'GMAIL')
// => `SELECT * FROM CONTACTS WHERE NAME LIKE '%DANIEL%' AND EMAIL LIKE '%GMAIL%'`