Download wp-calypso/client/blocks/comments/utils.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 632 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/blocks/comments/utils.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/blocks/comments/utils.jsx
-
curl -L -o utils.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/blocks/comments/utils.jsx
632 Bytes
| import { get } from 'lodash'; | |
| /** | |
| * @param {Object} ancestor potential ancestor comment | |
| * @param {Object} child potential child comment | |
| * @param {Object} commentsTree commentsTree for a post, see associated getPostCommentsTree selector | |
| * @returns {boolean} return true if parent is an ancestor of child | |
| */ | |
| export const isAncestor = ( ancestor, child, commentsTree ) => { | |
| if ( ! ancestor || ! child || ! child.parent || ! commentsTree ) { | |
| return false; | |
| } | |
| const nextParent = get( commentsTree, [ child.parent.ID, 'data' ] ); | |
| return child.parent.ID === ancestor.ID || isAncestor( ancestor, nextParent, commentsTree ); | |
| }; | |