the editable site (validation-lab)
This commit is contained in:
commit
3ac81d5a52
13454 files changed
+2227005
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
import {getCategory, isAmbiguous, isFullwidth, isWide} from './lookup.js';
|
||||
|
||||
function validate(codePoint) {
|
||||
if (!Number.isSafeInteger(codePoint)) {
|
||||
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
||||
}
|
||||
}
|
||||
|
||||
export function eastAsianWidthType(codePoint) {
|
||||
validate(codePoint);
|
||||
|
||||
return getCategory(codePoint);
|
||||
}
|
||||
|
||||
export function eastAsianWidth(codePoint, {ambiguousAsWide = false} = {}) {
|
||||
validate(codePoint);
|
||||
|
||||
if (
|
||||
isFullwidth(codePoint)
|
||||
|| isWide(codePoint)
|
||||
|| (ambiguousAsWide && isAmbiguous(codePoint))
|
||||
) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Private exports for https://github.com/sindresorhus/is-fullwidth-code-point
|
||||
export {
|
||||
isFullwidth as _isFullwidth,
|
||||
// TODO: Remove this in the next major version.
|
||||
isFullwidth as _isFullWidth,
|
||||
isWide as _isWide,
|
||||
} from './lookup.js';
|
||||
Reference in new issue
Block a user