zaphyra's git: oeffisearch

fast and simple tripplanner

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
import { isEmptyObject } from './helpers.js';
import { default as ds100 } from '../ds100.json';

let ds100R = {};

export const initDS100R = () => Object.keys(ds100).forEach(
	(id) => (ds100[id].split(', ').forEach(
		name => (ds100R[name] = id)
	))
);


export const getDS100byIBNR = id => {
	if (!ds100[Number(id)]) return null;

	return ds100[Number(id)];
};

export const getIBNRbyDS100 = name => {
	if (isEmptyObject(ds100R)) initDS100R();
	if (!ds100R[name]) return null;

	return ds100R[name];
};