All files / src line.ts

90% Statements 9/10
100% Branches 0/0
100% Functions 3/3
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2122x 22x                         22x 26x 26x     22x  
import auto from './auto.js'
import raw from './raw.js'
import type S from './sanitised.js'
 
/**
 * @returns space delimited line constructed from provided elements.
 *
 * `undefined` values are filtered out.
 *
 * Empty list returns sanitized empty string.
 *
 * @see maybeLine for variant which propagates emtpy list to undefined.
 */
export const line =
  (...elements: unknown[]): S => {
    const elements_ = elements.filter(_ => typeof _ !== 'undefined')
    return raw(elements_.map(auto).map(_ => _.toString().trim()).join(' '))
  }
 
export default line