Code Monkey home page Code Monkey logo

pinyin_js's Introduction

pinyin_js

中文转拼音 ##安装

npm install

##汉字转化成带音节的拼音

var pinyin=require("pinyin_js");
console.log(pinyin.pinyin("你好"," "));
//输出结果是nǐ hǎo 

##汉字转化成不带音节的拼音

var pinyin=require("pinyin_js");
console.log(pinyin.pinyinWithOutYin("你好"," "));
//输出结果是ni hao 

##判断是否是汉字

var pinyin=require("pinyin_js");
console.log(pinyin.isChineseWord("你好"));//true
console.log(pinyin.isChineseWord("!你好",false));//true
console.log(pinyin.isChineseWord("!你好",true));//第二个参数:true是严格模式,默认为严格模式
//false

##首字母排序

var pinyin=require("pinyin_js");
var users = [
    { 'user': '张三丰',   'age': 40 },
    { 'user': '123',   'age': 48 },
    { 'user': '张三',   'age': 48 },
    { 'user': '李四', 'age': 36 },  
    { 'user': '张三炮', 'age': 34 }
];
var sortResult = pinyin.sort(users, "user");
console.log(sortResult)
/*[ { user: '123', age: 48 },
    { user: '李四', age: 36 },
    { user: '张三', age: 48 },
    { user: '张三丰', age: 40 },
    { user: '张三炮', age: 34 } ]*/
    

pinyin_js's People

Contributors

liu11hao11 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.