Skip to content

Commit 81dc7ff

Browse files
committed
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. Refs: #9036
1 parent 1b093cb commit 81dc7ff

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
}
@@ -120,6 +122,14 @@ function normalizeEncoding(enc) {
120122
}
121123
}
122124

125+
function emitExperimentalWarning(feature) {
126+
if (experimentalWarnings.has(feature)) return;
127+
const msg = `${feature} is an experimental feature. This feature could ` +
128+
'change at any time';
129+
experimentalWarnings.add(feature);
130+
process.emitWarning(msg, 'ExperimentalWarning');
131+
}
132+
123133
function filterDuplicateStrings(items, low) {
124134
const map = new Map();
125135
for (var i = 0; i < items.length; i++) {
@@ -290,6 +300,7 @@ module.exports = {
290300
createClassWrapper,
291301
decorateErrorStack,
292302
deprecate,
303+
emitExperimentalWarning,
293304
filterDuplicateStrings,
294305
getConstructorOf,
295306
isError,

0 commit comments

Comments
 (0)