Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ Param for String.localeCompare should be a string. #161

Merged
merged 1 commit into from Sep 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pinyin.js
Expand Up @@ -181,7 +181,7 @@ class Pinyin {
compare (hanA, hanB) {
const pinyinA = this.convert(hanA, DEFAULT_OPTIONS);
const pinyinB = this.convert(hanB, DEFAULT_OPTIONS);
return String(pinyinA).localeCompare(pinyinB);
return String(pinyinA).localeCompare(String(pinyinB));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localeCompare 的参数其实默认会转换成 String 类型,这个加不加其实是一样的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为把代码引入到 TypeScript 的环境中出现报错,所以做了一个修改 ☺

}

static get STYLE_NORMAL () {
Expand Down