Skip to content

Instantly share code, notes, and snippets.

@intojs
Created December 1, 2019 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intojs/d12d818e0a6812f394ac19ad6e91b3fd to your computer and use it in GitHub Desktop.
Save intojs/d12d818e0a6812f394ac19ad6e91b3fd to your computer and use it in GitHub Desktop.
In Memory Loan Repository
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