npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mtr-kit

v1.13.6

Published

<div align="center">

Downloads

426

Readme

Banner

MTR Kit

Constants and utils for MTR HK

GitHub CI Conventional Commits npm type definitions

Usage | Development | Contributing

📦 Installation

npm i mtr-kit
// Or
yarn add mtr-kit
// Or
pnpm i mtr-kit

💻 Usage

API

RT Api

API client for Official Real-time MTR train information

import { rtApi } from "mtr-kit" // API Client
import { stopScheduleApi, LineCode } from "mtr-kit" // use the schedule API directly

const schedule = await stopScheduleApi.get({ line: LineCode.TML, stop: StopCode.TMU })

console.log(schedule)
/*
Output:
{
  status: 1,
  message: 'successful',
  sys_time: '2023-07-13 11:10:07',
  curr_time: '2023-07-13 11:09:58',
  data: {
    'TML-TUM': {
      curr_time: '2023-07-13 11:09:58',
      sys_time: '2023-07-13 11:10:07',
      DOWN: [Array]
    }
  },
  isdelay: 'N'
}
*/

Open Data API

API client for MTR routes, fares and barrier-fee facilities

import { openDataApi } from "mtr-kit" // API Client
import { fareApi, LineCode } from "mtr-kit" // use the fare API directly

const mtrFares = await fareApi.listMtrFares()

console.log(mtrFares)

/*
Output:
[
  {
    SRC_STATION_NAME: 'Central',
    SRC_STATION_ID: 1,
    DEST_STATION_NAME: 'Central',
    DEST_STATION_ID: 1,
    OCT_ADT_FARE: 0,
    OCT_STD_FARE: 0,
    OCT_JOYYOU_SIXTY_FARE: 0,
    SINGLE_ADT_FARE: 0,
    OCT_CON_CHILD_FARE: 0,
    OCT_CON_ELDERLY_FARE: 0,
    OCT_CON_PWD_FARE: 0,
    SINGLE_CON_CHILD_FARE: 0,
    SINGLE_CON_ELDERLY_FARE: 0
  },
  ...more
]
*/

const airportExpressFares = await fareApi.listAirportExpressFares()


/*
Output:
[
  {
    ST_FROM: 'HongKong',
    ST_FROM_ID: 44,
    ST_TO: 'Airport',
    ST_TO_ID: 47,
    OCT_ADT_FARE: 110,
    OCT_CHD_FARE: 55,
    SINGLE_ADT_FARE: 115,
    SINGLE_CHD_FARE: 57.5
  },
  ...more
]
*/

Constants

LineCode

Line code according to the Real-time MTR train information

import { LineCode } from "mtr-kit"

Lines

Line basic information

type Line = {
  line: LineCode
  nameEn: string
  nameZh: string
  color: string
  stops: {
    stop: StopCode
    up: LineStopDirection
    down: LineStopDirection
  }[]
}

import { lines } from "mtr-kit" // Line[]
import { lineMap } from "mtr-kit" // { [key in LineCode]: Line }


// Import line specifically
import { TML } from "mtr-kit" // Line

StopCode

Stop code according to the Real-time MTR train information

import { StopCode } from "mtr-kit"

Stops

Stop basic information

type Stop = {
  stop: StopCode
  nameEn: string
  nameZh: string
  color: string
  textColor: string
}

import { stops } from "mtr-kit" // Stop[]
import { stopMap } from "mtr-kit" // { [key in StopCode]: Stop }


// Import stop specifically
import { TUM } from "mtr-kit" // Stop

⌨️ Development

Local Development

pnpm i
pnpm run test

Build

pnpm run build

🤝 Contributing

🚢 Release Flow

This repo uses Release Please to release.

To release a new version

  1. Merge develop into main
  2. A GH Action will run(triggered automatically) and a Release PR will be created.
  3. Merge the release PR
  4. Wait for the second GH Action to run(triggered automatically)
  5. Create merge back PR(from main back to develop)
  6. You're done!