summaryrefslogtreecommitdiff
path: root/ext/node
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node')
-rw-r--r--ext/node/polyfills/util.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/node/polyfills/util.ts b/ext/node/polyfills/util.ts
index 1b611b1fd..2e25746ef 100644
--- a/ext/node/polyfills/util.ts
+++ b/ext/node/polyfills/util.ts
@@ -37,7 +37,9 @@ const {
SafeSet,
SetPrototypeAdd,
SetPrototypeHas,
+ StringPrototypeIsWellFormed,
StringPrototypePadStart,
+ StringPrototypeToWellFormed,
} = primordials;
export {
@@ -187,6 +189,13 @@ export const TextDecoder = _TextDecoder;
export type TextEncoder = import("./_utils.ts")._TextEncoder;
export const TextEncoder = _TextEncoder;
+export function toUSVString(str: string): string {
+ if (StringPrototypeIsWellFormed(str)) {
+ return str;
+ }
+ return StringPrototypeToWellFormed(str);
+}
+
function pad(n: number) {
return StringPrototypePadStart(NumberPrototypeToString(n), 2, "0");
}
@@ -309,6 +318,7 @@ export default {
stripVTControlCharacters,
TextDecoder,
TextEncoder,
+ toUSVString,
log,
debuglog,
isDeepStrictEqual,