format-list
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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'

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i format-list

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

57.3 kB

Total Files

10

Last publish

Collaborators

  • luvies