@@ -38,15 +38,18 @@ const {
38
38
kSize,
39
39
decode,
40
40
flush,
41
- encodings,
42
41
} = internalBinding ( 'string_decoder' ) ;
43
- const internalUtil = require ( 'internal/util' ) ;
42
+ const {
43
+ kIsEncodingSymbol,
44
+ encodingsMap,
45
+ normalizeEncoding : _normalizeEncoding ,
46
+ } = require ( 'internal/util' ) ;
44
47
const {
45
48
ERR_INVALID_ARG_TYPE ,
46
49
ERR_INVALID_THIS ,
47
50
ERR_UNKNOWN_ENCODING ,
48
51
} = require ( 'internal/errors' ) . codes ;
49
- const isEncoding = Buffer [ internalUtil . kIsEncodingSymbol ] ;
52
+ const isEncoding = Buffer [ kIsEncodingSymbol ] ;
50
53
51
54
const kNativeDecoder = Symbol ( 'kNativeDecoder' ) ;
52
55
@@ -60,7 +63,7 @@ const kNativeDecoder = Symbol('kNativeDecoder');
60
63
* @throws {TypeError } Throws an error when encoding is invalid
61
64
*/
62
65
function normalizeEncoding ( enc ) {
63
- const nenc = internalUtil . normalizeEncoding ( enc ) ;
66
+ const nenc = _normalizeEncoding ( enc ) ;
64
67
if ( nenc === undefined ) {
65
68
if ( Buffer . isEncoding === isEncoding || ! Buffer . isEncoding ( enc ) )
66
69
throw new ERR_UNKNOWN_ENCODING ( enc ) ;
@@ -69,10 +72,6 @@ function normalizeEncoding(enc) {
69
72
return nenc ;
70
73
}
71
74
72
- const encodingsMap = { } ;
73
- for ( let i = 0 ; i < encodings . length ; ++ i )
74
- encodingsMap [ encodings [ i ] ] = i ;
75
-
76
75
/**
77
76
* StringDecoder provides an interface for efficiently splitting a series of
78
77
* buffers into a series of JS strings without breaking apart multi-byte
0 commit comments