Download wp-calypso/client/lib/domains/get-selection-domain.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 762 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/domains/get-selection-domain.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/domains/get-selection-domain.ts
-
curl -L -o get-selection-domain.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/domains/get-selection-domain.ts
762 Bytes
| import { type as domainTypes } from './constants'; | |
| export function getSelectedDomain< | |
| T extends { | |
| type?: string; | |
| name?: string; | |
| }, | |
| >( { | |
| domains, | |
| selectedDomainName, | |
| isSiteRedirect = false, | |
| }: { | |
| domains: T[] | Record< string, T > | null; | |
| selectedDomainName: string; | |
| isSiteRedirect?: boolean; | |
| } ): T | undefined { | |
| if ( ! domains ) { | |
| return undefined; | |
| } | |
| const domainList = Array.isArray( domains ) ? domains : Object.values( domains ); | |
| return domainList.find( ( domain ) => { | |
| const isType = ( type: string ) => domain.type === type; | |
| if ( domain.name !== selectedDomainName ) { | |
| return false; | |
| } | |
| if ( isSiteRedirect && isType( domainTypes.SITE_REDIRECT ) ) { | |
| return true; | |
| } | |
| return ! isType( domainTypes.SITE_REDIRECT ); | |
| } ); | |
| } | |