Hi. Does anybody know how to translate the below code into JavaScript?

  for fn in self.hooks:
args = [self.consolidated_order_book, trades]
if asyncio.iscoroutinefunction(fn):
await fn(*args)
else:
fn(*args)
You already invited:

Jamie

Upvotes from:

I think what that code is trying to do is that using await for asynchronous calls and calling normally when in synchronous calls. It may be possible that in JS you can skip out the synchronous part of it. and not have that if. ( cuz I think js is async and that's what is best practice to keep functions like that). await is present in JS too.

If you wanna answer this question please Login or Register