Skip to content

Commit b08c732

Browse files
codeman869targos
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 e5d4aeb commit b08c732

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
@@ -15,6 +15,8 @@ const {
1515

1616
const noCrypto = !process.versions.openssl;
1717

18+
const experimentalWarnings = new Set();
19+
1820
function isError(e) {
1921
return objectToString(e) === '[object Error]' || e instanceof Error;
2022
}
@@ -127,6 +129,14 @@ function normalizeEncoding(enc) {
127129
}
128130
}
129131

132+
function emitExperimentalWarning(feature) {
133+
if (experimentalWarnings.has(feature)) return;
134+
const msg = `${feature} is an experimental feature. This feature could ` +
135+
'change at any time';
136+
experimentalWarnings.add(feature);
137+
process.emitWarning(msg, 'ExperimentalWarning');
138+
}
139+
130140
function filterDuplicateStrings(items, low) {
131141
const map = new Map();
132142
for (var i = 0; i < items.length; i++) {
@@ -297,6 +307,7 @@ module.exports = {
297307
createClassWrapper,
298308
decorateErrorStack,
299309
deprecate,
310+
emitExperimentalWarning,
300311
filterDuplicateStrings,
301312
getConstructorOf,
302313
isError,

0 commit comments

Comments
 (0)