import { LoginFailureRepository } from '../login-failure.repository' ; import { LoginFailure } from './../../../../models/login.failure' ; export class InMemoryLoginFailureRepository implements LoginFailureRepository { getLastFailures ( userEmail , number ) { const ascendingByTime = ( f1 , f2 ) => f1 . datetime . getTime ( ) - f2 . datetime . getTime ( ) ; const lastFailures = LOGIN_FAILURES . sort ( ascendingByTime ) . slice ( - number ) ; return Promise . resolve ( lastFailures ) ; } registerFailedLogin ( userEmail , datetime ) { LOGIN_FAILURES . push ( new LoginFailure ( userEmail , datetime ) ) ; return Promise . resolve ( ) ; } } const LOGIN_FAILURES = [ ] ;