{"size": 457, "ext": "js", "max_stars_repo_path": "test/utils/resultAction.js", "max_stars_repo_name": "leeor/redux-serial-effects", "max_stars_repo_stars_event_min_datetime": "2017-08-29T02:03:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-13T15:21:59.000Z", "max_issues_repo_path": "test/utils/resultAction.js", "max_issues_repo_name": "leeor/redux-serial-effects", "max_issues_repo_issues_event_min_datetime": "2018-10-11T15:10:53.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-14T06:06:08.000Z", "max_forks_repo_path": "test/utils/resultAction.js", "max_forks_repo_name": "leeor/redux-serial-effects", "max_forks_repo_forks_event_min_datetime": "2021-04-22T23:34:10.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T23:34:10.000Z"}
{"max_stars_count": 14, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 19.0416666667, "max_line_length": 67, "alphanum_fraction": 0.6455142232}
'use strict'

const { Either } = require('../../src/utils/either')

const toEither = action => {
  if (action.error === true) {
    return Either.Left(action.payload)
  } else {
    return Either.Right(action.payload)
  }
}

const match = (action, patterns) => {
  return toEither(action).match(patterns)
}

const creatorWithType = type =>
  type ? (error, payload) => ({ type, error, payload }) : undefined

module.exports = {
  match,
  creatorWithType
}
