primitives
equalishBy
Generic comparison function. This can be used to create a number of other more complex functions.
Usage
const productIdSelector = z => {
const d = z.indexOf('-')
return d > -1 ? z.slice(0, d) : 'NO_MATCH'
}
const isProduct = equalishBy(productIdSelector, 'coolco')
expect(isProduct('coolco-10020')).toBeTruthy()
expect(isProduct('otherco-xkswn')).toBeFalsy()
expect(isProduct('blabbo')).toBeFalsy()
coerce
Coerce values to boolean explicitly
Usage
expect(coerce(0)).toBeFalsy()
expect(coerce('')).toBeFalsy()
expect(coerce([])).toBeTruthy()
expect(coerce(1)).toBeTruthy()