@smartput/range
v0.1.2
Published
Numeric and measured ranges: `10–20 km`.
Maintainers
Readme
@smartput/range
Numeric and measured ranges:
10–20 km.
RANGE_KINDS registers a range over every ratio kind, and Range is the class door onto one.
Setup
npm add @smartput/rangeExample
import { sliceItems, parseSlice } from "@smartput/range";
JSON.stringify(parseSlice("2-4")) // "{\"start\":1,\"end\":3}"
sliceItems(["a", "b", "c", "d", "e"], "2-4").join(",") // ""
sliceItems(["a", "b", "c", "d", "e"], "last 2").join(",") // ""Selection over a list — the "3, 5-7, last 2" a user types into a print
dialog. One-based by default, because that is what the user counted;
ZeroIndexError is what an index of 0 gets rather than a silent off-by-one.
Entry points
| Import | Contents |
| --- | --- |
| @smartput/range | The package root. |
| @smartput/range/class | The immutable value class. |
Runtime exports
Type-only exports are erased and do not appear here.
ANCHORS · BackwardsRangeError · DEFAULT_DASH_WEIGHT · DEFAULT_INDEX_WEIGHT · DEFAULT_PHRASE_WEIGHT · INDEX_KIND · INDEX_UNIT · RANGE_KIND · RANGE_KINDS · RANGE_UNIT · Range · ZeroIndexError · assertOrdered · claimAt · createIndex · createRange · formatSlice · index · parseSlice · range · resolveSlice · sliceItems · toPosition · unwrapSlice · wrapSlice
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 | | --- | --- | --- | | range | ≤ 43.8 kB | ≤ 17.4 kB | | range/class | ≤ 43.8 kB | ≤ 17.4 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/range.md.
