Skip to content

Commit

Permalink
add convertToFirstLetter method
Browse files Browse the repository at this point in the history
跟随 `.STYLE_FIRST_LETTER` 功能.
  • Loading branch information
iugo committed Jul 26, 2017
1 parent 7574e25 commit 00a27eb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ module.exports = {
parse,
patchDict,
genToken, // inner usage
convertToFirstLetter(str) {
return parse(str).reduce((acc, val) => {
const code = val.target.charCodeAt(0);
if (code < 48 || code > 122 || (code > 90 && code < 97) || (code > 57 && code < 65)) {
return acc;
}
return acc + val.target[0];
}, '')
},
convertToPinyin (str, separator, lowerCase) {
return parse(str).map(v => {
if (lowerCase && v.type === PINYIN) {
Expand Down

0 comments on commit 00a27eb

Please sign in to comment.