<commit_before>import { Host } from '@algolia/transporter-types';
import { Response } from '@algolia/requester-types';

export const enum RetryOutcome {
  Success = 'SUCCESS',
  Retry = 'RETRY',
  Fail = 'FAIL',
}

export class RetryStrategy {
  public decide(host: Host, response: Response) {
    if (response.isTimedOut) {
      return RetryOutcome.Retry;
    }

    if (this.isRetryable(response)) {
      return RetryOutcome.Retry;
    }

    if (this.isSuccess(response)) {
      return RetryOutcome.Success;
    }

    return RetryOutcome.Fail;
  }

  private isRetryable({ status }: Response): boolean {
    return ~~(status / 100) !== 2 && ~~(status / 100) !== 4;
  }

  private isSuccess({ status }: Response): boolean {
    return status / 100 === 2;
  }
}<commit_msg>fix(retry): non success outcomes on status like 201<commit_after>import { Host } from '@algolia/transporter-types';
import { Response } from '@algolia/requester-types';

export const enum RetryOutcome {
  Success = 'SUCCESS',
  Retry = 'RETRY',
  Fail = 'FAIL',
}

export class RetryStrategy {
  public decide(host: Host, response: Response) {
    if (response.isTimedOut) {
      return RetryOutcome.Retry;
    }

    if (this.isRetryable(response)) {
      return RetryOutcome.Retry;
    }

    if (this.isSuccess(response)) {
      return RetryOutcome.Success;
    }

    return RetryOutcome.Fail;
  }

  private isRetryable({ status }: Response): boolean {
    return ~~(status / 100) !== 2 && ~~(status / 100) !== 4;
  }

  private isSuccess({ status }: Response): boolean {
    return ~~(status / 100) === 2;
  }
}
{'fraction_non_alphanumeric': 0.14080100125156444, 'fraction_numerical': 0.016896120150187734, 'mean_word_length': 3.2301587301587302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7138015', 'n_tokens_mistral': 547, 'n_tokens_neox': 522, 'n_words': 129}