Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active April 26, 2018 22:38
Show Gist options
  • Select an option

  • Save dewey92/2bb51d23ddd8d2225f0dc96f137d08ee to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/2bb51d23ddd8d2225f0dc96f137d08ee to your computer and use it in GitHub Desktop.
Transaksi Bambang
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