deno.land / std@0.166.0 / node / internal / process / per_thread.mjs

per_thread.mjs
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.// Copyright Joyent, Inc. and Node.js contributors. All rights reserved. MIT license.
const kInternal = Symbol("internal properties");
const replaceUnderscoresRegex = /_/g;const leadingDashesRegex = /^--?/;const trailingValuesRegex = /=.*$/;
// This builds the initial process.allowedNodeEnvironmentFlags// from data in the config binding.export function buildAllowedFlags() { const allowedNodeEnvironmentFlags = [ "--track-heap-objects", "--no-track-heap-objects", "--node-snapshot", "--no-node-snapshot", "--require", "--max-old-space-size", "--trace-exit", "--no-trace-exit", "--disallow-code-generation-from-strings", "--experimental-json-modules", "--no-experimental-json-modules", "--interpreted-frames-native-stack", "--inspect-brk", "--no-inspect-brk", "--trace-tls", "--no-trace-tls", "--stack-trace-limit", "--experimental-repl-await", "--no-experimental-repl-await", "--preserve-symlinks", "--no-preserve-symlinks", "--report-uncaught-exception", "--no-report-uncaught-exception", "--experimental-modules", "--no-experimental-modules", "--report-signal", "--jitless", "--inspect-port", "--heapsnapshot-near-heap-limit", "--tls-keylog", "--force-context-aware", "--no-force-context-aware", "--napi-modules", "--abort-on-uncaught-exception", "--diagnostic-dir", "--verify-base-objects", "--no-verify-base-objects", "--unhandled-rejections", "--perf-basic-prof", "--trace-atomics-wait", "--no-trace-atomics-wait", "--deprecation", "--no-deprecation", "--perf-basic-prof-only-functions", "--perf-prof", "--max-http-header-size", "--report-on-signal", "--no-report-on-signal", "--throw-deprecation", "--no-throw-deprecation", "--warnings", "--no-warnings", "--force-fips", "--no-force-fips", "--pending-deprecation", "--no-pending-deprecation", "--input-type", "--tls-max-v1.3", "--no-tls-max-v1.3", "--tls-min-v1.2", "--no-tls-min-v1.2", "--inspect", "--no-inspect", "--heapsnapshot-signal", "--trace-warnings", "--no-trace-warnings", "--trace-event-categories", "--experimental-worker", "--tls-max-v1.2", "--no-tls-max-v1.2", "--perf-prof-unwinding-info", "--preserve-symlinks-main", "--no-preserve-symlinks-main", "--policy-integrity", "--experimental-wasm-modules", "--no-experimental-wasm-modules", "--node-memory-debug", "--inspect-publish-uid", "--tls-min-v1.3", "--no-tls-min-v1.3", "--experimental-specifier-resolution", "--secure-heap", "--tls-min-v1.0", "--no-tls-min-v1.0", "--redirect-warnings", "--experimental-report", "--trace-event-file-pattern", "--trace-uncaught", "--no-trace-uncaught", "--experimental-loader", "--http-parser", "--dns-result-order", "--trace-sigint", "--no-trace-sigint", "--secure-heap-min", "--enable-fips", "--no-enable-fips", "--enable-source-maps", "--no-enable-source-maps", "--insecure-http-parser", "--no-insecure-http-parser", "--use-openssl-ca", "--no-use-openssl-ca", "--tls-cipher-list", "--experimental-top-level-await", "--no-experimental-top-level-await", "--openssl-config", "--icu-data-dir", "--v8-pool-size", "--report-on-fatalerror", "--no-report-on-fatalerror", "--title", "--tls-min-v1.1", "--no-tls-min-v1.1", "--report-filename", "--trace-deprecation", "--no-trace-deprecation", "--report-compact", "--no-report-compact", "--experimental-policy", "--experimental-import-meta-resolve", "--no-experimental-import-meta-resolve", "--zero-fill-buffers", "--no-zero-fill-buffers", "--report-dir", "--use-bundled-ca", "--no-use-bundled-ca", "--experimental-vm-modules", "--no-experimental-vm-modules", "--force-async-hooks-checks", "--no-force-async-hooks-checks", "--frozen-intrinsics", "--no-frozen-intrinsics", "--huge-max-old-generation-size", "--disable-proto", "--debug-arraybuffer-allocations", "--no-debug-arraybuffer-allocations", "--conditions", "--experimental-wasi-unstable-preview1", "--no-experimental-wasi-unstable-preview1", "--trace-sync-io", "--no-trace-sync-io", "--use-largepages", "--experimental-abortcontroller", "--debug-port", "--es-module-specifier-resolution", "--prof-process", "-C", "--loader", "--report-directory", "-r", "--trace-events-enabled", ];
/* function isAccepted(to) { if (!to.startsWith("-") || to === "--") return true; const recursiveExpansion = aliases.get(to); if (recursiveExpansion) { if (recursiveExpansion[0] === to) { recursiveExpansion.splice(0, 1); } return recursiveExpansion.every(isAccepted); } return options.get(to).envVarSettings === kAllowedInEnvironment; } for (const { 0: from, 1: expansion } of aliases) { if (expansion.every(isAccepted)) { let canonical = from; if (canonical.endsWith("=")) { canonical = canonical.slice(0, canonical.length - 1); } if (canonical.endsWith(" <arg>")) { canonical = canonical.slice(0, canonical.length - 4); } allowedNodeEnvironmentFlags.push(canonical); } } */
const trimLeadingDashes = (flag) => flag.replace(leadingDashesRegex, "");
// Save these for comparison against flags provided to // process.allowedNodeEnvironmentFlags.has() which lack leading dashes. const nodeFlags = allowedNodeEnvironmentFlags.map(trimLeadingDashes);
class NodeEnvironmentFlagsSet extends Set { constructor(array) { super(); this[kInternal] = { array }; }
add() { // No-op, `Set` API compatible return this; }
delete() { // No-op, `Set` API compatible return false; }
clear() { // No-op, `Set` API compatible }
has(key) { // This will return `true` based on various possible // permutations of a flag, including present/missing leading // dash(es) and/or underscores-for-dashes. // Strips any values after `=`, inclusive. // TODO(addaleax): It might be more flexible to run the option parser // on a dummy option set and see whether it rejects the argument or // not. if (typeof key === "string") { key = key.replace(replaceUnderscoresRegex, "-"); if (leadingDashesRegex.test(key)) { key = key.replace(trailingValuesRegex, ""); return this[kInternal].array.includes(key); } return nodeFlags.includes(key); } return false; }
entries() { this[kInternal].set ??= new Set(this[kInternal].array); return this[kInternal].set.entries(); }
forEach(callback, thisArg = undefined) { this[kInternal].array.forEach((v) => Reflect.apply(callback, thisArg, [v, v, this]) ); }
get size() { return this[kInternal].array.length; }
values() { this[kInternal].set ??= new Set(this[kInternal].array); return this[kInternal].set.values(); } } NodeEnvironmentFlagsSet.prototype.keys = NodeEnvironmentFlagsSet .prototype[Symbol.iterator] = NodeEnvironmentFlagsSet.prototype.values;
Object.freeze(NodeEnvironmentFlagsSet.prototype.constructor); Object.freeze(NodeEnvironmentFlagsSet.prototype);
return Object.freeze( new NodeEnvironmentFlagsSet( allowedNodeEnvironmentFlags, ), );}
std

Version Info

Tagged at
a year ago