All files / src utils.ts

100% Statements 11/11
100% Branches 6/6
100% Functions 3/3
100% Lines 11/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 213x 4x 3x 3x   3x 3x       3x     26x 8x 5x   8x      
export function assert(condition: any, message?: string): asserts condition {
  if (!condition) {
    const error = new Error(message || "Assertion failed")
    error.name = "Assertion Failure"
    // @ts-ignore
    error.framesToPop = 1
    throw error
  }
}
 
export function removeUndefined<O extends { [key: string]: any }>(
  obj: O
): Partial<O> {
  return Object.keys(obj).reduce((acc, key) => {
    if (obj[key] !== undefined) {
      acc[key] = obj[key]
    }
    return acc
  }, {} as { [key: string]: any }) as Partial<O>
}