pinyin-pro
Advanced tools
Comparing version 3.2.1 to 3.2.2
@@ -0,1 +1,5 @@ | ||
## 3.2.2 | ||
- 修复 options 为 `{ mutiple: true, type: 'array' }` 时若未找到多音字结果的报错问题 | ||
## 3.2.1 | ||
@@ -2,0 +6,0 @@ |
@@ -65,8 +65,9 @@ import { DICT1 } from '../data/dict1'; | ||
const getMultipleTone: GetMultipleTone = (word) => { | ||
return DICT1[word]; | ||
return DICT1[word] || word; | ||
}; | ||
type GetInitialAndFinal = ( | ||
pinyin: string | ||
) => { final: string; initial: string }; | ||
type GetInitialAndFinal = (pinyin: string) => { | ||
final: string; | ||
initial: string; | ||
}; | ||
const getInitialAndFinal: GetInitialAndFinal = (pinyin) => { | ||
@@ -73,0 +74,0 @@ const pinyin_arr = pinyin.split(' '); |
{ | ||
"name": "pinyin-pro", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"description": "汉字转拼音库。获取中文拼音、韵母、声母、声调、首字母等信息。", | ||
@@ -44,2 +44,3 @@ "main": "./dist/index.js", | ||
"@types/jest": "^26.0.20", | ||
"babel-eslint": "^10.1.0", | ||
"chai": "^4.3.4", | ||
@@ -46,0 +47,0 @@ "commitizen": "^4.2.2", |
@@ -24,7 +24,5 @@ [![pinyin-pro Logo](https://i.ibb.co/26fJ5vF/pinyin-logo.png)](https://github.com/zh-lx/pinyin-pro) | ||
当前版本: 3.2.0 -> 3.2.1 | ||
当前版本: 3.2.1 -> 3.2.2 | ||
- 修复部分单字的常用读音<br> | ||
- 艾: 'yì' -> 'ài yì' | ||
- 吽: 'ōu' -> 'hōng hǒu ōu' | ||
- 修复 options 为 `{ mutiple: true, type: 'array' }` 时若未找到多音字结果的报错问题 | ||
@@ -31,0 +29,0 @@ 点击查看 [版本更新文档](./CHANGELOG.md) |
@@ -152,2 +152,7 @@ const { pinyin } = require('../dist/index'); | ||
}); | ||
it('none-find', () => { | ||
const result = pinyin('a', { multiple: true, type: 'array' }); | ||
expect(result).to.deep.equal(['a']); | ||
}); | ||
}); | ||
@@ -218,1 +223,94 @@ | ||
}); | ||
describe('getPinyin', () => { | ||
it('double symbol', () => { | ||
const result = pinyin('aaaa'); | ||
expect(result).to.be.equal('aaaa'); | ||
}); | ||
it('length greater than 5', () => { | ||
const result = pinyin('赵钱孙李吧你'); | ||
expect(result).to.be.equal('zhào qián sūn lǐ ba nǐ'); | ||
}); | ||
it('dict2', () => { | ||
const result = pinyin('阿比让'); | ||
expect(result).to.be.equal('ā bǐ ràng'); | ||
}); | ||
}); | ||
describe('getNumOfTone', () => { | ||
it('no tone', () => { | ||
const result = pinyin('赵钱孙李吧你b', { pattern: 'num' }); | ||
expect(result).to.be.equal('4 2 1 3 0 3 '); | ||
}); | ||
}); | ||
describe('pinyinFn', () => { | ||
it('not string type', () => { | ||
const result = pinyin(2222); | ||
expect(result).to.be.equal(2222); | ||
}); | ||
it('empty string', () => { | ||
const resultStr = pinyin(''); | ||
const resultArr = pinyin('', { type: 'array' }); | ||
expect(resultStr).to.be.equal(''); | ||
expect(resultArr).to.deep.equal([]); | ||
}); | ||
it('origin', () => { | ||
const result = pinyin('赵钱孙李吧'); | ||
expect(result).to.be.equal('zhào qián sūn lǐ ba'); | ||
}); | ||
it('multiple', () => { | ||
const result = pinyin('好', { multiple: true }); | ||
expect(result).to.be.equal('hǎo hào'); | ||
}); | ||
it('pattern', () => { | ||
const resultNumStr = pinyin('赵钱孙李吧', { pattern: 'num' }); | ||
expect(resultNumStr).to.be.equal('4 2 1 3 0'); | ||
const resultNumArr = pinyin('赵钱孙李吧', { | ||
pattern: 'num', | ||
type: 'array', | ||
}); | ||
expect(resultNumArr).to.deep.equal(['4', '2', '1', '3', '0']); | ||
const resultInitial = pinyin('赵钱孙李吧', { | ||
pattern: 'initial', | ||
}); | ||
expect(resultInitial).to.be.equal('zh q s l b'); | ||
const resultFinal = pinyin('赵钱孙李吧', { | ||
pattern: 'final', | ||
}); | ||
expect(resultFinal).to.be.equal('ào ián ūn ǐ a'); | ||
const resultFirst = pinyin('赵钱孙李额', { | ||
pattern: 'first', | ||
}); | ||
expect(resultFirst).to.be.equal('z q s l é'); | ||
const resultFirst2 = pinyin('赵钱孙李额', { | ||
pattern: 'first', | ||
toneType: 'none', | ||
}); | ||
expect(resultFirst2).to.be.equal('z q s l e'); | ||
}); | ||
it('toneType', () => { | ||
const resultNone = pinyin('赵钱孙李吧', { toneType: 'none' }); | ||
expect(resultNone).to.be.equal('zhao qian sun li ba'); | ||
const resultNum = pinyin('赵钱孙李吧', { toneType: 'num' }); | ||
expect(resultNum).to.be.equal('zhao4 qian2 sun1 li3 ba0'); | ||
}); | ||
it('array', () => { | ||
const result = pinyin('赵钱孙李吧', { type: 'array' }); | ||
expect(result).to.deep.equal(['zhào', 'qián', 'sūn', 'lǐ', 'ba']); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1092968
30393
18
27
184