function translateDocument()

in src/contentScripts/functions.ts [169:190]


function translateDocument(
  client: TranslateClient,
  command: TranslateTextCommand,
  resolve: (value: TranslateTextCommandOutput) => void,
  reject: (reason?: any) => void,
  attempts = 0
) {
  setTimeout(() => {
    client
      .send(command)
      .then(res => {
        resolve(res);
      })
      .catch(e => {
        if (attempts < 4) {
          translateDocument(client, command, resolve, reject, attempts + 1);
        } else {
          reject(e);
        }
      });
  }, Math.pow(10, attempts));
}