import { breachedAccount } from './breachedAccount' ; import { pasteAccount } from './pasteAccount' ; import type { Breach , Paste } from './api/haveibeenpwned/types' ; export interface SearchResults { breaches : Breach [ ] | null ; pastes : Paste [ ] | null ; } typedef SearchResults property { ( Breach [ ] | null ) } breaches property { ( Paste [ ] | null ) } pastes param { string } account param breachOptions param { string } breachOptions . apiKey param { string } breachOptions . domain param { boolean } breachOptions . truncate param { string } breachOptions . baseUrl param { string } breachOptions . userAgent returns { Promise < SearchResults > } example example see https export function search ( account , breachOptions = { truncate : true , } ) { const { apiKey , baseUrl , userAgent } = breachOptions ; return Promise . all ( [ breachedAccount ( account , breachOptions ) , /^.+@.+$/ . test ( account ) ? pasteAccount ( account , { apiKey , baseUrl , userAgent } ) : null , ] ) . then ( ( promises ) => ( { breaches : promises [ 0 ] , pastes : promises [ 1 ] , } ) ) ; }