string/interpolateLiteral

Replaces the tokens in a literal-like string by the corresponding values.

Source:

Methods

(static) interpolateLiteral(value, tokensopt) → {string}

Source:
Example
import { interpolateLiteral } from '@untemps/utils/string/interpolateLiteral'

const value = 'A ${foo} with ${bar} "wings" and a lot of ${fun}'
const tokens = {
 foo: 'bird',
 bar: 3,
 fun: 'dignity'
}
interpolateLiteral(value, tokens) // A bird with 3 "wings" and a lot of dignity
Parameters:
Name Type Attributes Default Description
value string

The literal-like string value to interpolate.

tokens object.<key, value> <optional>
{}

An object of key/value pairs to replace the tokens.

Returns:

The interpolated string.

Type
string