crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
24 lines (18 loc) • 552 B
JavaScript
/** @license ISC License (c) copyright 2016 original and current authors */
/** @author Ian Hofmann-Hicks (evil) */
var curry = require('../core/curry')
var isFunction = require('../core/isFunction')
function swap(f, g, m) {
if(!(isFunction(f) && isFunction(g))) {
throw new TypeError(
'swap: Function required for first two arguments'
)
}
if(m && isFunction(m.swap)) {
return m.swap(f, g)
}
throw new TypeError(
'swap: Async, Either, Pair or Result required for third arguments'
)
}
module.exports = curry(swap)