Comparing version 3.1.0 to 3.1.1
@@ -71,2 +71,5 @@ const ansiColors = { | ||
} | ||
function isHighSurrogate(char) { | ||
return char >= '\ud800' && char <= '\udbff'; | ||
} | ||
export function truncate(string, length, tail = truncator) { | ||
@@ -80,3 +83,7 @@ string = String(string); | ||
if (stringLength > length && stringLength > tailLength) { | ||
return `${string.slice(0, length - tailLength)}${tail}`; | ||
let end = length - tailLength; | ||
if (end > 0 && isHighSurrogate(string[end - 1])) { | ||
end = end - 1; | ||
} | ||
return `${string.slice(0, end)}${tail}`; | ||
} | ||
@@ -83,0 +90,0 @@ return string; |
@@ -121,2 +121,5 @@ "use strict"; | ||
} | ||
function isHighSurrogate(char) { | ||
return char >= "\uD800" && char <= "\uDBFF"; | ||
} | ||
function truncate(string, length, tail = truncator) { | ||
@@ -130,3 +133,7 @@ string = String(string); | ||
if (stringLength > length && stringLength > tailLength) { | ||
return `${string.slice(0, length - tailLength)}${tail}`; | ||
let end = length - tailLength; | ||
if (end > 0 && isHighSurrogate(string[end - 1])) { | ||
end = end - 1; | ||
} | ||
return `${string.slice(0, end)}${tail}`; | ||
} | ||
@@ -133,0 +140,0 @@ return string; |
{ | ||
"name": "loupe", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Inspect utility for Node.js and browsers", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/chaijs/loupe", |
Sorry, the diff of this file is not supported yet
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
60483
1314