UNPKG

@rsonglab/baijiaxing

Version:

It's just an array of Hundred Family Surnames.

106 lines (72 loc) 2.8 kB
# The Hundred Family Surnames (baijiaxing) [![Node.js CI](https://github.com/rsonglab/baijiaxing/actions/workflows/node.js.yml/badge.svg)](https://github.com/rsonglab/baijiaxing/actions/workflows/node.js.yml) [![Coverage Status](https://coveralls.io/repos/github/rsonglab/baijiaxing/badge.svg?branch=master)](https://coveralls.io/github/rsonglab/baijiaxing?branch=master) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/rsonglab/baijiaxing/blob/master/LICENSE) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@rsonglab/baijiaxing)](https://www.npmjs.com/package/@rsonglab/baijiaxing) It's a list of the Hundred Family Surnames. > "The Hundred Family Surnames (Chinese: 百家姓), commonly known as Bai Jia Xing, also translated as Hundreds of Chinese Surnames, is a classic Chinese text composed of common Chinese surnames." - [Wikipedia](https://en.wikipedia.org/wiki/Hundred_Family_Surnames) ## Install ```shell npm i @rsonglab/baijiaxing ``` ## Usage ```js const bjx = require("@rsonglab/baijiaxing"); bjx.list; /* [ '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ... 404 more items ] */ bjx.object; /* { '': 'Zhao', '': 'Qian', '': 'Sun', '': 'Li', '': 'Zhou', '': 'Wu', '': 'Zheng', '': 'Wang', '': 'Feng', '': 'Chen', ... 494 more items } */ bjx.random(); // 公孫 bjx.getID("宋"); // 118 bjx.getName(118); // 宋 bjx.getName("Song"); // 宋 bjx.getPinyin("宋"); // Song ``` Live demo: [https://runkit.com/embed/uc856jmfnoj1](https://runkit.com/embed/uc856jmfnoj1) ## API ### bjx.list An array with all the Surnames. ### bjx.object An object with all the Surnames. ### bjx.random() Return a random Surnames. ### bjx.getID(name) `@param name [Required]` Search an id by surname. ### bjx.getName(id) `@param id/pinyin [Required]` Search a surname by id or pinyin. ### bjx.getPinyin(name) `@param name [Required]` Search an pinyin by surname. ## License It is an open-source npm package licensed under the "MIT License". Please see the file LICENSE for license terms.