aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-01-26 14:08:13 -0500
committerBobby <[email protected]>2022-01-26 14:08:13 -0500
commite58920a441ae0293764ed8e3645e3915f62e94cb (patch)
tree96367ea04e571f6640459dfce61893736b7ef9f3
parentdca40908a25b155dfed169f0260ec3083df90ed1 (diff)
downloadizuku.js-e58920a441ae0293764ed8e3645e3915f62e94cb.tar.xz
izuku.js-e58920a441ae0293764ed8e3645e3915f62e94cb.zip
chore: remove simple wcswidth
-rw-r--r--package-lock.json13
-rw-r--r--package.json3
-rw-r--r--src/helpers/tableBuilder/src/internalTable/input-converter.ts4
-rw-r--r--src/helpers/tableBuilder/src/internalTable/internal-table-printer.ts4
-rw-r--r--src/helpers/tableBuilder/src/internalTable/internal-table.ts8
-rw-r--r--src/helpers/tableBuilder/src/models/external-table.ts2
-rw-r--r--src/helpers/tableBuilder/src/utils/console-utils.ts2
-rw-r--r--src/helpers/tableBuilder/src/utils/table-constants.ts12
-rw-r--r--src/helpers/tableBuilder/src/utils/table-helpers.ts12
-rw-r--r--src/helpers/wcswidth/index.ts4
-rw-r--r--src/helpers/wcswidth/src/binary-search.ts29
-rw-r--r--src/helpers/wcswidth/src/models.ts4
-rw-r--r--src/helpers/wcswidth/src/non-spacing-chars.ts150
-rw-r--r--src/helpers/wcswidth/src/wcswidth.ts19
-rw-r--r--src/helpers/wcswidth/src/wcwidth.ts72
15 files changed, 302 insertions, 36 deletions
diff --git a/package-lock.json b/package-lock.json
index d56f210..c94c24b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,8 +9,7 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
- "buffer": "^6.0.3",
- "simple-wcswidth": "^1.0.1"
+ "buffer": "^6.0.3"
},
"devDependencies": {
"@commitlint/cli": "^16.0.2",
@@ -4451,11 +4450,6 @@
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==",
"dev": true
},
- "node_modules/simple-wcswidth": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz",
- "integrity": "sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg=="
- },
"node_modules/slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
@@ -8337,11 +8331,6 @@
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==",
"dev": true
},
- "simple-wcswidth": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz",
- "integrity": "sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg=="
- },
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
diff --git a/package.json b/package.json
index 29e3e35..76841c9 100644
--- a/package.json
+++ b/package.json
@@ -60,7 +60,6 @@
]
},
"dependencies": {
- "buffer": "^6.0.3",
- "simple-wcswidth": "^1.0.1"
+ "buffer": "^6.0.3"
}
}
diff --git a/src/helpers/tableBuilder/src/internalTable/input-converter.ts b/src/helpers/tableBuilder/src/internalTable/input-converter.ts
index c3800e6..cd24de0 100644
--- a/src/helpers/tableBuilder/src/internalTable/input-converter.ts
+++ b/src/helpers/tableBuilder/src/internalTable/input-converter.ts
@@ -9,7 +9,7 @@ export const objIfExists = (key: string, val: any) => {
}
return {
- [key]: val,
+ [key]: val
};
};
@@ -21,5 +21,5 @@ export const rawColumnToInternalColumn = (
...objIfExists('color', column.color as COLOR),
...objIfExists('maxLen', column.maxLen),
...objIfExists('minLen', column.minLen),
- alignment: column.alignment || DEFAULT_ROW_ALIGNMENT,
+ alignment: column.alignment || DEFAULT_ROW_ALIGNMENT
});
diff --git a/src/helpers/tableBuilder/src/internalTable/internal-table-printer.ts b/src/helpers/tableBuilder/src/internalTable/internal-table-printer.ts
index ffdeb59..d25719c 100644
--- a/src/helpers/tableBuilder/src/internalTable/internal-table-printer.ts
+++ b/src/helpers/tableBuilder/src/internalTable/internal-table-printer.ts
@@ -7,14 +7,14 @@ import {
DEFAULT_HEADER_ALIGNMENT,
DEFAULT_HEADER_FONT_COLOR,
DEFAULT_ROW_ALIGNMENT,
- DEFAULT_ROW_FONT_COLOR,
+ DEFAULT_ROW_FONT_COLOR
} from '../utils/table-constants';
import {
cellText,
createHeaderAsRow,
createRow,
getWidthLimitedColumnsArray,
- renderTableHorizontalBorders,
+ renderTableHorizontalBorders
} from '../utils/table-helpers';
import TableInternal from './internal-table';
import { preProcessColumns, preProcessRows } from './table-pre-processors';
diff --git a/src/helpers/tableBuilder/src/internalTable/internal-table.ts b/src/helpers/tableBuilder/src/internalTable/internal-table.ts
index a7b443f..17e8219 100644
--- a/src/helpers/tableBuilder/src/internalTable/internal-table.ts
+++ b/src/helpers/tableBuilder/src/internalTable/internal-table.ts
@@ -3,20 +3,20 @@ import {
ComplexOptions,
ComputedColumn,
RowFilterFunction,
- RowSortFunction,
+ RowSortFunction
} from '../models/external-table';
import { Column, TableStyleDetails } from '../models/internal-table';
import {
DEFAULT_TABLE_STYLE,
DEFAULT_ROW_ALIGNMENT,
DEFAULT_ROW_FONT_COLOR,
- DEFAULT_ROW_SEPARATOR,
+ DEFAULT_ROW_SEPARATOR
} from '../utils/table-constants';
import {
createColumFromComputedColumn,
createColumFromOnlyName,
createRow,
- RowOptions,
+ RowOptions
} from '../utils/table-helpers';
import { rawColumnToInternalColumn } from './input-converter';
import { renderTable } from './internal-table-printer';
@@ -50,7 +50,7 @@ class TableInternal {
this.columns = columns.map((column) => ({
name: column,
title: column,
- alignment: DEFAULT_ROW_ALIGNMENT,
+ alignment: DEFAULT_ROW_ALIGNMENT
}));
}
diff --git a/src/helpers/tableBuilder/src/models/external-table.ts b/src/helpers/tableBuilder/src/models/external-table.ts
index 4c2df30..8256e20 100644
--- a/src/helpers/tableBuilder/src/models/external-table.ts
+++ b/src/helpers/tableBuilder/src/models/external-table.ts
@@ -18,7 +18,7 @@ export interface ComputedColumn extends ColumnOptionsRaw {
export type RowSortFunction = (row1: any, row2: any) => number;
-export type RowFilterFunction = (row: any) => Boolean;
+export type RowFilterFunction = (row: any) => boolean;
export interface ComplexOptions {
style?: TableStyleDetails;
diff --git a/src/helpers/tableBuilder/src/utils/console-utils.ts b/src/helpers/tableBuilder/src/utils/console-utils.ts
index 93620c8..73ea8d8 100644
--- a/src/helpers/tableBuilder/src/utils/console-utils.ts
+++ b/src/helpers/tableBuilder/src/utils/console-utils.ts
@@ -1,4 +1,4 @@
-import { wcswidth } from 'simple-wcswidth';
+import { wcswidth } from '../../../wcswidth';
/* eslint-disable no-control-regex */
const colorRegex = /\x1b\[\d{1,3}m/g; // \x1b[30m \x1b[305m
diff --git a/src/helpers/tableBuilder/src/utils/table-constants.ts b/src/helpers/tableBuilder/src/utils/table-constants.ts
index 90d7bf9..a82ee83 100644
--- a/src/helpers/tableBuilder/src/utils/table-constants.ts
+++ b/src/helpers/tableBuilder/src/utils/table-constants.ts
@@ -17,27 +17,27 @@ export const DEFAULT_TABLE_STYLE: TableStyleDetails = {
left: '┌',
mid: '┬',
right: '┐',
- other: '─',
+ other: '─'
},
headerBottom: {
left: '├',
mid: '┼',
right: '┤',
- other: '─',
+ other: '─'
},
tableBottom: {
left: '└',
mid: '┴',
right: '┘',
- other: '─',
+ other: '─'
},
vertical: '│',
rowSeparator: {
left: '├',
mid: '┼',
right: '┤',
- other: '─',
- },
+ other: '─'
+ }
};
export const ALIGNMENTS = ['right', 'left', 'center'];
@@ -52,7 +52,7 @@ export const COLORS = [
'cyan',
'crimson',
'white_bold',
- 'reset',
+ 'reset'
];
export const DEFAULT_ROW_FONT_COLOR: COLOR = 'white';
diff --git a/src/helpers/tableBuilder/src/utils/table-helpers.ts b/src/helpers/tableBuilder/src/utils/table-helpers.ts
index 51478a3..69dfb3b 100644
--- a/src/helpers/tableBuilder/src/utils/table-helpers.ts
+++ b/src/helpers/tableBuilder/src/utils/table-helpers.ts
@@ -8,7 +8,7 @@ import {
DEFAULT_COLUMN_LEN,
DEFAULT_ROW_ALIGNMENT,
DEFAULT_ROW_SEPARATOR,
- DEFAULT_HEADER_FONT_COLOR,
+ DEFAULT_HEADER_FONT_COLOR
} from './table-constants';
const max = (a: number, b: number) => Math.max(a, b);
@@ -33,7 +33,7 @@ export const convertRawRowOptionsToStandard = (
if (options) {
return {
color: options.color as COLOR,
- separator: options.separator || DEFAULT_ROW_SEPARATOR,
+ separator: options.separator || DEFAULT_ROW_SEPARATOR
};
}
return undefined;
@@ -44,7 +44,7 @@ export const createTableHorizontalBorders = (
left,
mid,
right,
- other,
+ other
}: { left: string; mid: string; right: string; other: string },
column_lengths: number[]
) => {
@@ -67,7 +67,7 @@ export const createTableHorizontalBorders = (
export const createColumFromOnlyName = (name: string): Column => ({
name,
- title: name,
+ title: name
});
export const createColumFromComputedColumn = (
column: ComputedColumn
@@ -77,7 +77,7 @@ export const createColumFromComputedColumn = (
...objIfExists('color', column.color as COLOR),
...objIfExists('maxLen', column.maxLen),
...objIfExists('minLen', column.minLen),
- alignment: column.alignment || DEFAULT_ROW_ALIGNMENT,
+ alignment: column.alignment || DEFAULT_ROW_ALIGNMENT
});
export const createRow = (
@@ -87,7 +87,7 @@ export const createRow = (
): Row => ({
color,
separator,
- text,
+ text
});
export const findLenOfColumn = (column: Column, rows: Row[]): number => {
diff --git a/src/helpers/wcswidth/index.ts b/src/helpers/wcswidth/index.ts
new file mode 100644
index 0000000..f5f92b6
--- /dev/null
+++ b/src/helpers/wcswidth/index.ts
@@ -0,0 +1,4 @@
+import wcswidth from './src/wcswidth';
+import wcwidth from './src/wcwidth';
+
+export { wcwidth, wcswidth };
diff --git a/src/helpers/wcswidth/src/binary-search.ts b/src/helpers/wcswidth/src/binary-search.ts
new file mode 100644
index 0000000..c9b7a2a
--- /dev/null
+++ b/src/helpers/wcswidth/src/binary-search.ts
@@ -0,0 +1,29 @@
+import { Interval } from './models';
+
+/* auxiliary function for binary search in interval table */
+const bisearch = (
+ ucs: number,
+ table: Interval[],
+ tableSize: number
+): number => {
+ let min = 0;
+ let mid: number;
+ let max = tableSize;
+
+ if (ucs < table[0].first || ucs > table[max].last) return 0;
+
+ while (max >= min) {
+ mid = Math.floor((min + max) / 2);
+ if (ucs > table[mid].last) {
+ min = mid + 1;
+ } else if (ucs < table[mid].first) {
+ max = mid - 1;
+ } else {
+ return 1;
+ }
+ }
+
+ return 0;
+};
+
+export default bisearch;
diff --git a/src/helpers/wcswidth/src/models.ts b/src/helpers/wcswidth/src/models.ts
new file mode 100644
index 0000000..daf25b8
--- /dev/null
+++ b/src/helpers/wcswidth/src/models.ts
@@ -0,0 +1,4 @@
+export interface Interval {
+ first: number;
+ last: number;
+}
diff --git a/src/helpers/wcswidth/src/non-spacing-chars.ts b/src/helpers/wcswidth/src/non-spacing-chars.ts
new file mode 100644
index 0000000..09ac84b
--- /dev/null
+++ b/src/helpers/wcswidth/src/non-spacing-chars.ts
@@ -0,0 +1,150 @@
+import { Interval } from './models';
+
+/* sorted list of non-overlapping intervals of non-spacing characters */
+/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
+const combining: Interval[] = [
+ { first: 0x0300, last: 0x036f },
+ { first: 0x0483, last: 0x0486 },
+ { first: 0x0488, last: 0x0489 },
+ { first: 0x0591, last: 0x05bd },
+ { first: 0x05bf, last: 0x05bf },
+ { first: 0x05c1, last: 0x05c2 },
+ { first: 0x05c4, last: 0x05c5 },
+ { first: 0x05c7, last: 0x05c7 },
+ { first: 0x0600, last: 0x0603 },
+ { first: 0x0610, last: 0x0615 },
+ { first: 0x064b, last: 0x065e },
+ { first: 0x0670, last: 0x0670 },
+ { first: 0x06d6, last: 0x06e4 },
+ { first: 0x06e7, last: 0x06e8 },
+ { first: 0x06ea, last: 0x06ed },
+ { first: 0x070f, last: 0x070f },
+ { first: 0x0711, last: 0x0711 },
+ { first: 0x0730, last: 0x074a },
+ { first: 0x07a6, last: 0x07b0 },
+ { first: 0x07eb, last: 0x07f3 },
+ { first: 0x0901, last: 0x0902 },
+ { first: 0x093c, last: 0x093c },
+ { first: 0x0941, last: 0x0948 },
+ { first: 0x094d, last: 0x094d },
+ { first: 0x0951, last: 0x0954 },
+ { first: 0x0962, last: 0x0963 },
+ { first: 0x0981, last: 0x0981 },
+ { first: 0x09bc, last: 0x09bc },
+ { first: 0x09c1, last: 0x09c4 },
+ { first: 0x09cd, last: 0x09cd },
+ { first: 0x09e2, last: 0x09e3 },
+ { first: 0x0a01, last: 0x0a02 },
+ { first: 0x0a3c, last: 0x0a3c },
+ { first: 0x0a41, last: 0x0a42 },
+ { first: 0x0a47, last: 0x0a48 },
+ { first: 0x0a4b, last: 0x0a4d },
+ { first: 0x0a70, last: 0x0a71 },
+ { first: 0x0a81, last: 0x0a82 },
+ { first: 0x0abc, last: 0x0abc },
+ { first: 0x0ac1, last: 0x0ac5 },
+ { first: 0x0ac7, last: 0x0ac8 },
+ { first: 0x0acd, last: 0x0acd },
+ { first: 0x0ae2, last: 0x0ae3 },
+ { first: 0x0b01, last: 0x0b01 },
+ { first: 0x0b3c, last: 0x0b3c },
+ { first: 0x0b3f, last: 0x0b3f },
+ { first: 0x0b41, last: 0x0b43 },
+ { first: 0x0b4d, last: 0x0b4d },
+ { first: 0x0b56, last: 0x0b56 },
+ { first: 0x0b82, last: 0x0b82 },
+ { first: 0x0bc0, last: 0x0bc0 },
+ { first: 0x0bcd, last: 0x0bcd },
+ { first: 0x0c3e, last: 0x0c40 },
+ { first: 0x0c46, last: 0x0c48 },
+ { first: 0x0c4a, last: 0x0c4d },
+ { first: 0x0c55, last: 0x0c56 },
+ { first: 0x0cbc, last: 0x0cbc },
+ { first: 0x0cbf, last: 0x0cbf },
+ { first: 0x0cc6, last: 0x0cc6 },
+ { first: 0x0ccc, last: 0x0ccd },
+ { first: 0x0ce2, last: 0x0ce3 },
+ { first: 0x0d41, last: 0x0d43 },
+ { first: 0x0d4d, last: 0x0d4d },
+ { first: 0x0dca, last: 0x0dca },
+ { first: 0x0dd2, last: 0x0dd4 },
+ { first: 0x0dd6, last: 0x0dd6 },
+ { first: 0x0e31, last: 0x0e31 },
+ { first: 0x0e34, last: 0x0e3a },
+ { first: 0x0e47, last: 0x0e4e },
+ { first: 0x0eb1, last: 0x0eb1 },
+ { first: 0x0eb4, last: 0x0eb9 },
+ { first: 0x0ebb, last: 0x0ebc },
+ { first: 0x0ec8, last: 0x0ecd },
+ { first: 0x0f18, last: 0x0f19 },
+ { first: 0x0f35, last: 0x0f35 },
+ { first: 0x0f37, last: 0x0f37 },
+ { first: 0x0f39, last: 0x0f39 },
+ { first: 0x0f71, last: 0x0f7e },
+ { first: 0x0f80, last: 0x0f84 },
+ { first: 0x0f86, last: 0x0f87 },
+ { first: 0x0f90, last: 0x0f97 },
+ { first: 0x0f99, last: 0x0fbc },
+ { first: 0x0fc6, last: 0x0fc6 },
+ { first: 0x102d, last: 0x1030 },
+ { first: 0x1032, last: 0x1032 },
+ { first: 0x1036, last: 0x1037 },
+ { first: 0x1039, last: 0x1039 },
+ { first: 0x1058, last: 0x1059 },
+ { first: 0x1160, last: 0x11ff },
+ { first: 0x135f, last: 0x135f },
+ { first: 0x1712, last: 0x1714 },
+ { first: 0x1732, last: 0x1734 },
+ { first: 0x1752, last: 0x1753 },
+ { first: 0x1772, last: 0x1773 },
+ { first: 0x17b4, last: 0x17b5 },
+ { first: 0x17b7, last: 0x17bd },
+ { first: 0x17c6, last: 0x17c6 },
+ { first: 0x17c9, last: 0x17d3 },
+ { first: 0x17dd, last: 0x17dd },
+ { first: 0x180b, last: 0x180d },
+ { first: 0x18a9, last: 0x18a9 },
+ { first: 0x1920, last: 0x1922 },
+ { first: 0x1927, last: 0x1928 },
+ { first: 0x1932, last: 0x1932 },
+ { first: 0x1939, last: 0x193b },
+ { first: 0x1a17, last: 0x1a18 },
+ { first: 0x1b00, last: 0x1b03 },
+ { first: 0x1b34, last: 0x1b34 },
+ { first: 0x1b36, last: 0x1b3a },
+ { first: 0x1b3c, last: 0x1b3c },
+ { first: 0x1b42, last: 0x1b42 },
+ { first: 0x1b6b, last: 0x1b73 },
+ { first: 0x1dc0, last: 0x1dca },
+ { first: 0x1dfe, last: 0x1dff },
+ { first: 0x200b, last: 0x200f },
+ { first: 0x202a, last: 0x202e },
+ { first: 0x2060, last: 0x2063 },
+ { first: 0x206a, last: 0x206f },
+ { first: 0x20d0, last: 0x20ef },
+ { first: 0x302a, last: 0x302f },
+ { first: 0x3099, last: 0x309a },
+ { first: 0xa806, last: 0xa806 },
+ { first: 0xa80b, last: 0xa80b },
+ { first: 0xa825, last: 0xa826 },
+ { first: 0xfb1e, last: 0xfb1e },
+ { first: 0xfe00, last: 0xfe0f },
+ { first: 0xfe20, last: 0xfe23 },
+ { first: 0xfeff, last: 0xfeff },
+ { first: 0xfff9, last: 0xfffb },
+ { first: 0x10a01, last: 0x10a03 },
+ { first: 0x10a05, last: 0x10a06 },
+ { first: 0x10a0c, last: 0x10a0f },
+ { first: 0x10a38, last: 0x10a3a },
+ { first: 0x10a3f, last: 0x10a3f },
+ { first: 0x1d167, last: 0x1d169 },
+ { first: 0x1d173, last: 0x1d182 },
+ { first: 0x1d185, last: 0x1d18b },
+ { first: 0x1d1aa, last: 0x1d1ad },
+ { first: 0x1d242, last: 0x1d244 },
+ { first: 0xe0001, last: 0xe0001 },
+ { first: 0xe0020, last: 0xe007f },
+ { first: 0xe0100, last: 0xe01ef }
+];
+
+export default combining;
diff --git a/src/helpers/wcswidth/src/wcswidth.ts b/src/helpers/wcswidth/src/wcswidth.ts
new file mode 100644
index 0000000..a287561
--- /dev/null
+++ b/src/helpers/wcswidth/src/wcswidth.ts
@@ -0,0 +1,19 @@
+import mk_wcwidth from './wcwidth';
+
+const mk_wcswidth = (pwcs: string) => {
+ let width = 0;
+
+ // eslint-disable-next-line no-plusplus
+ for (let i = 0; i < pwcs.length; i++) {
+ const charCode = pwcs.charCodeAt(i);
+ const w = mk_wcwidth(charCode);
+ if (w < 0) {
+ return -1;
+ }
+ width += w;
+ }
+
+ return width;
+};
+
+export default mk_wcswidth;
diff --git a/src/helpers/wcswidth/src/wcwidth.ts b/src/helpers/wcswidth/src/wcwidth.ts
new file mode 100644
index 0000000..a546806
--- /dev/null
+++ b/src/helpers/wcswidth/src/wcwidth.ts
@@ -0,0 +1,72 @@
+import combining from './non-spacing-chars';
+import bisearch from './binary-search';
+
+/* The following two functions define the column width of an ISO 10646
+ * character as follows:
+ *
+ * - The null character (U+0000) has a column width of 0.
+ *
+ * - Other C0/C1 control characters and DEL will lead to a return
+ * value of -1.
+ *
+ * - Non-spacing and enclosing combining characters (general
+ * category code Mn or Me in the Unicode database) have a
+ * column width of 0.
+ *
+ * - SOFT HYPHEN (U+00AD) has a column width of 1.
+ *
+ * - Other format characters (general category code Cf in the Unicode
+ * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
+ *
+ * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
+ * have a column width of 0.
+ *
+ * - Spacing characters in the East Asian Wide (W) or East Asian
+ * Full-width (F) category as defined in Unicode Technical
+ * Report #11 have a column width of 2.
+ *
+ * - All remaining characters (including all printable
+ * ISO 8859-1 and WGL4 characters, Unicode control characters,
+ * etc.) have a column width of 1.
+ *
+ * This implementation assumes that wchar_t characters are encoded
+ * in ISO 10646.
+ */
+
+const mk_wcwidth = (ucs: number): number => {
+ /* test for 8-bit control characters */
+ if (ucs === 0) {
+ return 0;
+ }
+ if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
+ return -1;
+ }
+
+ /* binary search in table of non-spacing characters */
+ if (bisearch(ucs, combining, combining.length - 1)) {
+ return 0;
+ }
+
+ /* if we arrive here, ucs is not a combining or C0/C1 control character */
+
+ return (
+ 1 +
+ Number(
+ ucs >= 0x1100 &&
+ (ucs <= 0x115f /* Hangul Jamo init. consonants */ ||
+ ucs === 0x2329 ||
+ ucs === 0x232a ||
+ (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) /* CJK ... Yi */ ||
+ (ucs >= 0xac00 && ucs <= 0xd7a3) /* Hangul Syllables */ ||
+ (ucs >= 0xf900 && ucs <= 0xfaff) /* CJK Compatibility Ideographs */ ||
+ (ucs >= 0xfe10 && ucs <= 0xfe19) /* Vertical forms */ ||
+ (ucs >= 0xfe30 && ucs <= 0xfe6f) /* CJK Compatibility Forms */ ||
+ (ucs >= 0xff00 && ucs <= 0xff60) /* Fullwidth Forms */ ||
+ (ucs >= 0xffe0 && ucs <= 0xffe6) ||
+ (ucs >= 0x20000 && ucs <= 0x2fffd) ||
+ (ucs >= 0x30000 && ucs <= 0x3fffd))
+ )
+ );
+};
+
+export default mk_wcwidth;