china-railway-station 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2025, Pecasha
3
+ Copyright (c) 2025, Pomerun
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
6
6
  modification, are permitted provided that the following conditions are met:
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
1
  # China Railway Station
2
+
3
+ [![npm version](https://img.shields.io/npm/v/china-railway-station?logo=npm)](https://www.npmjs.com/package/china-railway-station)
4
+ [![npm version](https://img.shields.io/github/package-json/v/pomerun/china-railway-station?logo=github)](https://github.com/pomerun/china-railway-station/pkgs/npm/china-railway-station)
5
+ [![MIT Licence](https://img.shields.io/github/license/pomerun/china-railway-station)](https://github.com/pomerun/china-railway-station/blob/master/LICENSE)
6
+
2
7
  > 中国铁路车站信息
3
8
 
4
9
  ## 支持环境
@@ -11,7 +16,10 @@
11
16
  ```html
12
17
  <script src="build/index.iife.js"></script>
13
18
  <script>
14
- ChinaRailwayStation.getList();
19
+ const station = new ChinaRailwayStation();
20
+
21
+ station.list; // 全部车站列表
22
+ station.find("北京西"); // 获取 北京西 相关车站
15
23
  </script>
16
24
  ```
17
25
  ### ES Module
@@ -21,8 +29,12 @@ npm i china-railway-station
21
29
  ```
22
30
  引用依赖:
23
31
  ```javascript
24
- import { getList } from "china-railway-station";
25
- getList();
32
+ import ChinaRailwayStation from "china-railway-station";
33
+
34
+ const station = new ChinaRailwayStation();
35
+
36
+ station.list; // 全部车站列表
37
+ station.find("北京西"); // 获取 北京西 相关车站
26
38
  ```
27
39
  ### CommonJS
28
40
  安装依赖:
@@ -31,18 +43,23 @@ npm i china-railway-station
31
43
  ```
32
44
  引用依赖:
33
45
  ```javascript
34
- const { getList } = require("china-railway-station");
35
- getList();
46
+ const ChinaRailwayStation = require("china-railway-station");
47
+
48
+ const station = new ChinaRailwayStation();
49
+
50
+ station.list; // 全部车站列表
51
+ station.find("北京西"); // 获取 北京西 相关车站
36
52
  ```
37
- ## 调用方法
38
- #### getList
53
+ ## 属性、方法
54
+ #### list
39
55
  获取车站全部列表
40
- - 返回值:`Station[]`
41
- #### getListCityGroup
56
+ - 类型:`Station[]`
57
+ #### group
42
58
  获取车站全部列表(城市分组格式)
43
- - 返回值:`Record<string, Station[]>`
44
- #### getStation
59
+ - 类型:`Record<string, Station[]>`
60
+ #### find
45
61
  模糊搜索车站
62
+ - 类型:`function`
46
63
  - 参数:
47
64
 
48
65
  | 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
@@ -50,8 +67,9 @@ getList();
50
67
  | keyword | `string` | 否 | - | 搜索关键词 |
51
68
 
52
69
  - 返回值:`Station[]`
53
- #### getStationByName
70
+ #### findByName
54
71
  通过车站名获取车站信息
72
+ - 类型:`function`
55
73
  - 参数:
56
74
 
57
75
  | 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
@@ -59,8 +77,9 @@ getList();
59
77
  | name | `string` | 否 | - | 车站名 |
60
78
 
61
79
  - 返回值:`Station | undefined`
62
- #### getStationByTelecode
80
+ #### findByTelecode
63
81
  通过电报码获取车站信息
82
+ - 类型:`function`
64
83
  - 参数:
65
84
 
66
85
  | 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
@@ -68,8 +87,9 @@ getList();
68
87
  | telecode | `string` | 否 | - | 电报码 |
69
88
 
70
89
  - 返回值:`Station | undefined`
71
- #### getStationByPinyinCode
90
+ #### findByPinyinCode
72
91
  通过拼音码获取车站信息
92
+ - 类型:`function`
73
93
  - 参数:
74
94
 
75
95
  | 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
@@ -77,8 +97,9 @@ getList();
77
97
  | pinyinCode | `string` | 否 | - | 拼音码 |
78
98
 
79
99
  - 返回值:`Station[]`
80
- #### getStationByCity
100
+ #### findByCity
81
101
  通过城市名或城市编码获取车站信息
102
+ - 类型:`function`
82
103
  - 参数:
83
104
 
84
105
  | 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
@@ -86,5 +107,3 @@ getList();
86
107
  | city | `string` | 否 | - | 城市名/城市编码 |
87
108
 
88
109
  - 返回值:`Station[]`
89
- ## 说明
90
- - 数据来源:<https://kyfw.12306.cn/otn/resources/js/framework/station_name.js>