import { fetchFromApi } from './api/pwnedpasswords' ; export interface PwnedPasswordSuffixes { [ suffix ] : number ; } typedef { Object . < string , number > } PwnedPasswordSuffixes param { string } prefix param options param { string } options . baseUrl param { string } options . userAgent returns { Promise < PwnedPasswordSuffixes > } example example see https export function pwnedPasswordRange ( prefix , options = { } ) { return ( fetchFromApi ( `/range/${ encodeURIComponent ( prefix ) }` , options ) . then ( ( data ) => data . split ( '\n' ) . filter ( Boolean ) ) . then ( ( results ) => results . reduce < PwnedPasswordSuffixes > ( ( acc , row ) => { const [ suffix , countString ] = row . split ( ':' ) ; acc [ suffix ] = parseInt ( countString , 10 ) ; return acc ; } , { } ) ) ) ; }