Skip to content

MartEye/agri-toolkit

Repository files navigation

agri-toolkit

A tiny TypeScript toolkit for farm data. Parse and format livestock ear tags and UK CPH numbers.

Install

npm i @marteye/agri-toolkit

Quick 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 available

Dev

  • Test: npm test
  • Build: npm run build
  • Node: >= 18

License

MIT

About

A small library for dealing with UK County Parish Holding numbers (CPH) and ear tag identifiers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors