mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
22 lines
434 B
JavaScript
22 lines
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,
|
||
};
|