diff --git a/doc/api/process.md b/doc/api/process.md index 0c35007103c253..5aec229e9e8ed9 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -416,6 +416,55 @@ generate a core file. This feature is not available in [`Worker`][] threads. +## process.allowedNodeEnvironmentFlags + + +* {Set} + +The `process.allowedNodeEnvironmentFlags` property is a special, +read-only `Set` of flags allowable within the [`NODE_OPTIONS`][] +environment variable. + +`process.allowedNodeEnvironmentFlags` extends `Set`, but overrides +`Set.prototype.has` to recognize several different possible flag +representations. `process.allowedNodeEnvironmentFlags.has()` will +return `true` in the following cases: + +- Flags may omit leading single (`-`) or double (`--`) dashes; e.g., + `inspect-brk` for `--inspect-brk`, or `r` for `-r`. +- Flags passed through to V8 (as listed in `--v8-options`) may replace + one or more *non-leading* dashes for an underscore, or vice-versa; + e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`, + etc. +- Flags may contain one or more equals (`=`) characters; all + characters after and including the first equals will be ignored; + e.g., `--stack-trace-limit=100`. +- Flags *must* be allowable within [`NODE_OPTIONS`][]. + +When iterating over `process.allowedNodeEnvironmentFlags`, flags will +appear only *once*; each will begin with one or more dashes. Flags +passed through to V8 will contain underscores instead of non-leading +dashes: + +```js +process.allowedNodeEnvironmentFlags.forEach((flag) => { + // -r + // --inspect-brk + // --abort_on_uncaught_exception + // ... +}); +``` + +The methods `add()`, `clear()`, and `delete()` of +`process.allowedNodeEnvironmentFlags` do nothing, and will fail +silently. + +If Node.js was compiled *without* [`NODE_OPTIONS`][] support (shown in +[`process.config`][]), `process.allowedNodeEnvironmentFlags` will +contain what *would have* been allowable. + ## process.arch