diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index b221b084275867..4936ab761ddccb 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -140,6 +140,7 @@ const assert = require('internal/assert'); const { NativeModule } = require('internal/bootstrap/loaders'); const { validateObject, + validateString, } = require('internal/validators'); let hexSlice; @@ -2114,9 +2115,7 @@ if (internalBinding('config').hasIntl) { * Remove all VT control characters. Use to estimate displayed string width. */ function stripVTControlCharacters(str) { - if (typeof str !== 'string') { - throw new ERR_INVALID_ARG_TYPE('str', 'string', str); - } + validateString(str, 'str'); return str.replace(ansi, ''); }