All files / object/src isNotNull.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

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 261x                                           11x 11x    
import { isNull } from "./isNull";
 
/**
 * Checks if a `value` is not `null`
 *
 * The opposite of {@link isNull}
 *
 * @example
 * ```
 * const result = isNotNull(0);
 * console.log(result); // true
 * ```
 *
 * @example
 * ```
 * const result = isNotNull(null);
 * console.log(result); // false
 * ```
 *
 * @param value - the value to check
 * @returns `true` if `value` is not `null`, otherwise `false`
 */
export const isNotNull = <T>(value: T): value is Exclude<T, null> => {
  return !isNull(value);
};