import head from 'lodash/head' ; import type { LabwareDefinition2 } from '@opentrons/shared-data' ; import { getLatestLabwareDef } from './getLabware' ; function filterLabwareDefinitions ( namespace , loadName , version , customLabware ) { return ( head ( customLabware . filter ( def => ( loadName && def . parameters . loadName === loadName ) || ( namespace && def . namespace === namespace ) || ( version && String ( def . version ) === version ) ) ) || null ) ; } export function findLabwareDefWithCustom ( namespace , loadName , version , customLabware ) { return namespace === 'opentrons' ? getLatestLabwareDef ( loadName ) : filterLabwareDefinitions ( namespace , loadName , version , customLabware ) ; }