npm module: retry a function with a series of arguments until one works