xdash / xor
Function: xor()
xor<
Args>(…fns): (…args) =>boolean
XOR operator for functions.
Type parameters
• Args extends readonly unknown[]
Parameters
• …fns: (…args) => boolean[]
functions to combine
Returns
Function
a function that returns true if exactly one of the input functions returns true
Parameters
• …args:
ArgsReturns
boolean
Example
const isEven = (n: number) => n % 2 === 0
const isPositive = (n: number) => n > 0
const isPositiveXorEven = xor(isEven, isPositive)
isPositiveXorEven(2) // returns false
isPositiveXorEven(3) // returns true
isPositiveXorEven(4) // returns false