# is-chinese

> assert whether a string is chinese

Latest version **2.0.0** (published 2022-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-chinese
pnpm add is-chinese
yarn add is-chinese
bun add is-chinese
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-11-18 |
| First published | 2015-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 120 |
| Author | alsotang |
| Maintainers | alsotang |
| Keywords | chinese, assert |

## Links

- npm: https://www.npmjs.com/package/is-chinese
- Repository: https://github.com/alsotang/is-chinese
- Homepage: https://github.com/alsotang/is-chinese#readme
- Issues: https://github.com/alsotang/is-chinese/issues
- npm.io page: https://npm.io/package/is-chinese

## Recent versions

- 2.0.0 (latest) — 2022-11-18
- 1.4.8 — 2022-10-21
- 1.4.7 — 2022-09-30
- 1.4.6 — 2021-08-02
- 1.4.5 — 2021-07-03
- 1.4.4 — 2021-07-03
- 1.4.3 — 2021-07-03
- 1.4.2 — 2021-05-01
- 1.4.1 — 2021-04-30
- 1.4.0 — 2021-04-30
- 1.3.0 — 2021-04-30
- 1.2.9 — 2019-03-08
- 1.2.8 — 2019-03-08
- 1.2.7 — 2019-03-07
- 1.2.6 — 2019-01-29
- … 11 more at https://npm.io/package/is-chinese/versions

## README

[![Build Status](https://travis-ci.org/alsotang/is-chinese.svg?branch=master)](https://travis-ci.org/alsotang/is-chinese)

JS 中文字符串判断（根据 unicode 编码区间判断）

Determine whether a string is all Chinese(based on unicode range)

## install

`$ npm install is-chinese`

## description

Chinese range is based on: https://en.wikipedia.org/wiki/CJK_Unified_Ideographs

## usage

```typescript
const isChinese: (str: string, { includePunctuation }?: {
    includePunctuation?: boolean | undefined;
}) => boolean
```

## example

```js
import isChinese from 'is-chinese'
isChinese('中国').should.true();
isChinese('中国ss').should.false();
isChinese('ss').should.false();
isChinese("\uD842\uDFB7").should.true();
```

## benchmark

```
isChinese("扁担宽，板凳长，扁担想绑在板凳上。") x 15,813,552 ops/sec ±1.28% (98 runs sampled)
isChinese("ss扁担宽，板凳长，扁担想绑在板凳上。") x 74,815,821 ops/sec ±0.72% (96 runs sampled)
isChinese("扁担宽，板凳长，扁担想绑在板凳上。ss") x 53,410,698 ops/sec ±0.47% (92 runs sampled)
isChinese(chars1000) true x 453,971 ops/sec ±0.57% (100 runs sampled)
isChinese(chars1000WithAscii) false x 2,817,982 ops/sec ±0.36% (90 runs sampled)
Fastest is isChinese("ss扁担宽，板凳长，扁担想绑在板凳上。")
```

## license

MIT

---
_Source: https://npm.io/package/is-chinese · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
