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 b1bfced

Browse filesBrowse 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 <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 6789663 commit b1bfced
Copy full SHA for b1bfced

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++) {
@@ -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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.