How to use the pinyin.STYLE_NORMAL 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 gaoxiaoliangz / readr / src / server / api / books / helpers.ts View on Github external
return dataProvider.Author.findOne({ name: authorName }).exec().then(async doc => {
    if (doc) {
      return doc._id
    } else {
      const slug = pinyin(
        authorName, {
          style: pinyin.STYLE_NORMAL
        })
        .map(seg => seg[0])
        // isAlphanumeric checks args lenght to determine locale
        // if more than one there will be a problem, and an error
        // will be thrown
        .filter(str => validator.isAlphanumeric(str))
        .join('')

      const result = await dataProvider.Author.utils.save({
        name: authorName,
        slug,
        description
      })
      return result._id
    }
  })
github apache / incubator-echarts / map / tool / genGeo.js View on Github external
var geoJson = {
        type: 'FeatureCollection',
        features: provinceDetail.districts[0].districts.map(function (city) {
            var cityCode = city.citycode;
            var cityDetail = readCity(provinceName, city.name);
            return makeFeature(cityDetail.districts.filter(function (distrct) {
                return distrct.citycode === cityCode;
            })[0], 0, 0.0005);
        })
    };

    var jsonStr = JSON.stringify(compress(geoJson));
    var pinyinName = pinyin(provinceFullShortMap[provinceName], {
        // heteronym: true,
        style: pinyin.STYLE_NORMAL
    }).join('');
    fs.writeFileSync(
        '../json/province/' + pinyinName + '.json',
        jsonStr,
        'utf-8'
    );

    fs.writeFileSync(
        '../js/province/' + pinyinName + '.js',
        jsTplStr.replace('{{name}}', provinceFullShortMap[provinceName])
            .replace('{{data}}', jsonStr),
        'utf-8'
    );
}
github jabez128 / jabez128.github.io / compile.js View on Github external
mds.forEach(function(item){
	var title = item.substr(0,item.length-3);
	var py = pinyin(title,{
		style: pinyin.STYLE_NORMAL,
		heteronym: false
	}).reduce(function(prev,next){
		return prev.concat(next)
	},[]).join("_");
	var html = markdown.toHTML(fs.readFileSync("newfile/"+item).toString());
	fs.writeFileSync("archives/"+py+".html",compiled({
		raw: encodeURIComponent(py),
		title: title,
		html: html
	}));
})
console.log("done!");
github hex-ci / resource-uploader / lib / alioss.js View on Github external
return name.split('-').map(item => pinyin(item, {
    style: pinyin.STYLE_NORMAL,
    segment: true
  }).join('-')).join('-') + ext;
};
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
            })
        )
    };
});
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 solobat / Steward / extension / js / common / util.js View on Github external
function getPinyin(name) {
    return pinyin(name, {
        style: pinyin.STYLE_NORMAL

    }).join('');
}
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){

pinyin

汉语拼音转换工具。

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis