string-width
Advanced tools
Comparing version 7.0.0 to 7.1.0
@@ -5,2 +5,4 @@ import stripAnsi from 'strip-ansi'; | ||
const segmenter = new Intl.Segmenter(); | ||
export default function stringWidth(string, options = {}) { | ||
@@ -25,4 +27,5 @@ if (typeof string !== 'string' || string.length === 0) { | ||
let width = 0; | ||
const eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow}; | ||
for (const {segment: character} of new Intl.Segmenter().segment(string)) { | ||
for (const {segment: character} of segmenter.segment(string)) { | ||
const codePoint = character.codePointAt(0); | ||
@@ -45,3 +48,3 @@ | ||
width += eastAsianWidth(codePoint, {ambiguousAsWide: !ambiguousIsNarrow}); | ||
width += eastAsianWidth(codePoint, eastAsianWidthOptions); | ||
} | ||
@@ -48,0 +51,0 @@ |
{ | ||
"name": "string-width", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "Get the visual width of a string - the number of columns required to display it", | ||
@@ -18,2 +18,3 @@ "license": "MIT", | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
@@ -20,0 +21,0 @@ "node": ">=18" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6612
68