JSPM

  • Created
  • Published
  • Downloads 1189
  • Score
    100M100P100Q107372F
  • License MIT

Split up any kind of Pinyin into an array of syllables.

Package Exports

  • pinyin-split

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pinyin-split) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Pinyin Split

npm version Travis Build Status Greenkeeper badge dependency status dev dependency status MIT-licensed chat on gitter

Install

npm install pinyin-split

Syntax

split(str: string, everything?: boolean, wrapInList?: boolean)

Usage

const split = require('pinyin-split')

console.log(split('本: "wǒshìzhōngguórén".'))
// ['wǒ', 'shì', 'zhōng', 'guó', 'rén']

console.log(split('本: "wǒshìzhōngguórén".', true))
// ['本: "', 'wǒ', 'shì', 'zhōng', 'guó', 'rén', '"."]

console.log(split('本: "wǒshìzhōngguórén".', false, true))
// [['wǒ'], ['shì'], ['zhōng'], ['guó'], ['rén']]

console.log(split('本: "wǒshìzhōngguórén".', true, true))
// ['本: "', ['wǒ'], ['shì'], ['zhōng'], ['guó'], ['rén'], '"."]

// return everything and wrap pinyin into lists
console.log(split('本:ni jiao shenme mingzi?', true, true))
// ['本:'['ni'], ' ', ['jiao'], ' ', ['shen'], ['me'], ' ', ['ming'], ['zi'], '?']

// return everything and don't wrap pinyin into lists
console.log(split('Nǐ huì shuō Yīngwén ma?', true))
// ['Nǐ', ' ', 'huì', ' ', 'shuō', ' ', 'Yīng', 'wén', ' ', 'ma', '?']

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.