Initial experience of publishing Chinese API in NPM


Release details refer to Chinese code demo – create Node.js Module process, no accident.

The source of the data is the appendix of the 11th edition of the Xinhua Dictionary, “a brief list of Chinese Dynasties”, which will be refined gradually and made a draft first.

Now there is only one interface:

Var demo = require ('Chinese Dynasties')

console.log (demo. History ())


[{'name':'xia ','qi': - 2070, 'Zhi': - 1600},
  {name ':'shang','qi ': - 1600,' Zhi ': - 1046},
  {week ': [[object], [object], [object], [object]},
  {name ':'qin','qi ': - 221,' Zhi ': - 206},
  {Han ': [[object], [object]},
  {three kingdoms': [[object], [object], [object]},
  {name ':'western Jin','qi ': 265,' Zhi ': 317},
  {sixteen states of Eastern Jin Dynasty ': [[object], [object]},
  {northern and Southern Dynasties': [[object], [object]},
  {name ':'sui','qi ': 581,' Zhi ': 618},
  {name ':'tang','qi ': 618,' Zhi ': 907},
  {Five Dynasties and ten states': [[object], [object], [object], [object], [object], [object]},
  {song ': [[object], [object]},
  {name ':'liao','qi ': 907,' Zhi ': 1125},
  {name ':'xixia','qi ': 1038,' Zhi ': 1227},
  {name ':'jin','qi ': 1115,' Zhi ': 1234},
  {name ':'yuan','qi ': 1206,' Zhi ': 1368},
  {name ':'ming','qi ': 1368,' Zhi ': 1644},
  {name ':'qing','qi ': 1616,' Zhi ': 1911},
  The name: the Republic of China, Qi, 1912, Zhi, 1949,
  {name ':'People's Republic of China','qi ': 1949,' end ': undefined}]

It can be seen that the data structure is not very regular.

Source code in: program in Chinese / NPM Chinese Dynasties

The functions to be added are as follows:

  1. List all dynasties in order
  2. According to the name of the dynasty to obtain the beginning and ending time
  3. According to the date of the dynasty

According to the function, the data structure will be adjusted gradually. For example, whether to create enumeration types for dynasties.

You are welcome to suggest other functions or refine the above functions.

Recommended Today

How to share queues with hypertools 2.5

Share queue with swote To realize asynchronous IO between processes, the general idea is to use redis queue. Based on the development of swote, the queue can also be realized through high-performance shared memory table. Copy the code from the HTTP tutorial on swoole’s official website, and configure four worker processes to simulate multiple producers […]