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

random-chinese-characters-generator

v0.1.2

Published

A simple package generates random Chinese characters

Downloads

4

Readme

Random Chinese Characters Generator

A simple package to generate random Chinese characters based on various criteria.

Installation

npm install random-chinese-characters-generator

yarn add random-chinese-characters-generator

pnpm add random-chinese-characters-generator

Usage

import getRandomCharacters from "random-chinese-characters-generator";

// Get a random character
const randomCharacter = getRandomCharacters();

// Get 10 random characters
const tenRandomCharacters = getRandomCharacters({ count: 10 });

// Get characters within a level range
const charactersInLevelRange = getRandomCharacters({ levelRange: [1, 3] });

// Get characters within a stroke count range
const charactersInStrokeCountRange = getRandomCharacters({
  strokeCountRange: [5, 10],
});

// Get characters within a level range and stroke count range
const charactersWithinRanges = getRandomCharacters({
  levelRange: [1, 3],
  strokeCountRange: [5, 10],
});

If count is missing, it will return one random character.

If levelRange is missing, it may use characters from all levels.

If strokeCountRange is missing, it will use characters with any stroke count.

To specify a single level, use the same number for both ends of the range: levelRange: [3, 3].

To specify a single stroke count, use the same number for both ends of the range: strokeCountRange: [8, 8].

API

getRandomCharacters(options?: RandomCharactersOptions): string[]

Returns an array of random Chinese characters based on the provided options.

RandomCharactersOptions

  • count?: number: The number of random characters to generate.
  • levelRange?: [number, number]: The range of levels to include in the generated characters. The current available level range is from 1 to 3.
  • strokeCountRange?: [number, number]: The range of stroke counts to include in the generated characters. The current available stroke count range is from 1 to 36.

Level Descriptions

  • Level 1 (一级字表): Consists of commonly used characters, with a collection of 3500 characters, primarily meeting the basic needs of education and cultural dissemination.
  • Level 2 (二级字表): Contains 3000 characters, slightly less common than Level 1 characters. The combined Level 1 and Level 2 lists comprise 6500 characters, catering to general usage in publishing, dictionary compilation, and information processing.
  • Level 3 (三级字表): Includes 1605 characters, featuring surnames, place names, scientific and technical terms, and less commonly used characters in primary and secondary school Chinese textbooks. These characters address the specialized needs of the information age and areas closely related to public life.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

Data Source

This package uses character data from the source 通用规范汉字表 (Wikisource).

License

This project is licensed under the MIT License.