Download wp-calypso/client/state/comments/utils.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 791 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/utils.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/comments/utils.js
-
curl -L -o utils.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/utils.js
791 Bytes
| import { domForHtml } from 'calypso/lib/post-normalizer/utils'; | |
| export const getStateKey = ( siteId, postId ) => `${ siteId }-${ postId }`; | |
| export const deconstructStateKey = ( key ) => { | |
| const [ siteId, postId ] = key.split( '-' ); | |
| return { siteId: +siteId, postId: +postId }; | |
| }; | |
| export const getErrorKey = ( siteId, commentId ) => `${ siteId }-${ commentId }`; | |
| export const commentHasLink = ( commentContent, apiSuppliedValue ) => { | |
| // In case API provides value for has_link, skip parsing and return it instead. | |
| if ( typeof apiSuppliedValue !== 'undefined' ) { | |
| return apiSuppliedValue; | |
| } | |
| try { | |
| return !! domForHtml( commentContent ).getElementsByTagName( 'a' ).length; | |
| } catch ( e ) { | |
| return false; | |
| } | |
| }; | |
| export const getCommentDate = ( { date } ) => new Date( date ); | |