Tabnine Logo For Javascript
pinyin
Code IndexAdd Tabnine to your IDE (free)

How to use pinyin

Best JavaScript code snippets using pinyin(Showing top 2 results out of 315)

origin: arthurkiller/electronic-QQ

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);
 }
origin: kslr/telegram-aqi-bot

bot.onText(/\/aqi (.+)/, (msg, match) => {
 let city = match[1];
 const re = /[^\u4e00-\u9fa5]|[\uFE30-\uFFA0]/;
 if (!re.test(city)) {
  city = pinyin(city, {
   segment: true,
   style: pinyin.STYLE_NORMAL,
  });
  city = city.join('');
 }

 console.log(`query ${city} city`);
 request(`http://aqicn.org/aqicn/json/android/${city}/json`, (error, response, body) => {
  if (!error && response.statusCode === 200) {
   const res = JSON.parse(body);
   if (res.wgt) {
    console.log(res.wgt);
    bot.sendPhoto(msg.chat.id, res.wgt);
   }
  } else {
   console.error(error);
  }
 });
});
pinyin(npm)

JSDoc

汉语拼音转换工具。

Most used pinyin functions

  • pinyin
  • STYLE_FIRST_LETTER
  • STYLE_NORMAL

Popular in JavaScript

  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • moment
    Parse, validate, manipulate, and display dates
  • lodash
    Lodash modular utilities.
  • express
    Fast, unopinionated, minimalist web framework
  • winston
    A logger for just about everything.
  • minimatch
    a glob matcher in javascript
  • aws-sdk
    AWS SDK for JavaScript
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • async
    Higher-order functions and common patterns for asynchronous code
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now