@marteye/agri-toolkit
v0.1.1
Published
TypeScript toolkit for agricultural data parsing and utilities
Downloads
19
Maintainers
Readme
agri-toolkit
A tiny TypeScript toolkit for farm data. Parse and format livestock ear tags and UK CPH numbers.
Install
npm i @marteye/agri-toolkitQuick start
import { EarTag, CPH, isValidCPH } from "@marteye/agri-toolkit";
// Ear tags
const tag = EarTag.parse("UK 1234567 89012");
tag.isEartag(); // true
tag.toString(); // "UK 1234567 89012"
tag.toISO24631(); // "1 0 04 00 0 826 1234567 89012"
// Add a fallback country if the tag has only numbers
EarTag.format("123456789012", "UK"); // => "UK 1234567 89012"
// UK CPH (County/Parish/Holding)
isValidCPH("12/345/6789"); // true
const cph = CPH.parse("12/345/6789");
cph.isValid();
cph.region; // "England" | "Wales" | "Scotland" | "Unknown"
cph.details(); // parsed pieces + county/parish names when availableDev
- Test:
npm test - Build:
npm run build - Node: >= 18
License
MIT
