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

chinese-idiom-chengyu

v1.1.0

Published

A package that contains utility functions for Chinese idioms or chengyu.

Downloads

10

Readme

Chinese Idioms Chengyu

Simple npm package that contains utilities for Chinese idioms or Chengyu. Functions available right now are for Chinese idioms solitaire or Chengyu Jielong. More functions will be added in the future versions!

Installation

npm install chinese-idioms-chengyu

Usage

Solitaire Functions

| Name | Params | Description | Error handling | | ---- | ------ | ----------- | -------------- | | nextIdiomsWithMatchingCharacter | idiomWord - String of Chinese characters of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin | Returns a list of idiom word-pinyin-pairs, words, or pinyin that have idioms where the first character is the same as the last character of the parameter idiomWord. | Throw an error when idiomWord does not exist. | nextIdiomsWithMatchingTonePinyin | idiomWord - String of Chinese characters of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin | Returns a list of idiom word-pinyin-pairs, words, or pinyin that have idioms where the pinyin of the first character is the same as the pinyin of the last character of the parameter idiomWord. | Throw an error when idiomWord does not exist. | nextIdiomsWithMatchingNoTonePinyin | idiomWord - String of Chinese characters of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin | Returns a list of idiom word-pinyin-pairs, words, or pinyin that have idioms where the pinyin of the first character is the same as the pinyin of the last character of the parameter idiomWord disregarding the tone. | Throw an error when idiomWord does not exist.

Search Functions

| Name | Params | Description | Error handling | | ---- | ------ | ----------- | -------------- | | startWithCharacter | character - String of first character of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin | Return a list of idiom word-pinyin-pairs, word, or pinyin that starts with the parameter character. | Throw an error when options is not valid. | startWithTonePinyin | pinyin - String of pinyin of first character of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin | Return a list of idiom word-pinyin-pairs, word, or pinyin that starts with the parameter pinyin. | Throw an error when options is not valid. | startWithNoTonePinyin | noTonePinyin - String of no tone pinyin of first character of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin | Return a list of idiom word-pinyin-pairs, word, or pinyin that starts with the parameter noTonEpinyin. | Throw an error when options is not valid. | getDefinition | idiomWord - String of idiom word | Return the definition of the parameter idiomWord | Throw an error when idiomWord does not exist. |

Options

| Name | Type | Default value | Description | | ---- | ---- | ------------- | ----------- | | word | Boolean | true | Whether returned idioms include the string of words | | pinyin | Boolean | true | Whether returned idioms include the string of pinyin |

Example

const chengyu = require('chinese-idioms-chengyu')

const idiom = '全力以赴' // [ '全力以赴' : 'quán lì yǐ fù' ]
const lessIdioms = chengyu.nextIdiomsWithMatchingCharacter(idiom)
console.log(lessIdioms.length)
console.log(lessIdioms[0])

const wordOnly = chengyu.nextIdiomsWithMatchingCharacter(idiom, {word: true, pinyin: false})
console.log(wordOnly[0])

const moreIdioms = chengyu.nextIdiomsWithMatchingNoTonePinyin(idiom)
console.log(moreIdioms.length)
console.log(moreIdioms[0])

const pinyinOnly = chengyu.nextIdiomsWithMatchingNoTonePinyin(idiom, {word: false, pinyin: true})
console.log(pinyinOnly[0])

Output

2
[ '赴汤蹈火', 'fù tāng dǎo huǒ' ]
赴汤蹈火
347
[ '夫倡妇随', 'fū chàng fù suí' ]
fū chàng fù suí

License

MIT

Acknowledge

chinese-xinhua