Last active
April 26, 2018 22:38
-
-
Save dewey92/2bb51d23ddd8d2225f0dc96f137d08ee to your computer and use it in GitHub Desktop.
Transaksi Bambang
This file contains hidden or 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
| interface Account { | |
| name: string, | |
| email: string, | |
| } | |
| interface AccountRepo { | |
| find: (no: string) => Account | |
| } | |
| const accRepo: AccountRepo = { | |
| find: no => ({ name: 'Bambang', email: 'tampan@tampan.com' }) | |
| }; | |
| declare function debit(no: string, amount: number): (accountRepo: AccountRepo) => Account; | |
| declare function credit(no: string, amount: number): (accountRepo: AccountRepo) => Account; | |
| declare function balance(no: string): (accountRepo: AccountRepo) => number; | |
| const transaksiBambang = (no: string) => (repo: AccountRepo) => { | |
| debit(no, 100)(repo); | |
| debit(no, 50)(repo); | |
| credit(no, 80)(repo); | |
| balance(no)(repo); | |
| } | |
| transaksiBambang('NL90DLBK0286293543')(accRepo) // <- Inject deps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment