import { checkProperty } from "../_check"
import { curry2 } from "../_util"
import { Observable } from "../Observable"
import { Property } from "../Property"
import { _combine } from "./combine"
import { map } from "./map"
export type Falsy = 0 | false | null | "" | undefined
export type Result = A extends Falsy ? A : (Exclude | B)
export const and: CurriedAnd = curry2(_and)
export interface CurriedAnd {
(a: Observable, b: Observable): Property>
(a: Observable): (b: Observable) => Property>
}
export const or: CurriedOr = curry2(_or)
export interface CurriedOr {
(a: Observable, b: Observable): Property>
(a: Observable): (b: Observable) => Property>
}
export function not(a: Observable): Observable {
checkProperty(a)
return map(x => !x, a)
}
function _and(a: Property, b: Property): Property> {
checkProperty(a)
checkProperty(b)
return _combine(xs => xs[0] && xs[1], [a, b] as any) as any
}
function _or(a: Property, b: Property): Property> {
checkProperty(a)
checkProperty(b)
return _combine(xs => xs[0] || xs[1], [a, b] as any) as any
}