File tree Expand file tree Collapse file tree 3 files changed +14
-13
lines changed
Expand file tree Collapse file tree 3 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 8585 normalizeEncoding,
8686 kIsEncodingSymbol,
8787 defineLazyProperties,
88+ encodingsMap,
8889} = require ( 'internal/util' ) ;
8990const {
9091 isAnyArrayBuffer,
9596const {
9697inspect : utilInspect ,
9798} = require ( 'internal/util/inspect' ) ;
98- const { encodings } = internalBinding ( 'string_decoder' ) ;
9999
100100const {
101101codes : {
@@ -149,10 +149,6 @@ const constants = ObjectDefineProperties({},{
149149Buffer . poolSize = 8 * 1024 ;
150150let poolSize , poolOffset , allocPool ;
151151
152- const encodingsMap = { __proto__ : null } ;
153- for ( let i = 0 ; i < encodings . length ; ++ i )
154- encodingsMap [ encodings [ i ] ] = i ;
155-
156152function createPool ( ) {
157153poolSize = Buffer . poolSize ;
158154allocPool = createUnsafeBuffer ( poolSize ) . buffer ;
Original file line number Diff line number Diff line change 6565} = internalBinding ( 'util' ) ;
6666const { isNativeError, isPromise } = internalBinding ( 'types' ) ;
6767const { getOptionValue } = require ( 'internal/options' ) ;
68+ const { encodings } = internalBinding ( 'string_decoder' ) ;
6869
6970const noCrypto = ! process . versions . openssl ;
7071
@@ -859,6 +860,10 @@ class WeakReference{
859860}
860861}
861862
863+ const encodingsMap = { __proto__ : null } ;
864+ for ( let i = 0 ; i < encodings . length ; ++ i )
865+ encodingsMap [ encodings [ i ] ] = i ;
866+
862867module . exports = {
863868 getLazy,
864869 assertCrypto,
@@ -872,6 +877,7 @@ module.exports ={
872877 defineReplaceableLazyAttribute,
873878 deprecate,
874879 emitExperimentalWarning,
880+ encodingsMap,
875881 exposeInterface,
876882 exposeLazyInterfaces,
877883 exposeNamespace,
Original file line number Diff line number Diff line change @@ -38,15 +38,18 @@ const{
3838 kSize,
3939 decode,
4040 flush,
41- encodings,
4241} = internalBinding ( 'string_decoder' ) ;
43- const internalUtil = require ( 'internal/util' ) ;
42+ const {
43+ kIsEncodingSymbol,
44+ encodingsMap,
45+ normalizeEncoding : _normalizeEncoding ,
46+ } = require ( 'internal/util' ) ;
4447const {
4548ERR_INVALID_ARG_TYPE ,
4649ERR_INVALID_THIS ,
4750ERR_UNKNOWN_ENCODING ,
4851} = require ( 'internal/errors' ) . codes ;
49- const isEncoding = Buffer [ internalUtil . kIsEncodingSymbol ] ;
52+ const isEncoding = Buffer [ kIsEncodingSymbol ] ;
5053
5154const kNativeDecoder = Symbol ( 'kNativeDecoder' ) ;
5255
@@ -60,7 +63,7 @@ const kNativeDecoder = Symbol('kNativeDecoder');
6063 * @throws {TypeError } Throws an error when encoding is invalid
6164 */
6265function normalizeEncoding ( enc ) {
63- const nenc = internalUtil . normalizeEncoding ( enc ) ;
66+ const nenc = _normalizeEncoding ( enc ) ;
6467if ( nenc === undefined ) {
6568if ( Buffer . isEncoding === isEncoding || ! Buffer . isEncoding ( enc ) )
6669throw new ERR_UNKNOWN_ENCODING ( enc ) ;
@@ -69,10 +72,6 @@ function normalizeEncoding(enc){
6972return nenc ;
7073}
7174
72- const encodingsMap = { } ;
73- for ( let i = 0 ; i < encodings . length ; ++ i )
74- encodingsMap [ encodings [ i ] ] = i ;
75-
7675/**
7776 * StringDecoder provides an interface for efficiently splitting a series of
7877 * buffers into a series of JS strings without breaking apart multi-byte
You can’t perform that action at this time.
0 commit comments