diff --git a/.npmignore b/.npmignore index 67b1799..48f1423 100644 --- a/.npmignore +++ b/.npmignore @@ -1,7 +1,9 @@ rollup.config.js docs coverage -dist/pinyin-pro.js .github .husky -handle-data \ No newline at end of file +handle-data +lib +data +test \ No newline at end of file diff --git a/data/special.ts b/data/special.ts index 63bcc8d..8ae9f05 100644 --- a/data/special.ts +++ b/data/special.ts @@ -27,6 +27,11 @@ export const InitialList = [ export const SpecialInitialList = ['j', 'q', 'x']; export const SpecialFinalList = [ + 'uān', + 'uán', + 'uǎn', + 'uàn', + 'uan', 'ūn', 'ún', 'ǔn', @@ -40,6 +45,11 @@ export const SpecialFinalList = [ ]; export const SpecialFinalMap = { + uān: 'üān', + uán: 'üán', + uǎn: 'üǎn', + uàn: 'üàn', + uan: 'üan', ūn: 'ǖn', ún: 'ǘn', ǔn: 'ǚn', @@ -51,3 +61,5 @@ export const SpecialFinalMap = { ù: 'ǜ', u: 'ü', }; + +export const doubleFinal = []; diff --git a/lib/pinyin.ts b/lib/pinyin.ts index 98dab18..71bf3c5 100644 --- a/lib/pinyin.ts +++ b/lib/pinyin.ts @@ -25,8 +25,19 @@ interface BasicOptions { * @value final:返回韵母 * @value num:返回音调对应的数字 * @value first:返回首字母 + * @value finalHead:返回韵头(介音) + * @value finalBody:返回韵腹 + * @value finalTail:返回韵尾 */ - pattern?: 'pinyin' | 'initial' | 'final' | 'num' | 'first'; + pattern?: + | 'pinyin' + | 'initial' + | 'final' + | 'num' + | 'first' + | 'finalHead' + | 'finalBody' + | 'finalTail'; /** * @description 是否返回单个汉字的所有多音,仅针对输入的 word 为单个汉字生效 * @value false:返回最常用的一个拼音 (默认值) diff --git a/package.json b/package.json index 6254ae2..c8c2060 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,10 @@ "type": "git", "url": "git+https://github.com/zh-lx/pinyin-pro.git" }, + "files": [ + "dist", + "types" + ], "keywords": [ "拼音", "pinyin", diff --git a/test/dist.test.js b/test/dist.test.js index 63b20c8..3fdad5b 100644 --- a/test/dist.test.js +++ b/test/dist.test.js @@ -293,6 +293,7 @@ describe('surname', () => { describe('pinyinFn', () => { it('not string type', () => { + // @ts-ignore const result = pinyin(2222); expect(result).to.be.equal(2222); }); @@ -576,5 +577,10 @@ describe('customConfig', () => { pattern: 'final', }); expect(result1).to.deep.equal('ǘ'); + + const result2 = pinyin('选', { + pattern: 'final', + }); + expect(result1).to.deep.equal('üǎn'); }); });