Created
December 1, 2019 02:31
-
-
Save intojs/d12d818e0a6812f394ac19ad6e91b3fd to your computer and use it in GitHub Desktop.
In Memory Loan Repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class InMemoryLoanRepo implements LoanRepo { | |
readonly calculations: LoanCalculation[] = []; | |
findOne(address: EmailAddress): Promise<LoanCalculation | undefined> { | |
const predicate = (c: LoanCalculation) => c.emailAddress.value === address.value; | |
const calculation = this.calculations.find(predicate); | |
return Promise.resolve(calculation); | |
} | |
save(calculation: LoanCalculation): Promise<void> { | |
this.calculations.push(calculation); | |
return Promise.resolve(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment