Skip to content

Commit 8fd316f

Browse files
codeman869MylesBorins
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 821951e commit 8fd316f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/internal/util.js

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
1010
const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
1111
const noCrypto = !process.versions.openssl;
1212

13+
const experimentalWarnings = new Set();
14+
1315
function isError(e) {
1416
return objectToString(e) === '[object Error]' || e instanceof Error;
1517
}
@@ -115,6 +117,14 @@ function normalizeEncoding(enc) {
115117
}
116118
}
117119

120+
function emitExperimentalWarning(feature) {
121+
if (experimentalWarnings.has(feature)) return;
122+
const msg = `${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
function filterDuplicateStrings(items, low) {
119129
const map = new Map();
120130
for (var i = 0; i < items.length; i++) {
@@ -285,6 +295,7 @@ module.exports = {
285295
createClassWrapper,
286296
decorateErrorStack,
287297
deprecate,
298+
emitExperimentalWarning,
288299
filterDuplicateStrings,
289300
getConstructorOf,
290301
isError,

0 commit comments

Comments
 (0)