-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathis-narrow-character.js
42 lines (39 loc) · 1.25 KB
/
is-narrow-character.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* @copyright 2016 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
"use strict"
//------------------------------------------------------------------------------
// Exports
//------------------------------------------------------------------------------
/*eslint-disable complexity */
/**
* It checks whether the given character is a narrow character or not.
*
* @param {string} character - The character to check.
* @returns {boolean} `true` if the character is a narrow character.
*/
module.exports = function isNarrowCharacter(character) {
const cp = character.codePointAt(0)
return (
(cp >= 0x20 && cp <= 0x7E) ||
cp === 0xA2 ||
cp === 0xA3 ||
cp === 0xA5 ||
cp === 0xA6 ||
cp === 0xAC ||
cp === 0xAF ||
cp === 0x20A9 ||
(cp >= 0x27E6 && cp <= 0x27ED) ||
cp === 0x2985 ||
cp === 0x2986 ||
(cp >= 0xFF61 && cp <= 0xFFBE) ||
(cp >= 0xFFC2 && cp <= 0xFFC7) ||
(cp >= 0xFFCA && cp <= 0xFFCF) ||
(cp >= 0xFFD2 && cp <= 0xFFD7) ||
(cp >= 0xFFDA && cp <= 0xFFDC) ||
(cp >= 0xFFE8 && cp <= 0xFFEE)
)
}
/*eslint-enable */