@untemps/utils - v3.1.0
    Preparing search index...

    Function interpolate

    • Parameters

      • value: string

        The string value to interpolate.

      • tokens: Record<string, unknown> = {}

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

      • divider: string = '%'

        The symbol that identifies a token.

      Returns string

      The interpolated string.

      import { interpolate } from '@untemps/utils/string/interpolate'

      const value = 'A %foo% with a "%bar%" wings and a lot of %fun%'
      const tokens = {
      foo: 'bird',
      bar: 3,
      fun: 'dignity'
      }
      const divider = '%'
      interpolate(value, tokens, divider) // A bird with a "3" wings and a lot of dignity