Skip to content

Commit

Permalink
util: runtime deprecate toUSVString()
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Sep 19, 2024
1 parent 291d90a commit 962ea51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3547,12 +3547,15 @@ the result of said promise, which can lead to unhandled promise rejections.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/55018
description: Runtime deprecation.
- version: v20.8.0
pr-url: https://github.com/nodejs/node/pull/49725
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

The [`util.toUSVString()`][] API is deprecated. Please use
[`String.prototype.toWellFormed`][] instead.
Expand Down
9 changes: 6 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ function getCallSite(frames = 10) {
return binding.getCallSite(frames);
};

function toUSVString(input) {
return StringPrototypeToWellFormed(`${input}`);
}

// Keep the `exports =` so that various functions can still be monkeypatched
module.exports = {
_errnoException,
Expand Down Expand Up @@ -357,9 +361,8 @@ module.exports = {
},
promisify,
stripVTControlCharacters,
toUSVString(input) {
return StringPrototypeToWellFormed(`${input}`);
},
toUSVString: deprecate(toUSVString, 'util.toUSVString() is deprecated. ' +
'Please use String.prototype.toWellFormed() instead.', 'DEP0175'),
get transferableAbortSignal() {
return lazyAbortController().transferableAbortSignal;
},
Expand Down

0 comments on commit 962ea51

Please sign in to comment.