How to use the pinyin 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 zerosoul / chinese-colors / src / hooks.js View on Github external
set.colors = set.colors.map(c => {
    let heteronymIdx = c.name.indexOf('藏') > -1 ? 1 : 0;
    return {
      ...c,
      RGB: convert.hex.rgb(c.hex),
      CMYK: convert.hex.cmyk(c.hex),
      pinyin: pinyin(c.name, {
        heteronym: true, // 启用多音字模式
        segment: true // 启用分词,以解决多音字问题。
      })
        .map(item => {
          return item.length > 1 ? item[heteronymIdx] : item;
        })
        .join(' ')
    };
  });
  return set;
github cn-src / swagger-document-ui / src / utils / swagger.js View on Github external
function toPinyin(text) {
    const pyArray = pinyin(text, { style: pinyin.STYLE_NORMAL });
    return $.join($.flatMap(pyArray), ' ');
}
github solobat / Steward / extension / js / common / util.js View on Github external
function getPinyin(name) {
    return pinyin(name, {
        style: pinyin.STYLE_NORMAL

    }).join('');
}
github cqm1994617 / react-native-alphabetaList / index.android.js View on Github external
return array.sort(function(a, b) {
                let x = pinyin(a[key].toLowerCase());
                let y = pinyin(b[key].toLowerCase());
                return ((x < y) ? -1 : ((x > y) ? 1 : 0));
            });
        }
github bailicangdu / node-elm / controller / v1 / cities.js View on Github external
async getCityName(req){
		try{
			const cityInfo = await this.guessPosition(req);
			/*
			汉字转换成拼音
			 */
	    const pinyinArr = pinyin(cityInfo.city, {
		  	style: pinyin.STYLE_NORMAL,
			});
			let cityName = '';
			pinyinArr.forEach(item => {
				cityName += item[0];
			})
			return cityName;
		}catch(err){
			return '北京';
		}
	}
	async getExactAddress(req, res, next){
github cqm1994617 / react-native-alphabetaList / index.ios.js View on Github external
return array.sort(function(a, b) {
                let x = pinyin(a[key].toLowerCase());
                let y = pinyin(b[key].toLowerCase());
                return ((x < y) ? -1 : ((x > y) ? 1 : 0));
            });
        }
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 5 months ago

Package Health Score

75 / 100
Full package analysis