npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pinyin-separate

v1.2.0

Published

Separates a string containing pinyin notation (with diacritics) into an array of pinyin syllables, even if there are no spaces in between.

Downloads

14

Readme

pinyin-separate

dependencies Status devDependencies Status License: MIT npm total downloads

Separates a string containing pinyin notation (with diacritics) into an array of pinyin syllables, even if there are no spaces in between.

This is mainly separate-pinyin-in-syllables.js turned into an npm module, but I made some fixes and extended it to allow "vv̄v́v̆v̀" in addition to "üǖǘǚǜ" as well, so I use my own fork as the base for this module.

Installation

npm install pinyin-separate

or use the files in /dist or from the releases for direct in-browser usage.

Usage and examples

const pinyinSeparate = require('pinyin-separate').default
// or
import pinyinSeparate from 'pinyin-separate'
// or (for usage in a browser environment)
<script src="dist/pinyin-separate.min.js"></script>

// and then it's as simple as
pinyinSeparate("nĭhăoma"); // result: ['nĭ', 'hăo', 'ma']

// if the syllables in your input string are separated by
// non-breaking spaces (charcode 160), you can set the option "byNbsp"
// to true; that will simply split the string by that character
// without any further splitting/processing. This is a remnant from
// the original lib (second argument of the main function) and probably
// not very useful on its own, but I decided to keep it in for compatibility
pinyinSeparate("jiān rěn bù bá", { // non-breaking spaces!
    byNbsp: true
}) // result: ['jiān', 'rěn', 'bù', 'bá']

Options

An optional options object can be passed as a second argument.

| Option Name | Default | Description | | ------------- | ------------- | ------------- | | byNbsp | false | Split input string by charcode 160 (non-breaking space) without any further processing (see explanation in the code example above) |

Development Commands

  • npm run clean - Remove lib/ directory
  • npm test - Run tests with linting
  • npm test:only - Run tests without linting
  • npm test:watch - Re-run tests on file changes
  • npm test:prod - Run tests with minified code
  • npm run test:examples - Test examples with node
  • npm run lint - Run ESlint with airbnb-config
  • npm run build - Babel will transpile ES6 => ES5 and minify the code, Browserify will create a bundle in dist/ for in-browser usage.
  • npm run prepublish - Hook for npm. Do all the checks before publishing the module.

License

MIT © Connum

based on flexdinesh/npm-module-boilerplate, MIT © Dinesh Pandiyan and separate-pinyin-in-syllables.js, MIT © GitHub user pierophp