is-fullwidth-code-point
Advanced tools
Comparing version 1.0.0 to 2.0.0
72
index.js
'use strict'; | ||
var numberIsNan = require('number-is-nan'); | ||
module.exports = function (x) { | ||
if (numberIsNan(x)) { | ||
/* eslint-disable yoda */ | ||
module.exports = x => { | ||
if (Number.isNaN(x)) { | ||
return false; | ||
} | ||
// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369 | ||
// code points are derived from: | ||
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt | ||
if (x >= 0x1100 && ( | ||
x <= 0x115f || // Hangul Jamo | ||
0x2329 === x || // LEFT-POINTING ANGLE BRACKET | ||
0x232a === x || // RIGHT-POINTING ANGLE BRACKET | ||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months | ||
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || | ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A | ||
0x3250 <= x && x <= 0x4dbf || | ||
// CJK Unified Ideographs .. Yi Radicals | ||
0x4e00 <= x && x <= 0xa4c6 || | ||
// Hangul Jamo Extended-A | ||
0xa960 <= x && x <= 0xa97c || | ||
// Hangul Syllables | ||
0xac00 <= x && x <= 0xd7a3 || | ||
// CJK Compatibility Ideographs | ||
0xf900 <= x && x <= 0xfaff || | ||
// Vertical Forms | ||
0xfe10 <= x && x <= 0xfe19 || | ||
// CJK Compatibility Forms .. Small Form Variants | ||
0xfe30 <= x && x <= 0xfe6b || | ||
// Halfwidth and Fullwidth Forms | ||
0xff01 <= x && x <= 0xff60 || | ||
0xffe0 <= x && x <= 0xffe6 || | ||
// Kana Supplement | ||
0x1b000 <= x && x <= 0x1b001 || | ||
// Enclosed Ideographic Supplement | ||
0x1f200 <= x && x <= 0x1f251 || | ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane | ||
0x20000 <= x && x <= 0x3fffd)) { | ||
if ( | ||
x >= 0x1100 && ( | ||
x <= 0x115f || // Hangul Jamo | ||
x === 0x2329 || // LEFT-POINTING ANGLE BRACKET | ||
x === 0x232a || // RIGHT-POINTING ANGLE BRACKET | ||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months | ||
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || | ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A | ||
(0x3250 <= x && x <= 0x4dbf) || | ||
// CJK Unified Ideographs .. Yi Radicals | ||
(0x4e00 <= x && x <= 0xa4c6) || | ||
// Hangul Jamo Extended-A | ||
(0xa960 <= x && x <= 0xa97c) || | ||
// Hangul Syllables | ||
(0xac00 <= x && x <= 0xd7a3) || | ||
// CJK Compatibility Ideographs | ||
(0xf900 <= x && x <= 0xfaff) || | ||
// Vertical Forms | ||
(0xfe10 <= x && x <= 0xfe19) || | ||
// CJK Compatibility Forms .. Small Form Variants | ||
(0xfe30 <= x && x <= 0xfe6b) || | ||
// Halfwidth and Fullwidth Forms | ||
(0xff01 <= x && x <= 0xff60) || | ||
(0xffe0 <= x && x <= 0xffe6) || | ||
// Kana Supplement | ||
(0x1b000 <= x && x <= 0x1b001) || | ||
// Enclosed Ideographic Supplement | ||
(0x1f200 <= x && x <= 0x1f251) || | ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane | ||
(0x20000 <= x && x <= 0x3fffd) | ||
) | ||
) { | ||
return true; | ||
@@ -46,2 +46,2 @@ } | ||
return false; | ||
} | ||
}; |
{ | ||
"name": "is-fullwidth-code-point", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Check if the character represented by a given Unicode code point is fullwidth", | ||
@@ -13,6 +13,6 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -39,9 +39,9 @@ "files": [ | ||
], | ||
"dependencies": { | ||
"number-is-nan": "^1.0.0" | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"devDependencies": { | ||
"ava": "0.0.4", | ||
"code-point-at": "^1.0.0" | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -16,3 +16,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) | ||
```js | ||
var isFullwidthCodePoint = require('is-fullwidth-code-point'); | ||
const isFullwidthCodePoint = require('is-fullwidth-code-point'); | ||
@@ -40,2 +40,2 @@ isFullwidthCodePoint('谢'.codePointAt()); | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
0
44
4136
- Removednumber-is-nan@^1.0.0
- Removednumber-is-nan@1.0.1(transitive)