Encode or decode geocaching ID (base31 or base16)
This package is available on npmjs.com: geocaching-base-converter
0123456789ABCDEFGHJKMNPQRTVWXYZ
ILOSU
npm install geocaching-base-converterimport { encode, decode } from "geocaching-base-converter"
// Encode a number with a prefix
let encodedValue = encode(1220432, "PR") // "PR1QQQP"
// Decode a geocaching reference code
let decodedValue = decode("PR1QQQP") // 1220432
// Works with GC codes too
let gcEncoded = encode(1585032, "GC") // "GC25050"
let gcDecoded = decode("GC2SOSO") // 1585032 (handles S→5, O→0 substitution)This project uses TAP (Test Anything Protocol) for testing.
npm testnpx tap test/convert.test.jsnpx tap test/*.js --coverageTAP automatically generates coverage reports. You can view detailed coverage information in the .tap/coverage/ directory after running tests.
The project uses:
- Biome for additional linting and formatting
# Install dependencies
npm install
# Run tests
npm test
# Format code with Biome
npx @biomejs/biome format --write .
# Lint code with Biome
npx @biomejs/biome lint .