iep-ui
Version:
An enterprise-class UI design language and Vue-based implementation
34 lines (28 loc) • 1.82 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPinyinMatch = exports.getPinyin = exports.toType = undefined;
var _pinyinPro = require('pinyin-pro');
var toType = exports.toType = function toType(e) {
return Object.prototype.toString.call(e).slice(8, -1).toLowerCase();
};
/**
* 根据汉字获取拼音,如果不是汉字直接返回原字符
* @param str 要转换的汉字
* @param pattern 输出的结果的信息(拼音 / 声母 / 韵母 / 音调 / 首字母),默认pinyin, 可选值 pinyin / initial / final / num / first
* @param toneType 音调输出形式(拼音符号 / 数字 / 不加音调),默认symbol, 可选值 symbol / num / none
* @param type 输出结果类型(字符串/数组),string / array, 可选值 string
* @param multiple 输出多音字全部拼音(仅在 word 为长度为 1 的汉字字符串时生效),默认false, 可选值 true / false
* @param mode 拼音查找的模式(常规模式 / 姓氏模式),默认normal, 可选值 ormal / surname
* @param removeNonZh 是否输入字符串中将非汉字的字符过滤掉,默认false, 可选值 true / false
* @param nonZh 定义非汉字字符的输出形式(以空格间隔输出/紧凑输出/移除非汉字字符),默认spaced, 可选值 spaced / consecutive / removed
* @param v 是否将拼音 ü 替换为 v,默认false, 可选值 true / false
*/
var getPinyin = exports.getPinyin = function getPinyin(str) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { pattern: 'first', type: 'array' };
return (0, _pinyinPro.pinyin)(str, params);
};
var getPinyinMatch = exports.getPinyinMatch = function getPinyinMatch(str, pinyin) {
return (0, _pinyinPro.match)(str, pinyin);
};
;