```sh npm install --save extra-tags # or yarn add extra-tags ```
npm install extra-tagssh
npm install --save extra-tags
or
yarn add extra-tags
`API
$3
`ts
function map>(
fn: (value: T, index: number) => U
, strings: Strings
, ...values: T[]
): [strings: Strings, ...values: U[]]
function map(
fn: (value: T, index: number) => U
): >(
strings: Strings
, ...values: T[]
) => [strings: Strings, ...values: U[]]
`$3
`ts
function filter(
predicate: (value: T, index: number) => boolean
, strings: TemplateStringsArray
, ...values: T[]
): [strings: TemplateStringsArray, ...values: U[]]
function filter(
predicate: (value: T, index: number) => boolean
, strings: ReadonlyArray
, ...values: T[]
): [strings: ReadonlyArray, ...values: U[]]
function filter(
predicate: (value: T, index: number) => boolean
): >(
strings: Strings
, ...values: T[]
) => [
strings: Strings extends TemplateStringsArray
? TemplateStringsArray
: ReadonlyArray
, ...values: U[]
]
`$3
`ts
function array(strings: TemplateStringsArray, ...values: T[]): Array
``ts
arraya${1}b${2}c
// ['a', 1, 'b', 2, 'c']
`$3
`ts
function fromArray(arr: Array): [
strings: string[]
, ...values: T[]
]
``ts
fromArray(arraya${1}b${2}c)
// [['a', 'b', 'c'], 1, 2]
`$3
`ts
function concat(strings: ReadonlyArray, ...values: unknown[]): string
`It is equivalent to
Array.prototype.concat for template arguments.`ts
// It doesn't make sense to use it as a tag function,
// because it equivalent to a${'b'}c${'d'}e.
concata${'b'}c${'d'}e
// 'abcde'concat(strings, ...values)
// 'abcde'
`$3
`ts
function dedent(strings: ReadonlyArray, ...values: unknown[]): string
``ts
dedent
// 'hello' + '\n'
// + 'world'
`$3
`ts
function oneline(
separator: string
, strings: ReadonlyArray
, ...values: unknown[]
): string
function oneline(
separator: string
): (strings: ReadonlyArray, ...values: unknown[]) => string
function oneline(strings: ReadonlyArray, ...values: unknown[]): string
``ts
oneline(' ')
// 'hello world'
`$3
`ts
function indentMultilineValues>(
strings: Strings
, ...values: string[]
): [strings: Strings, ...values: string[]]
``ts
const [strings, ...values] = indentMultilineValues
// strings: [
// '\n'
// + ' '.repeat(2) + 'a' + '\n'
// , '\n'
// + ' '.repeat(2) + 'd' + '\n'
// ]
// values: [
// 'b' + '\n'
// + ' '.repeat(2) + 'c'
// ]
`$3
`ts
type JavaScriptValue =
| string
| number
| boolean
| null
| bigint
| undefined
| ((args: any) => any)
| { [property: string]: JavaScriptValue }
| JavaScriptValue[]function javascript(strings: ReadonlyArray, ...values: JavaScriptValue[]): string
``ts
javascript
// const text = "hello world"
// console.log(text)
``