1.0.1 • Published 6 years ago

format-list v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Format List

build status Coverage Status npm version

Formats a list of values into a given string using the $n tags. By default, index 0 will replace the $0 tag, and it will go up by 1 from there (i.e. tags match indexes). It can be configured with the following options:

  • tagStr
    • The string to use as the tag prefix
  • tagStart
    • The number to start the tags from
  • indexStart
    • The index to start from
    • Allows regex results to be passed in without slicing (using a value of 1)

More info can be seen in the code docs.

Examples

formatList('hello $0', ['world']) // -> 'hello world'

formatList('hello $0, it is an $1 day today', ['you', 'alright']) // -> 'hello you, it is an alright day today'

formatList('$1 $0', ['world', 'hello']) // -> 'hello world'

formatList('foo $1 bar', ['baz'], { tagStart: 1 }) // -> 'foo baz bar'

formatList('foo $0 bar', ['baz', 'faz'], { indexStart: 1 }) // -> 'foo faz bar'
1.0.1

6 years ago

1.0.0

6 years ago