Skip to content

Commit e6a568b

Browse files
codeman869gibfahn
authored andcommitted
internal: add emitExperimentalWarning function
Adds a new emitExperimentalWarning function to internal/util to warn users that they are using an experimental feature and that feature can change at any time. PR-URL: #16497 Refs: #9036 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent b18cd4e commit e6a568b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎lib/internal/util.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
1010
constkDecoratedPrivateSymbolIndex=binding['decorated_private_symbol'];
1111
constnoCrypto=!process.versions.openssl;
1212

13+
constexperimentalWarnings=newSet();
14+
1315
functionisError(e){
1416
returnobjectToString(e)==='[object Error]'||einstanceofError;
1517
}
@@ -115,6 +117,14 @@ function normalizeEncoding(enc){
115117
}
116118
}
117119

120+
functionemitExperimentalWarning(feature){
121+
if(experimentalWarnings.has(feature))return;
122+
constmsg=`${feature} is an experimental feature. This feature could `+
123+
'change at any time';
124+
experimentalWarnings.add(feature);
125+
process.emitWarning(msg,'ExperimentalWarning');
126+
}
127+
118128
functionfilterDuplicateStrings(items,low){
119129
constmap=newMap();
120130
for(vari=0;i<items.length;i++){
@@ -280,6 +290,7 @@ module.exports ={
280290
createClassWrapper,
281291
decorateErrorStack,
282292
deprecate,
293+
emitExperimentalWarning,
283294
filterDuplicateStrings,
284295
getConstructorOf,
285296
isError,

0 commit comments

Comments
(0)