Skip to content

Commit

Permalink
feat: typescript version usable
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Mar 2, 2022
1 parent 865f101 commit f0bca72
Show file tree
Hide file tree
Showing 19 changed files with 570 additions and 245 deletions.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
[ '@babel/preset-env', {targets: {node: 'current'}} ],
[ '@babel/preset-typescript', {allExtensions: true}],
],
};
2 changes: 1 addition & 1 deletion data/dict-zi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const dict: string[] = [];
const dict: Record<number, string> = {};

dict[0x3007] = "líng,xīng"; /* 〇: https://zh.m.wiktionary.org/wiki/%E3%80%87 */
dict[0x3400] = "qiū"; /* 㐀 */
Expand Down
6 changes: 5 additions & 1 deletion data/phrases-dict.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 有些通假字,单字本身没有这个读音,但是通假字可以有。
// 如:阿家阿翁 [["ā"], ["gū"], ["ā"], ["wēng"]],家通姑。
export default {

const phrases_dict: Record<string,string[][]> = {
"阿Q": [["ā"], ["Q"]],
"阿爸": [["ā"], ["bà"]],
"阿鼻": [["ā"], ["bí"]],
Expand Down Expand Up @@ -40277,6 +40278,7 @@ export default {
"中华民族": [["zhōng"], ["huá"], ["mín"], ["zú"]],
"中华民国": [["zhōng"], ["huá"], ["mín"], ["guó"]],
"中华人民共和国": [["zhōng"], ["huá"], ["rén"], ["mín"], ["gòng"], ["hé"], ["guó"]],
"中奖": [["zhòng"], ["jiǎng"]],
"中馈乏人": [["zhōng"], ["kuì"], ["fá"], ["rén"]],
"中立不倚": [["zhōng"], ["lì"], ["bù"], ["yǐ"]],
"中馈犹虚": [["zhōng"], ["kuì"], ["yóu"], ["xū"]],
Expand Down Expand Up @@ -41127,3 +41129,5 @@ export default {
"做一日和尚撞一天钟": [["zuò"], ["yī"], ["rì"], ["hé"], ["shàng"], ["zhuàng"], ["yī"], ["tiān"], ["zhōng"]],
"做一天和尚撞一天钟": [["zuò"], ["yī"], ["tiān"], ["hé"], ["shàng"], ["zhuàng"], ["yī"], ["tiān"], ["zhōng"]],
};

export default phrases_dict;
7 changes: 6 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// export type { IPinyinOptions, IPinyinSegment, PINYIN_STYLE } from "./src/declare";

export default "./src/";
// export default from "./src/pinyin";

export default function pinyin(hans: string) {
return hans;
}
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "pinyin",
"version": "3.0.0-alpha-0",
"description": "汉语拼音转换工具。",
"main": "index.ts",
"module": "build/es/index.js",
"main": "build/dist/src/pinyin.js",
"module": "build/es/src/pinyin.js",
"files": [
"package.json",
"build/",
Expand Down Expand Up @@ -43,35 +43,38 @@
"doc:build": "dumi build",
"doc:deploy": "npm run doc:build && cp CNAME docs-dist/dist && gh-pages -d docs-dist/dist",
"lint": "eslint ./lib/ ./bin/ ./tests/",
"test": "nyc --reporter=lcov mocha --timeout=5000 --inline-diffs ./tests/"
"test": "nyc --reporter=lcov mocha --timeout=5000 --inline-diffs ./tests/",
"test-local": "jest && npx ts-node test/index.benchmark.ts",
"debug": "npx ts-node tools/debug.ts"
},
"dependencies": {
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"commander": "~1.1.1",
"object-assign": "^4.0.1"
"npx": "^10.2.2",
"object-assign": "^4.0.1",
"segmentit": "^2.0.3"
},
"optionalDependencies": {
"nodejieba": "^2.5.2"
},
"devDependencies": {
"aurl": "^1.2.0",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"jest": "^27.2.3",
"@types/jest": "^27.0.2",
"aurl": "^1.2.0",
"aws-sdk": "^2.1011.0",
"benchmark": "~1.0.0",
"dumi": "^1.1.30",
"eslint": "~0.24.0",
"gh-pages": "^3.2.3",
"istanbul": "~0.3.17",
"jest": "^27.2.3",
"mocha": "^9.0.0",
"mock-aws-s3": "^4.0.2",
"nock": "^13.1.4",
"nyc": "^15.1.0",
"react-json-view": "^1.21.3",
"request": "~2.68.0",
"ts-node": "^10.5.0",
"typescript": "^4.4.4"
},
"registry": "https://registry.npmmirror.com",
Expand Down
Loading

0 comments on commit f0bca72

Please sign in to comment.