All files / src in.ts

90.9% Statements 10/11
100% Branches 7/7
100% Functions 1/1
90% Lines 9/10

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 23 24 2522x 22x 22x 22x 22x   22x                   22x 11x           32x  
import id from './identifier.js'
import tsql from './template.js'
import fallback from './fallback.js'
import isNull from './is-null.js'
import row from './row.js'
import type S from './sanitised.js'
import logicalFalse from './logical-false.js'
 
/**
 * @returns LHS in (RHS) expression.
 *
 * `undefined` RHS propagates.
 *
 * Falsy or empty array RHS returns logical false.
 */
export const in_ =
  (l: S | string, r: undefined | null | unknown[]): undefined | S =>
    typeof r === 'undefined' ?
      undefined :
      r && !isNull(r) && (r.length > 0) ?
        tsql`${fallback(l, id)} in ${row(r)}` :
        logicalFalse
 
export default in_