Options
All
  • Public
  • Public/Protected
  • All
Menu

Module string/format2

Index

Functions

Functions

  • format2(template: string, values: Record<string, unknown>): string
  • Helper to create a string from a template and a string record. Similar to format but with objects instead of positional arguments.

    example
     format2('Foo {foo} Bar {bar}{boo}', { foo: 'bar' });                       //=> 'Foo bar Bar {bar}{boo}'
    format2('Foo {foo} Bar {bar}{boo}', { foo: 'bar', bar: 'undefined' }); //=> 'Foo bar Bar undefined{boo}'
    format2('Foo {foo} Bar {bar}{boo}', { foo: 'bar', bar: '5', boo: false }); //=> 'Foo bar Bar 5false'

    Parameters

    • template: string
    • values: Record<string, unknown>

    Returns string

Generated using TypeDoc