import { findLastIndex , reduce } from '@typed/list' ; import { Maybe , race } from '@typed/maybe' ; export function findNamedArg ( name , aliases , args ) { const value = `--${ name }` ; const namedValue = findLastIndex ( ( arg ) => arg . startsWith ( value ) , args ) ; const aliasValues = aliases . map ( ( alias ) => `-${ alias }` ) ; return reduce ( ( maybe , value ) => race ( maybe , findLastIndex ( ( arg ) => arg . startsWith ( value ) , args ) ) , namedValue , aliasValues ) ; }