db-vendo-client
Version:
Client for bahn.de public transport APIs.
23 lines (19 loc) • 434 B
JavaScript
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,
};