nanomath/src/boolean/type.js
Glen Whitney 47370cec9e feat: Index behaviors by return typing strategy
* Adds the concept of, and options for, the return typing strategy
  * adds the strategy at the beginning of every behavior index
  * adds the strategy as an additional argument to resolve
  * No actual use of return type strategy so far
  * Sets up eslint
  * Fixes eslint errors
2025-04-26 00:20:30 -07:00

14 lines
438 B
JavaScript

import {BooleanT} from './BooleanT.js'
import {match} from '#core/TypePatterns.js'
import {Returns, TypeOfTypes, Undefined} from '#core/Type.js'
import {NumberT} from '#number/NumberT.js'
const bool = f => Returns(BooleanT, f)
export const boolean = [
match(BooleanT, bool(p => p)),
match(NumberT, bool(a => !!a)),
match(TypeOfTypes, bool(() => true)),
match(Undefined, bool(() => false)),
match([], bool(() => false))
]