All files / src columns.ts

38.46% Statements 5/13
0% Branches 0/4
0% Functions 0/2
45.45% Lines 5/11

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 21 22 2322x 22x 22x                 22x                   22x  
import id from './identifier.js'
import list from './list.js'
import fallback from './fallback.js'
import type S from './sanitised.js'
 
/**
 * @returns column projection based on provided record and optional filter.
 *
 * Propagates `undefined` if there are no non-`undefined` entries.
 */
export const columns =
  (record: Record<string, boolean | string | S>, filter: Record<string, boolean> = {}): undefined | S => {
    const values: (string | S)[] = []
    for (const key of Object.keys(record)) {
      Iif (filter[key] !== false) {
        values.push(record[key] === true ? key : record[key] as string | S)
      }
    }
    return list(values.map(_ => fallback(_, id)))
  }
 
export default columns