MCPcopy Index your code
hub / github.com/refined-github/refined-github / isTextNodeContaining

Function isTextNodeContaining

source/helpers/dom-utils.ts:83–92  ·  view source on GitHub ↗
(node: Nullable<Text | ChildNode>, expectation: RegExp | string)

Source from the content-addressed store, hash-verified

81 node instanceof Text || ([...node.childNodes].every(childNode => childNode instanceof Text));
82
83export const isTextNodeContaining = (node: Nullable<Text | ChildNode>, expectation: RegExp | string): boolean => {
84 // Make sure only text is being considered, not links, icons, etc
85 if (!node || !isTextNode(node)) {
86 console.warn('Expected Text node', node);
87 throw new TypeError(`Expected Text node, received ${String(node?.nodeName)}`);
88 }
89
90 // The string/regex may expect spaces, like for `conventional-commits`
91 return matchString(expectation, node.textContent) || matchString(expectation, node.textContent.trim());
92};
93
94export const assertNodeContent = <N extends Text | ChildNode>(node: Nullable<N>, expectation: RegExp | string): N => {
95 if (isTextNodeContaining(node, expectation)) {

Callers 2

assertNodeContentFunction · 0.85
addInfoFunction · 0.85

Calls 2

isTextNodeFunction · 0.85
matchStringFunction · 0.85

Tested by

no test coverage detected