mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
string_decoder: Migrate to use internal/errors
PR-URL: https://github.com/nodejs/node/pull/14682 Refs: https://github.com/nodejs/node/issues/11273 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
committed by
Ruben Bridgewater
parent
468110b327
commit
eb4940e2d2
@@ -23,6 +23,7 @@
|
||||
|
||||
const Buffer = require('buffer').Buffer;
|
||||
const internalUtil = require('internal/util');
|
||||
const errors = require('internal/errors');
|
||||
const isEncoding = Buffer[internalUtil.kIsEncodingSymbol];
|
||||
|
||||
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
||||
@@ -31,7 +32,7 @@ function normalizeEncoding(enc) {
|
||||
const nenc = internalUtil.normalizeEncoding(enc);
|
||||
if (typeof nenc !== 'string' &&
|
||||
(Buffer.isEncoding === isEncoding || !Buffer.isEncoding(enc)))
|
||||
throw new Error(`Unknown encoding: ${enc}`);
|
||||
throw new errors.TypeError('ERR_UNKNOWN_ENCODING', enc);
|
||||
return nenc || enc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user