Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8fd316f

Browse filesBrowse 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 <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 821951e commit 8fd316f
Copy full SHA for 8fd316f

File tree

Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/util.js
+11Lines 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
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.