Suppose I have the following array:
const routes = [
{ isAsync: true },
{ isAsync: false },
{ isAsync: true },
]
How can I map this to async or sync functions? Something like the following doesn't work:
routes.map(({ isAsync }, index) =>
[isAsync ? 'async' : ''] () => { console.log('isAsync: ', isAsync, index) })
I could something like,
routes.map(({ isAsync }, index) =>
isAsync
? async () => { console.log('isAsync: ', isAsync, index) }
: () => { console.log('isAsync: ', isAsync, index) })
But I'm wondering if it's possible to do it the way I'm trying to in the first example?