How to use the pinyin.STYLE_FIRST_LETTER function in pinyin

To help you get started, we’ve selected a few pinyin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nigulasikk / freeStylePlugin / index.js View on Github external
function getYunMu(word) {
    /**
     * 声母数组
     */
    var shenMu = pinyin(word, {
        style: pinyin.STYLE_FIRST_LETTER, // 设置拼音风格
        segment: true,
        heteronym: true
    })
    /**
     * 单词全拼数组
     */
    var wholePinyinArray = pinyin(word, {
        style: pinyin.STYLE_NORMAL, // 设置拼音风格
        segment: true,
        heteronym: true
    })
    // console.log(shenMu);  
    // console.log(wholePinyinArray);
    // 全拼 减去 声母 得到韵语 用逗号分隔
    var yunMu = wholePinyinArray.map((fullPinyin, index) => {
        return fullPinyin[0].replace(shenMu[index][0], '')
github geeeeeeeeek / electronic-wechat / src / inject / mention_menu.js View on Github external
static isValidNameHint(nameHint, userName) {
    const pinyinRaw = pinyin(userName, {
      style: pinyin.STYLE_FIRST_LETTER,
    });

    let pinyinName = '';
    for (const py of pinyinRaw) {
      if (py[0] && py[0] !== ' ') {
        pinyinName += py[0];
      }
    }

    const nameRe = new RegExp(nameHint[1], 'ig');
    return nameRe.test(userName) || nameRe.test(pinyinName);
  }
github arthurkiller / electronic-QQ / src / inject / mention_menu.js View on Github external
static isValidNameHint(nameHint, userName) {
    const pinyinRaw = pinyin(userName, {
      style: pinyin.STYLE_FIRST_LETTER,
    });

    let pinyinName = '';
    for (const py of pinyinRaw) {
      if (py[0] && py[0] !== ' ') {
        pinyinName += py[0];
      }
    }

    const nameRe = new RegExp(nameHint[1], 'ig');
    return nameRe.test(userName) || nameRe.test(pinyinName);
  }
github caijinyc / vue-music-webapp / src / components / singer / singer.vue View on Github external
s.map((item) => {
          let py = pinyin(item.name[0], {
            style: pinyin.STYLE_FIRST_LETTER
          })
          item.initial = py[0][0].toUpperCase()
        })
        this.singers = this._normalizeSinger(s)
github easysoft / zui / Gruntfile.js View on Github external
var toPinYin = function(text) {
            var py1 = mergeString(pinyin(text, {style: pinyin.STYLE_NORMAL}));
            if(py1 === '' || py1 === text) return '';
            return py1 + ' ' + mergeString(pinyin(text, {style: pinyin.STYLE_FIRST_LETTER}));
        };
github hsuehic / react-wechat-backend / controllers / user.js View on Github external
} else if (!userName) {
    message = '请输入用户名';
  } else if (!password) {
    message = '请输入密码';
  } else if (!email) {
    message = '请输入Email';
  } else if (!phone) {
    message = '请输入手机号码';
  }
  if (message) {
    ctx.body = {
      code: 100003,
      message
    };
  } else {
    const group = pinyin(nick, { style: pinyin.STYLE_FIRST_LETTER })[0][0].toUpperCase().substr(0, 1);
    const db = ctx.mongo.db(dbName);
    const defaultContacts = ['18958067917', '18958067916'];
    const user = { nick, thumb, userName, password: encryptUsingMd5(password), region, email, phone, group, contacts: defaultContacts };
    const collection = db.collection('user');
    const result = await collection.insertOne(user);
    if (result.insertedCount > 0) {
      ctx.body = {
        code: 0,
        message: ''
      };

      collection.updateMany({
        phone: {
          $in: defaultContacts
        }
      }, {
github Ice-Hazymoon / MikuTools / pinyin.js View on Github external
toolName.forEach(name => {
    toolPinyin[name] = {
        first: group(
            pinyin(name.replace(/\s/g, '').toLowerCase(), {
                style: pinyin.STYLE_FIRST_LETTER,
                heteronym: true
            })
        ),
        pinyin: group(
            pinyin(name.replace(/\s/g, '').toLowerCase(), {
                style: pinyin.STYLE_NORMAL,
                heteronym: true
            })
        )
    };
});

pinyin

汉语拼音转换工具。

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis