isTextNode

Checks if the value is a Text node.

Usage Scenarios

  • Text Manipulation: When you need to handle text content in the DOM, you can use isTextNode to identify Text nodes before performing operations like updating text content.
  • Traversing the DOM: During DOM traversal, you can use this method to filter out Text nodes for specific processing.

Examples

import { isTextNode } from 'funtool';

isTextNode(document.createTextNode('Hello')); // ✅ true

Signature

function isTextNode<T = unknown>(value: T): value is T & Text

Parameters

  • value (T): The value to check.

Returns

  • (value is T & Text): Returns true if the value is a Text node.