import R from 'ramda';
import isUpperCase from '../src/is-upper-case.js';

// a -> a
const swapCase = R.compose(
  R.join(''),
  R.map(
    R.either(
      R.both(isUpperCase, R.toLower),
      R.both(R.compose(R.not, isUpperCase), R.toUpper)
    )
  )
);

export default swapCase;

import R from 'ramda';
import compose from './util/compose.js';
import isUpperCase from '../src/is-upper-case.js';

// a -> a
const swapCase = compose(
  R.join(''),
  R.map(
    R.either(
      R.both(isUpperCase, R.toLower),
      R.both(compose(R.not, isUpperCase), R.toUpper)
    )
  )
);

export default swapCase;

Refactor swapCase function to use custom compose function
Refactor swapCase function to use custom compose function
