UNPKG

@gameroom/cli

Version:

A command line tool for Gameroom

22 lines (20 loc) 446 B
const timeout = require('./timeout') module.exports = async (f, output) => { while (true) { try { const result = await f() return result } catch (err) { // not found if (err.response?.status === 404) return null // too many requests if (err.response?.status === 429) { await timeout() continue } // anything else if (output) output(err) throw err } } }