functional js async loops