<commit_before>'use strict'

/* @flow */

import NativeFS from 'fs'
import request from 'request'
import promisify from 'sb-promisify'
import type {PoolWorker} from 'range-pool'

export function promisedRequest(options: Object): Promise{
  return new Promise(function(resolve, reject) {
    const job = request(options)
    job.on('error', reject)
    job.on('response', resolve)
    job.pause()
  })
}

export function getRange(worker: PoolWorker): ?string {
  let range = null
  if (worker.getCurrentIndex() !== 0) {
    range = worker.getCurrentIndex() + '-'
    if (worker.getIndexLimit() !== Infinity) {
      range += worker.getIndexLimit()
    }
  }
  return range ? 'bytes=' + range : range
}

export const FS = {
  open: promisify(NativeFS.open),
  close: promisify(NativeFS.close),
  write: promisify(NativeFS.write)
}<commit_msg>:fire: Cleanup helpers<commit_after>'use strict'

/* @flow */

import NativeFS from 'fs'
import request from 'request'
import promisify from 'sb-promisify'
import type {PoolWorker} from 'range-pool'

export function promisedRequest(options: Object): Promise{
  return new Promise(function(resolve, reject) {
    const job = request(options)
    job.on('error', reject)
    job.on('response', resolve)
    job.pause()
  })
}

export function getRange(worker: PoolWorker): ?string {
  let range = null
  if (worker.getCurrentIndex() !== 0) {
    range = worker.getCurrentIndex() + '-'
    if (worker.getIndexLimit() !== Infinity) {
      range += worker.getIndexLimit()
    }
  }
  return range ? 'bytes=' + range : range
}

export const fsOpen = promisify(NativeFS.open)
{'fraction_non_alphanumeric': 0.13859540087010566, 'fraction_numerical': 0.001243008079552517, 'mean_word_length': 4.062893081761007, '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': '6909336', 'n_tokens_mistral': 505, 'n_tokens_neox': 504, 'n_words': 135}