Repository URL to install this package:
|
Version:
6.0.4 ▾
|
import curry from '../fp/curry'
/**
* @desc first fn & second fn
* @memberOf conditional
* @since 4.0.1
*
* @param {Function} left first fn
* @param {Function} right second fn
* @return {Function | boolean} both functions return truthy @curried
*
* @curried
* @name and
* @alias both
* @func
*
* @example
*
* const both = and(x => typeof x === 'boolean', x => x === true)
*
* both([true])
* //=> true
*
* both([false])
* //=> false
*
* both([1])
* //=> false
*
*/
export interface Return<Value> {
(...args: any[]): Value
(): Value
}
export interface And<Value = any> {
// (left: Return<false>, right: Return<true>): (x: Value) => boolean
// (left: Return<true>, right: Return<true>): (x: Value) => boolean
(left: Return<true | false>, right: Return<true | false>): (x: Value) => boolean
}
const and = <Value = any>(left: Return<boolean>, right: Return<boolean>) => (x: Value) => left(x) && right(x)
export default curry(2, and)