<commit_before>const {
  curry,
  map,
  prop,
  pick,
  zip,
  has,
  merge,
  props,
  append
} = require('ramda')

const unwrapArgs = (a) => {
  if (!Array.isArray(a)) return a
  if (a.length === 1) {
    return a[0]
  } else {
    return a
  }
}

const toArray = (a) => {
  return Array.isArray(a) ? a : [a]
}

const toPromise = (v) => {
  if (!v || !v.then) {
    return Promise.resolve(v)
  }

  return v
}

function success (payload = null) {
  return {
    success: true,
    payload
  }
}

function isSuccess (p) {
  return p.success === true
}

function getSuccesses (l) {
  return l.filter((p) => p.success === true)
}

function failure (error = null) {
  let e1 = errorToObject(error)
  if (typeof error === 'string') {
    e1 = {
      message: error
    }
  }
  return {
    success: false,
    error: e1
  }
}

function errorToObject (error) {
  const isError = error instanceof Error
  if (!isError) return error
  const errorProps = Object.getOwnPropertyNames(error)
  const e1 = pick(errorProps, error)
  const e2 = merge(e1, {
    name: error.name
  })
  return e2
}

function isFailure (p) {
  return p.success === false
}

function getFailures (l) {
  return l.filter((p) => p.success === false)
}

const normalizeToSuccess = (p) => {
  if (isProtocol(p)) return p
  return success(p)
}

const normalizeListToSuccess = map(normalizeToSuccess)

const normalizeToFailure = (p) => {
  if (isProtocol(p)) return p
  return failure(p)
}

const isProtocol = (p) => {
  if (!p) return false
  const hasSuccess = has('success')
  const hasPayload = has('payload')
  const hasError = has('error')
  if (hasSuccess(p) && (hasPayload(p) || hasError(p))) return true
  return false
}

const clean = (p) => {
  return pick(['success', 'error', 'payload'], p)
}

module.exports = {
  unwrapArgs,
  toArray,
  toPromise,
  curry,
  map,
  prop,
  pick,
  props,<commit_msg>refactor to all one-line functions<commit_after>const {
  curry,
  map,
  prop,
  pick,
  zip,
  has,
  merge,
  props,
  append,
  filter
} = require('ramda')

const hasSuccess             = has('success')
const hasPayload             = has('payload')
const hasError               = has('error')
const isArray                = Array.isArray
const isString               = s => typeof s === 'string'
const isPromise              = v => !v || !v.then
const isProtocol             = p => p ? hasSuccess(p) && (hasPayload(p) || hasError(p)) : false
const isSuccess              = p => p.success === true
const isFailure              = p => p.success === false
const clean                  = p => pick(['success', 'error', 'payload'], p)

const toError                = e => isString(e) ? { message: e } : e
const toArray                = a => isArray(a) ? a : [a]
const toPromise              = v => isPromise(v) ? Promise.resolve(v) : v

const S                      = { success: true }
const success                = (payload = null) => Object.assign({}, S, { payload })
const F                      = { success: false }
const failure                = (e = null) => Object.assign({}, F, { error: toError(e)})

const isError                = e => e instanceof Error
const errorProps             = e => Object.getOwnPropertyNames(e).concat('name')
const errorToObject          = e => isError(e) ? pick(errorProps(e), e) : e

const unwrapArray            = a => a.length === 1 ? a[0] : a
const unwrapArgs             = a => isArray(a) ? unwrapArray(a) : a
const getSuccesses           = l => filter(isSuccess, l)
const getFailures            = l => filter(isFailure, l)
const normalize              = (fn, p) => isProtocol(p) ? p : fn(p)
const normalizeToSuccess     = p => normalize(success, p)
const normalizeToFailure     = p => normalize(failure, p)
const normalizeListToSuccess = map(normalizeToSuccess)

module.exports = {
  unwrapArgs,
  unwrapArray,
  toArray,
  toPromise,
  curry,
  map,
  prop,
  pick,
  props,
{'fraction_non_alphanumeric': 0.1403643828586092, 'fraction_numerical': 0.0028226841159866563, 'mean_word_length': 2.458740017746229, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '855157', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1282, 'n_words': 359}