@trashpanda001/helpers
    Preparing search index...

    Function interpolate

    • Returns the text with variables replaced by their values.

      Parameters

      • text: string

        the template text with variables in the form {variableName}

      • variables: Record<string, string>

        the variables to replace in the text

      Returns string

      a new string with the variables replaced by their values

      import { interpolate } from "@trashpanda001/helpers/string"

      interpolate("Hello, {name}!", { name: "World" })
      // "Hello, World!"
      interpolate("Hello, {name}!", { name: "World", age: "42" })
      // "Hello, World!" -- age is not used
      interpolate("Hello, {name}!", {})
      // "Hello, {name}!" -- unknown variable is not replaced