All files / src like.ts

91.66% Statements 11/12
50% Branches 2/4
100% Functions 2/2
90.9% Lines 10/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 23 24 25 2622x 22x 22x 22x 22x       22x 1x                   22x 1x       22x  
import fallback from './fallback.js'
import id from './identifier.js'
import isNull from './is-null.js'
import nstring from './nstring.js'
import tsql from './template.js'
import type S from './sanitised.js'
 
const rhsLike =
  (rhs: unknown): S =>
    isNull(rhs) ?
      tsql`is null` :
      tsql`like ${nstring(String(rhs))}`
 
/**
 * @returns LIKE operator.
 *
 * `undefined` is propagated.
 */
export const like =
  (lhs: S | string, rhs: unknown): undefined | S =>
    typeof rhs === 'undefined' ?
      undefined :
      tsql`${fallback(lhs, id)} ${rhsLike(rhs)}`
 
export default like