All files / src json.ts

85.71% Statements 6/7
50% Branches 1/2
100% Functions 1/1
83.33% Lines 5/6

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 1722x 22x                 22x 8x       22x  
import null_ from './null.js'
import nstring from './nstring.js'
import type S from './sanitised.js'
 
/**
 * @returns stringified json.
 *
 * `undefined` value is serialised as NULL.
 */
export const json =
  (x: unknown): S =>
    typeof x === 'undefined' ?
      null_ :
      nstring(JSON.stringify(x))
 
export default json