@smartput/boolean
v0.1.2
Published
The kind comparisons land in.
Maintainers
Readme
@smartput/boolean
The kind comparisons land in.
1 kg > 900 g has to evaluate to something. This is that
something: a two-valued opaque kind, plus truthOf() and a Bool class, so
a comparison result is a value like any other rather than a JavaScript boolean
smuggled out of the engine.
Setup
npm add @smartput/booleanExample
import { composeLocale, createEngine } from "@smartput/core";
import { english } from "@smartput/core/locale/en";
import { BUILTIN_KINDS } from "@smartput/kinds";
import BUILTIN_EN from "@smartput/kinds/locale/en";
const engine = createEngine({
locales: [composeLocale(english, BUILTIN_EN)],
kinds: BUILTIN_KINDS,
});
engine.evaluate("1 kg > 900 g").formatted // "true"
engine.evaluate("30 min < 1 h").formatted // "true"
engine.evaluate("5 km != 5000 m").formatted // "false"
engine.evaluate("1000 mb = 1 gb").formatted // "true"A comparison is a kind, so it ranks and formats like any other
reading. The last row is the interesting one: mb and gb are decimal, so
the answer is what the units say rather than what a binary intuition expects.
Entry points
| Import | Contents |
| --- | --- |
| @smartput/boolean | The package root. |
| @smartput/boolean/class | The immutable value class. |
Runtime exports
Type-only exports are erased and do not appear here.
BOOLEAN_KIND · BOOLEAN_UNIT · Bool · boolean · booleanValue · truthOf
Dependencies
What it costs
Ceilings, not measurements. bun run check-size bundles each entry with
bun build --minify and fails if a row crosses its ceiling or drops more
than 30 % below it — a budget that is only an upper bound reports a vanished
graph as a triumph.
| Import | Minified | Gzipped | | --- | --- | --- | | boolean | ≤ 33.9 kB | ≤ 13.5 kB | | boolean/class | ≤ 34.2 kB | ≤ 13.7 kB |
Generated by scripts/gen-readmes.ts — run bun run docs:readmes. Every
output above was produced by running the line beside it. The full page, with
live demos, is docs/packages/boolean.md.
