Return when first promise resolves
问题 Goal I have a bunch of file names in an array, and would like to read the contents of the first of the files that exists. They're config files, so it's important that the order is deterministic, so I can't use .race() . The version I have below maps over each file in order, tries to load it, and if it loads successfully, calls resolve. Problems Here are a couple of issues with this implementation: Calling resolve(...) doesn't actually exit the loop, so the program opens every file in the list