@@ -118,16 +118,17 @@ function setupConfig(_source) {
118118 return value ;
119119 } ) ;
120120 const processConfig = process . binding ( 'config' ) ;
121- // Intl.v8BreakIterator() would crash w/ fatal error, so throw instead.
122- if ( processConfig . hasIntl &&
123- processConfig . hasSmallICU &&
124- Intl . hasOwnProperty ( 'v8BreakIterator' ) &&
125- ! process . icu_data_dir ) {
121+ if ( typeof Intl !== 'undefined' && Intl . hasOwnProperty ( 'v8BreakIterator' ) ) {
122+ const oldV8BreakIterator = Intl . v8BreakIterator ;
126123 const des = Object . getOwnPropertyDescriptor ( Intl , 'v8BreakIterator' ) ;
127- des . value = function v8BreakIterator ( ) {
128- throw new Error ( 'v8BreakIterator: full ICU data not installed. ' +
129- 'See https://github.com/nodejs/node/wiki/Intl' ) ;
130- } ;
124+ des . value = require ( 'internal/util' ) . deprecate ( function v8BreakIterator ( ) {
125+ if ( processConfig . hasSmallICU && ! process . icu_data_dir ) {
126+ // Intl.v8BreakIterator() would crash w/ fatal error, so throw instead.
127+ throw new Error ( 'v8BreakIterator: full ICU data not installed. ' +
128+ 'See https://github.com/nodejs/node/wiki/Intl' ) ;
129+ }
130+ return Reflect . construct ( oldV8BreakIterator , arguments ) ;
131+ } , 'Intl.v8BreakIterator is deprecated and will be removed soon.' ) ;
131132 Object . defineProperty ( Intl , 'v8BreakIterator' , des ) ;
132133 }
133134 // Don’t let icu_data_dir leak through.
0 commit comments