@washy-washy/core
v1.5.6
Published
Chart parsing, mixing rules and machine validation for washy-washy — a laundry chart generator.
Downloads
8,296
Readme
@washy-washy/core
Chart parsing, machine validation, and mixing rules for
washy-washy, a laundry chart
generator. This package holds no rendering or file I/O — just the pure logic
a CSV/JSON chart is checked and reasoned about with, shared by the CLI, the
web app, and @washy-washy/pdf.
Jump to: Browser · Node and Bun (CSV) · What's in it · Development · API reference
Requirements
- Node.js 18+, Bun, or any other runtime with modern ESM/
exportsmap support. - No system packages, no external services, no credentials — this package does no file I/O and no network access.
Install
npm install @washy-washy/coreTwo entry points
| Import | Use when | Includes |
| --------------------------- | --------------------------------- | --------------------------------- |
| @washy-washy/core/browser | Bundled for a browser | Everything except CSV parsing |
| @washy-washy/core | Node/Bun, reading a CSV from disk | Everything, including CSV parsing |
@washy-washy/core's CSV parser depends on csv-parse, which reaches for
Node's Buffer at import time even if nothing calls it — a bundler ships
that reference into the client, and it dies at runtime with
Buffer is not defined. @washy-washy/core/browser excludes it: a browser
consumer reads and writes charts as JSON instead (chartFromJson/
chartToJson), which needs no such dependency.
Usage
Browser
Read and write a chart as JSON instead of CSV — @washy-washy/core/browser
has no CSV parser (see Two entry points).
import {
chartFromJson,
chartToJson,
parseMachine,
} from "@washy-washy/core/browser";
const machine = parseMachine(machineConfig);
const instructions = chartFromJson(jsonFromStorage, machine);Node and Bun (CSV)
import { parseInstructions, parseMachine } from "@washy-washy/core";
const machine = parseMachine(JSON.parse(machineFileContents));
const instructions = parseInstructions(csvFileContents, machine);What's in it
- Every chart row carries an optional
referenceName/referenceLinkpair — who to credit for a care instruction that isn't obvious from the garment itself ("the manufacturer says wash these alone"), and a link backing it up. Both are empty strings when there's nothing to cite. parseMachinevalidates a machine description (washer programmes, temperatures, spins, options; iron thermostat positions) and hands back a typedMachine. Every failure names the field that's wrong.parseInstructions(CSV) andchartFromJson/chartToJson(JSON) parse a chart against aMachine, rejecting any row that asks for a setting the machine doesn't have.durationis checked too, against~H:MM(the~is optional) — empty is still fine, for a pile with no duration on record.parseConfig/configFromJson/configToJsondo the same for a machine and a chart together, as one{ machine, chart }object — the chart is always validated against the machine it's embedded with.configToJson's output leads with a$schemakey (schema/config.schema.json, generated from theConfigtype, so it can't drift) — an editor that reads it, VS Code among them, validates and autocompletes the file with no setup. The output is plainJSON.stringify(..., null, 2)— if you write it straight to a file in a Biome- or Prettier-linted repo, run your own formatter over it afterward, since a generic serializer can't match either tool's opinions.mixBlocker/canMix/resolvedecide whether two piles of laundry can share a drum, and why not when they can't.cardGroups/washGroups/ironGroupsgroup instructions the way a printed chart is laid out: one card per identical setup, a wash-only cut, an iron-only cut ordered by thermostat position.
Every exported function and type carries a TSDoc comment with a runnable
example — that's your editor's hover, and it's also the generated
API reference.
@washy-washy/pdf has the same.
Development
bun install
bun run check # lint, typecheck, test
bun run build # emit dist/ (tsdown)See CONTRIBUTING.md and, for how the modules fit together, docs/ARCHITECTURE.md.
