15 lines
411 B
JavaScript
15 lines
411 B
JavaScript
|
import {BooleanT} from './BooleanT.js'
|
||
|
import {onType} from '#core/helpers.js'
|
||
|
import {Returns, Type, TypeOfTypes, Undefined} from '#core/Type.js'
|
||
|
import {NumberT} from '#number/NumberT.js'
|
||
|
|
||
|
const bool = f => Returns(BooleanT, f)
|
||
|
|
||
|
export const boolean = onType(
|
||
|
BooleanT, bool(p => p),
|
||
|
NumberT, bool(a => !!a),
|
||
|
TypeOfTypes, bool(() => true),
|
||
|
Undefined, bool(() => false),
|
||
|
[], bool(() => false)
|
||
|
)
|