is-fullwidth-code-point
Advanced tools
Comparing version 2.0.0 to 3.0.0
46
index.js
@@ -0,40 +1,41 @@ | ||
/* eslint-disable yoda */ | ||
'use strict'; | ||
/* eslint-disable yoda */ | ||
module.exports = x => { | ||
if (Number.isNaN(x)) { | ||
const isFullwidthCodePoint = codePoint => { | ||
if (Number.isNaN(codePoint)) { | ||
return false; | ||
} | ||
// code points are derived from: | ||
// Code points are derived from: | ||
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt | ||
if ( | ||
x >= 0x1100 && ( | ||
x <= 0x115f || // Hangul Jamo | ||
x === 0x2329 || // LEFT-POINTING ANGLE BRACKET | ||
x === 0x232a || // RIGHT-POINTING ANGLE BRACKET | ||
codePoint >= 0x1100 && ( | ||
codePoint <= 0x115F || // Hangul Jamo | ||
codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET | ||
codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET | ||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months | ||
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || | ||
(0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || | ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A | ||
(0x3250 <= x && x <= 0x4dbf) || | ||
(0x3250 <= codePoint && codePoint <= 0x4DBF) || | ||
// CJK Unified Ideographs .. Yi Radicals | ||
(0x4e00 <= x && x <= 0xa4c6) || | ||
(0x4E00 <= codePoint && codePoint <= 0xA4C6) || | ||
// Hangul Jamo Extended-A | ||
(0xa960 <= x && x <= 0xa97c) || | ||
(0xA960 <= codePoint && codePoint <= 0xA97C) || | ||
// Hangul Syllables | ||
(0xac00 <= x && x <= 0xd7a3) || | ||
(0xAC00 <= codePoint && codePoint <= 0xD7A3) || | ||
// CJK Compatibility Ideographs | ||
(0xf900 <= x && x <= 0xfaff) || | ||
(0xF900 <= codePoint && codePoint <= 0xFAFF) || | ||
// Vertical Forms | ||
(0xfe10 <= x && x <= 0xfe19) || | ||
(0xFE10 <= codePoint && codePoint <= 0xFE19) || | ||
// CJK Compatibility Forms .. Small Form Variants | ||
(0xfe30 <= x && x <= 0xfe6b) || | ||
(0xFE30 <= codePoint && codePoint <= 0xFE6B) || | ||
// Halfwidth and Fullwidth Forms | ||
(0xff01 <= x && x <= 0xff60) || | ||
(0xffe0 <= x && x <= 0xffe6) || | ||
(0xFF01 <= codePoint && codePoint <= 0xFF60) || | ||
(0xFFE0 <= codePoint && codePoint <= 0xFFE6) || | ||
// Kana Supplement | ||
(0x1b000 <= x && x <= 0x1b001) || | ||
(0x1B000 <= codePoint && codePoint <= 0x1B001) || | ||
// Enclosed Ideographic Supplement | ||
(0x1f200 <= x && x <= 0x1f251) || | ||
(0x1F200 <= codePoint && codePoint <= 0x1F251) || | ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane | ||
(0x20000 <= x && x <= 0x3fffd) | ||
(0x20000 <= codePoint && codePoint <= 0x3FFFD) | ||
) | ||
@@ -47,1 +48,4 @@ ) { | ||
}; | ||
module.exports = isFullwidthCodePoint; | ||
module.exports.default = isFullwidthCodePoint; |
{ | ||
"name": "is-fullwidth-code-point", | ||
"version": "2.0.0", | ||
"description": "Check if the character represented by a given Unicode code point is fullwidth", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-fullwidth-code-point", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"fullwidth", | ||
"full-width", | ||
"full", | ||
"width", | ||
"unicode", | ||
"character", | ||
"char", | ||
"string", | ||
"str", | ||
"codepoint", | ||
"code", | ||
"point", | ||
"is", | ||
"detect", | ||
"check" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "is-fullwidth-code-point", | ||
"version": "3.0.0", | ||
"description": "Check if the character represented by a given Unicode code point is fullwidth", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-fullwidth-code-point", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"fullwidth", | ||
"full-width", | ||
"full", | ||
"width", | ||
"unicode", | ||
"character", | ||
"string", | ||
"codepoint", | ||
"code", | ||
"point", | ||
"is", | ||
"detect", | ||
"check" | ||
], | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"tsd-check": "^0.5.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) | ||
``` | ||
$ npm install --save is-fullwidth-code-point | ||
$ npm install is-fullwidth-code-point | ||
``` | ||
@@ -19,6 +19,6 @@ | ||
isFullwidthCodePoint('谢'.codePointAt()); | ||
isFullwidthCodePoint('谢'.codePointAt(0)); | ||
//=> true | ||
isFullwidthCodePoint('a'.codePointAt()); | ||
isFullwidthCodePoint('a'.codePointAt(0)); | ||
//=> false | ||
@@ -30,9 +30,9 @@ ``` | ||
### isFullwidthCodePoint(input) | ||
### isFullwidthCodePoint(codePoint) | ||
#### input | ||
#### codePoint | ||
Type: `number` | ||
[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. | ||
The [code point](https://en.wikipedia.org/wiki/Code_point) of a character. | ||
@@ -39,0 +39,0 @@ |
Sorry, the diff of this file is not supported yet
4994
5
59
3