Skip to content

Commit

Permalink
fix: pinyinify
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Aug 29, 2023
1 parent 2527ce9 commit 6131818
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 12 additions & 10 deletions src/scripts/pinyinify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import { readFileSync, readdirSync, writeFileSync } from "fs"
import { pinyin } from "pinyin"

function pinyinify(name: string) {
// we are using pinyin2, the return value of pinyin() is an array of arrays
const fullPinyin = pinyin(name, {
heteronym: true,
style: pinyin.STYLE_NORMAL,
})
const partialPinyin = pinyin(name, {
heteronym: true,
style: pinyin.STYLE_FIRST_LETTER,
})
return [fullPinyin.join(""), partialPinyin.join("")]
return [
pinyin(name, {
compact: true,
heteronym: true,
style: pinyin.STYLE_NORMAL,
}),
pinyin(name, {
compact: true,
heteronym: true,
style: pinyin.STYLE_FIRST_LETTER,
}),
].flatMap(py => py.map(el => el.join("")))
}

function addAliasToSchema(json: any) {
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"moduleResolution": "node",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
Expand All @@ -18,7 +18,9 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down

0 comments on commit 6131818

Please sign in to comment.