<commit_before>//@flow

/*******************************************************************************
 * Imports
 *******************************************************************************/

import { Observable } from 'rxjs/observable'
import type { AjaxObservable } from 'rxjs/observable/dom/ajax'
import { ajax } from 'rxjs/observable/dom/ajax'
Observable.ajax = ajax
import 'rxjs/add/operator/timeout'

/*******************************************************************************
 * Type Definitions
 *******************************************************************************/

type Repository = string

type Branch = 'master' | string

export type Options = {
  repository: Repository;
  branch?: string;
}

export type Github = {
  get(opts: Get): AjaxObservable
}

export type Get = {
  path: string;
  branch?: string;
}

/*******************************************************************************
 * Public API
 *******************************************************************************/

export default (opts: Options): Github => {
  let { repository } = opts

  const buildUrl = ({path, branch}: Get): string => (
    `https://api.github.com/repos/${repository}/contents/${path}?ref=${branch}`
  )

  let get = (opts: Get): AjaxObservable => {
    return Observable
      .ajax({ url: buildUrl(opts) })
      .timeout(1000, new Error('Timeout :(') )
  }

  return { get: get }
}
<commit_msg>Pass in timeout as an option<commit_after>//@flow

/*******************************************************************************
 * Imports
 *******************************************************************************/

import { Observable } from 'rxjs/observable'
import type { AjaxObservable } from 'rxjs/observable/dom/ajax'
import { ajax } from 'rxjs/observable/dom/ajax'
Observable.ajax = ajax
import 'rxjs/add/operator/timeout'

/*******************************************************************************
 * Type Definitions
 *******************************************************************************/

type Repository = string

type Branch = 'master' | string

type Timeout = number

export type Options = {
  repository: Repository;
  branch?: Branch;
  timeout?: Timeout
}

export type Github = {
  get(opts: Get): AjaxObservable
}

export type Get = {
  path: string;
  branch?: string;
}

/*******************************************************************************
 * Public API
 *******************************************************************************/

export default (opts: Options): Github => {
  let { repository, timeout } = opts

  const buildUrl = ({path, branch}: Get): string => (
    `https://api.github.com/repos/${repository}/contents/${path}?ref=${branch}`
  )

  let get = (opts: Get): AjaxObservable => {
    return Observable
      .ajax({ url: buildUrl(opts) })
      .timeout(timeout, new Error("Timeout :("))
  }

  return { get: get }
}

{'fraction_non_alphanumeric': 0.4239316239316239, 'fraction_numerical': 0.0013675213675213675, 'mean_word_length': 5.487804878048781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '4841495', 'n_tokens_mistral': 743, 'n_tokens_neox': 683, 'n_words': 173}