Skip to content

Commit

Permalink
util: replace util.toUSVString with String.prototype.toWellFormed (#2036
Browse files Browse the repository at this point in the history
)
  • Loading branch information
KhafraDev committed Apr 1, 2023
1 parent 7ae1779 commit 549e7ed
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,21 @@ function throwIfAborted (signal) {
}
}

const hasToWellFormed = !!String.prototype.toWellFormed

/**
* @param {string} val
*/
function toUSVString (val) {
if (hasToWellFormed) {
return `${val}`.toWellFormed()
} else if (nodeUtil.toUSVString) {
return nodeUtil.toUSVString(val)
}

return `${val}`
}

const kEnumerableProperty = Object.create(null)
kEnumerableProperty.enumerable = true

Expand All @@ -418,7 +433,7 @@ module.exports = {
isDisturbed,
isErrored,
isReadable,
toUSVString: nodeUtil.toUSVString || ((val) => `${val}`),
toUSVString,
isReadableAborted,
isBlobLike,
parseOrigin,
Expand Down

0 comments on commit 549e7ed

Please sign in to comment.