hk-mtr-util
v1.0.2
Published
A simple TypeScript Library contains information about HK MTR.
Downloads
5
Readme
HK MTR Util
A simple TypeScript Library contains information about HK MTR.
Installation
$ npm install hk-mtr-util
or
$ yarn add hk-mtr-util
Usage
Translation
import { MTRUtil } from 'hk-mtr-util';
const stations = MTRUtil.getKowloonLocation();
// [KOWLOON, MONG_KOK, LAI_CHI_KOK, ...]
const translatedStations = stations.map(MTRUtil.translate);
// ["九龍", "旺角", "荔枝角", ...]
By Area
import { MTRUtil } from 'hk-mtr-util';
// Kowloon
const stations = MTRUtil.getKowloonLocation();
// Island
const stations = MTRUtil.getIslandLocation();
// New Territories
const stations = MTRUtil.getNewTerritoriesLocation();
By Line
import { MTRUtil } from 'hk-mtr-util';
// Kwun Tong Line
const stations = MTRUtil.getKwunTongLine();
// Island Line
const stations = MTRUtil.getIslandLine();
// Disneyland Resort Line
const stations = MTRUtil.getDisneylandResortLine();
// etc...
Use Enum
import { IslandLine, SouthIslandLine } from 'hk-mtr-util';
const oceanPark = SouthIslandLine.OCEAN_PARK;
const central = IslandLine.CENTRAL;
Type Definition
import { MTRUtil } from 'hk-mtr-util';
import type { District, AirportExpressLine, IslandLine } from 'hk-mtr-util';
const allStations: District[] = MTRUtil.getAllLocation();
const airportStations: AirportExpressLine[] = MTRUtil.getAirportExpressLine();
const islandStations: IslandLine[] = MTRUtil.getIslandLine();