Download wp-calypso/client/lib/media-serialization/detect-format.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 726 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/media-serialization/detect-format.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/media-serialization/detect-format.js
-
curl -L -o detect-format.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/media-serialization/detect-format.js
726 Bytes
| import { includes } from 'lodash'; | |
| import { getMimePrefix } from 'calypso/lib/media/utils'; | |
| import { Formats, MediaTypes } from './constants'; | |
| /** | |
| * Module variables | |
| */ | |
| const VALID_SHORTCODE_TYPES = [ 'closed', 'self-closing', 'single' ]; | |
| export default function ( node ) { | |
| if ( 'string' === typeof node ) { | |
| return Formats.STRING; | |
| } | |
| if ( 'object' === typeof node && 'string' === typeof node.nodeName ) { | |
| return Formats.DOM; | |
| } | |
| if ( node && node.tag && includes( VALID_SHORTCODE_TYPES, node.type ) ) { | |
| return Formats.SHORTCODE; | |
| } | |
| if ( node && node.type && includes( MediaTypes, node.type ) ) { | |
| return Formats.OBJECT; | |
| } | |
| if ( getMimePrefix( node ) ) { | |
| return Formats.API; | |
| } | |
| return Formats.UNKNOWN; | |
| } | |