db-vendo-client/format/station.js
2024-12-21 15:26:49 +00:00

22 lines
434 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {formatLocationIdentifier} from './location-identifier.js';
const isIBNR = /^\d{6,}$/;
const formatStation = (id) => {
if (!isIBNR.test(id)) {
throw new Error('station ID must be an IBNR.');
}
return {
type: 'S', // station
// todo: name necessary?
lid: formatLocationIdentifier({
A: '1', // station?
L: id,
// todo: `p` timestamp of when the ID was obtained
}),
};
};
export {
formatStation,
};