All files is-node-falsy.ts

0% Statements 0/27
0% Branches 0/1
0% Functions 0/1
0% Lines 0/27

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 26 27 28                                                       
/**
 * Copyright (c) OpenLens Authors. All rights reserved.
 * Licensed under MIT License. See LICENSE in root directory for more information.
 */

import type React from "react";

/**
 * Returns `true` if `node` is a falsy value
 */
export function isNodeFalsy(node: React.ReactNode): boolean {
  return !isNodeRenderable(node);
}

/**
 * Return `true` if React would render this
 */
export function isNodeRenderable(node: React.ReactNode): boolean {
  return Boolean(node);
}

/**
 * Returns the first react node provided that is would be rendered by react
 */
export function foldNodes(...nodes: React.ReactNode[]): React.ReactNode {
  return nodes.find(isNodeRenderable);
}