UNPKG

js-awe

Version:

Awesome js utils including - plan: An Asynchronous control flow with a functional taste - Chrono: record and visualize timelines in the console

23 lines (18 loc) 554 B
import { plan } from 'js-awe' const getCustomerBalances = plan().build([ [fetchAccounts], [(customerId)=>[1,2,3,4][customerId]], format, ]) console.log('result: ', await getCustomerBalances(0)) function format([fetchAccounts, customerId]) { return {fetchAccounts, customerId} } // Data fetch services are mocked for local running. // In production they should be fetch APIs to real implementations. function fetchAccounts(customerId) { return Promise.resolve([ { id: 1, type: 'saving' }, { id: 2, type: 'loan' }, ][customerId]) }