| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a3feb15 commit e0b1f09
15 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -591,7 +591,6 @@ the error passed to the callback will be an `AbortError`: | |||
| 591 | 591 | ||
| 592 | 592 | ```cjs | |
| 593 | 593 | const { fork } = require('node:child_process'); | |
| 594 | - const process = require('node:process'); | ||
| 595 | 594 | ||
| 596 | 595 | if (process.argv[2] === 'child') { | |
| 597 | 596 | setTimeout(() => { | |
@@ -933,7 +932,6 @@ Example of a long-running process, by detaching and also ignoring its parent | |||
| 933 | 932 | ||
| 934 | 933 | ```cjs | |
| 935 | 934 | const { spawn } = require('node:child_process'); | |
| 936 | - const process = require('node:process'); | ||
| 937 | 935 | ||
| 938 | 936 | const subprocess = spawn(process.argv[0], ['child_program.js'], { | |
| 939 | 937 | detached: true, | |
@@ -1077,7 +1075,6 @@ pipes between the parent and child. The value is one of the following: | |||
| 1077 | 1075 | ||
| 1078 | 1076 | ```cjs | |
| 1079 | 1077 | const { spawn } = require('node:child_process'); | |
| 1080 | - const process = require('node:process'); | ||
| 1081 | 1078 | ||
| 1082 | 1079 | // Child will use parent's stdios. | |
| 1083 | 1080 | spawn('prg', [], { stdio: 'inherit' }); | |
@@ -1833,7 +1830,6 @@ process to wait for the child process to exit before exiting itself. | |||
| 1833 | 1830 | ||
| 1834 | 1831 | ```cjs | |
| 1835 | 1832 | const { spawn } = require('node:child_process'); | |
| 1836 | - const process = require('node:process'); | ||
| 1837 | 1833 | ||
| 1838 | 1834 | const subprocess = spawn(process.argv[0], ['child_program.js'], { | |
| 1839 | 1835 | detached: true, | |
@@ -2289,7 +2285,6 @@ the child and the parent processes. | |||
| 2289 | 2285 | ||
| 2290 | 2286 | ```cjs | |
| 2291 | 2287 | const { spawn } = require('node:child_process'); | |
| 2292 | - const process = require('node:process'); | ||
| 2293 | 2288 | ||
| 2294 | 2289 | const subprocess = spawn(process.argv[0], ['child_program.js'], { | |
| 2295 | 2290 | detached: true, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,6 @@ if (cluster.isPrimary) { | |||
| 49 | 49 | const cluster = require('node:cluster'); | |
| 50 | 50 | const http = require('node:http'); | |
| 51 | 51 | const numCPUs = require('node:os').availableParallelism(); | |
| 52 | - const process = require('node:process'); | ||
| 53 | 52 | ||
| 54 | 53 | if (cluster.isPrimary) { | |
| 55 | 54 | console.log(`Primary ${process.pid} is running`); | |
@@ -318,7 +317,6 @@ if (cluster.isPrimary) { | |||
| 318 | 317 | const cluster = require('node:cluster'); | |
| 319 | 318 | const http = require('node:http'); | |
| 320 | 319 | const numCPUs = require('node:os').availableParallelism(); | |
| 321 | - const process = require('node:process'); | ||
| 322 | 320 | ||
| 323 | 321 | if (cluster.isPrimary) { | |
| 324 | 322 | ||
@@ -541,7 +539,6 @@ if (cluster.isPrimary) { | |||
| 541 | 539 | const cluster = require('node:cluster'); | |
| 542 | 540 | const http = require('node:http'); | |
| 543 | 541 | const numCPUs = require('node:os').availableParallelism(); | |
| 544 | - const process = require('node:process'); | ||
| 545 | 542 | ||
| 546 | 543 | if (cluster.isPrimary) { | |
| 547 | 544 | console.log(`Primary ${process.pid} is running`); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1682,7 +1682,6 @@ setImmediate(() => { | |||
| 1682 | 1682 | ``` | |
| 1683 | 1683 | ||
| 1684 | 1684 | ```cjs | |
| 1685 | - 'use strict'; | ||
| 1686 | 1685 | const { eventLoopUtilization } = require('node:perf_hooks'); | |
| 1687 | 1686 | const { spawnSync } = require('node:child_process'); | |
| 1688 | 1687 | ||
@@ -2132,7 +2131,6 @@ setTimeout(() => {}, 1000); | |||
| 2132 | 2131 | ``` | |
| 2133 | 2132 | ||
| 2134 | 2133 | ```cjs | |
| 2135 | - 'use strict'; | ||
| 2136 | 2134 | const async_hooks = require('node:async_hooks'); | |
| 2137 | 2135 | const { | |
| 2138 | 2136 | performance, | |
@@ -2202,7 +2200,6 @@ await timedImport('some-module'); | |||
| 2202 | 2200 | <!-- eslint-disable no-global-assign --> | |
| 2203 | 2201 | ||
| 2204 | 2202 | ```cjs | |
| 2205 | - 'use strict'; | ||
| 2206 | 2203 | const { | |
| 2207 | 2204 | performance, | |
| 2208 | 2205 | PerformanceObserver, | |
@@ -2259,7 +2256,6 @@ createServer((req, res) => { | |||
| 2259 | 2256 | ``` | |
| 2260 | 2257 | ||
| 2261 | 2258 | ```cjs | |
| 2262 | - 'use strict'; | ||
| 2263 | 2259 | const { PerformanceObserver } = require('node:perf_hooks'); | |
| 2264 | 2260 | const http = require('node:http'); | |
| 2265 | 2261 | ||
@@ -2301,7 +2297,6 @@ createServer((socket) => { | |||
| 2301 | 2297 | ``` | |
| 2302 | 2298 | ||
| 2303 | 2299 | ```cjs | |
| 2304 | - 'use strict'; | ||
| 2305 | 2300 | const { PerformanceObserver } = require('node:perf_hooks'); | |
| 2306 | 2301 | const net = require('node:net'); | |
| 2307 | 2302 | const obs = new PerformanceObserver((items) => { | |
@@ -2335,7 +2330,6 @@ promises.resolve('localhost'); | |||
| 2335 | 2330 | ``` | |
| 2336 | 2331 | ||
| 2337 | 2332 | ```cjs | |
| 2338 | - 'use strict'; | ||
| 2339 | 2333 | const { PerformanceObserver } = require('node:perf_hooks'); | |
| 2340 | 2334 | const dns = require('node:dns'); | |
| 2341 | 2335 | const obs = new PerformanceObserver((items) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,8 @@ Node.js process. | |||
| 13 | 13 | import process from 'node:process'; | |
| 14 | 14 | ``` | |
| 15 | 15 | ||
| 16 | + <!-- eslint-disable no-restricted-syntax --> | ||
| 17 | + | ||
| 16 | 18 | ```cjs | |
| 17 | 19 | const process = require('node:process'); | |
| 18 | 20 | ``` | |
@@ -62,8 +64,6 @@ console.log('This message is displayed first.'); | |||
| 62 | 64 | ``` | |
| 63 | 65 | ||
| 64 | 66 | ```cjs | |
| 65 | - const process = require('node:process'); | ||
| 66 | - | ||
| 67 | 67 | process.on('beforeExit', (code) => { | |
| 68 | 68 | console.log('Process beforeExit event with code: ', code); | |
| 69 | 69 | }); | |
@@ -120,8 +120,6 @@ process.on('exit', (code) => { | |||
| 120 | 120 | ``` | |
| 121 | 121 | ||
| 122 | 122 | ```cjs | |
| 123 | - const process = require('node:process'); | ||
| 124 | - | ||
| 125 | 123 | process.on('exit', (code) => { | |
| 126 | 124 | console.log(`About to exit with code: ${code}`); | |
| 127 | 125 | }); | |
@@ -143,8 +141,6 @@ process.on('exit', (code) => { | |||
| 143 | 141 | ``` | |
| 144 | 142 | ||
| 145 | 143 | ```cjs | |
| 146 | - const process = require('node:process'); | ||
| 147 | - | ||
| 148 | 144 | process.on('exit', (code) => { | |
| 149 | 145 | setTimeout(() => { | |
| 150 | 146 | console.log('This will not run'); | |
@@ -221,8 +217,6 @@ process.on('rejectionHandled', (promise) => { | |||
| 221 | 217 | ``` | |
| 222 | 218 | ||
| 223 | 219 | ```cjs | |
| 224 | - const process = require('node:process'); | ||
| 225 | - | ||
| 226 | 220 | const unhandledRejections = new Map(); | |
| 227 | 221 | process.on('unhandledRejection', (reason, promise) => { | |
| 228 | 222 | unhandledRejections.set(promise, reason); | |
@@ -305,7 +299,6 @@ console.log('This will not run.'); | |||
| 305 | 299 | ``` | |
| 306 | 300 | ||
| 307 | 301 | ```cjs | |
| 308 | - const process = require('node:process'); | ||
| 309 | 302 | const fs = require('node:fs'); | |
| 310 | 303 | ||
| 311 | 304 | process.on('uncaughtException', (err, origin) => { | |
@@ -394,8 +387,6 @@ nonexistentFunc(); | |||
| 394 | 387 | ``` | |
| 395 | 388 | ||
| 396 | 389 | ```cjs | |
| 397 | - const process = require('node:process'); | ||
| 398 | - | ||
| 399 | 390 | process.on('uncaughtExceptionMonitor', (err, origin) => { | |
| 400 | 391 | MyMonitoringTool.logSync(err, origin); | |
| 401 | 392 | }); | |
@@ -445,8 +436,6 @@ somePromise.then((res) => { | |||
| 445 | 436 | ``` | |
| 446 | 437 | ||
| 447 | 438 | ```cjs | |
| 448 | - const process = require('node:process'); | ||
| 449 | - | ||
| 450 | 439 | process.on('unhandledRejection', (reason, promise) => { | |
| 451 | 440 | console.log('Unhandled Rejection at:', promise, 'reason:', reason); | |
| 452 | 441 | // Application specific logging, throwing an error, or other logic here | |
@@ -473,8 +462,6 @@ const resource = new SomeResource(); | |||
| 473 | 462 | ``` | |
| 474 | 463 | ||
| 475 | 464 | ```cjs | |
| 476 | - const process = require('node:process'); | ||
| 477 | - | ||
| 478 | 465 | function SomeResource() { | |
| 479 | 466 | // Initially set the loaded status to a rejected promise | |
| 480 | 467 | this.loaded = Promise.reject(new Error('Resource not yet loaded!')); | |
@@ -526,8 +513,6 @@ process.on('warning', (warning) => { | |||
| 526 | 513 | ``` | |
| 527 | 514 | ||
| 528 | 515 | ```cjs | |
| 529 | - const process = require('node:process'); | ||
| 530 | - | ||
| 531 | 516 | process.on('warning', (warning) => { | |
| 532 | 517 | console.warn(warning.name); // Print the warning name | |
| 533 | 518 | console.warn(warning.message); // Print the warning message | |
@@ -663,8 +648,6 @@ process.on('SIGTERM', handle); | |||
| 663 | 648 | ``` | |
| 664 | 649 | ||
| 665 | 650 | ```cjs | |
| 666 | - const process = require('node:process'); | ||
| 667 | - | ||
| 668 | 651 | // Begin reading from stdin so the process does not exit. | |
| 669 | 652 | process.stdin.resume(); | |
| 670 | 653 | ||
@@ -766,8 +749,6 @@ process.addUncaughtExceptionCaptureCallback((err) => { | |||
| 766 | 749 | ``` | |
| 767 | 750 | ||
| 768 | 751 | ```cjs | |
| 769 | - const process = require('node:process'); | ||
| 770 | - | ||
| 771 | 752 | process.addUncaughtExceptionCaptureCallback((err) => { | |
| 772 | 753 | console.error('Caught exception:', err.message); | |
| 773 | 754 | return true; // Indicates exception was handled | |
@@ -1217,8 +1198,6 @@ process.debugPort = 5858; | |||
| 1217 | 1198 | ``` | |
| 1218 | 1199 | ||
| 1219 | 1200 | ```cjs | |
| 1220 | - const process = require('node:process'); | ||
| 1221 | - | ||
| 1222 | 1201 | process.debugPort = 5858; | |
| 1223 | 1202 | ``` | |
| 1224 | 1203 | ||
@@ -1355,8 +1334,6 @@ process.on('warning', (warning) => { | |||
| 1355 | 1334 | ``` | |
| 1356 | 1335 | ||
| 1357 | 1336 | ```cjs | |
| 1358 | - const process = require('node:process'); | ||
| 1359 | - | ||
| 1360 | 1337 | process.on('warning', (warning) => { | |
| 1361 | 1338 | console.warn(warning.name); // 'Warning' | |
| 1362 | 1339 | console.warn(warning.message); // 'Something happened!' | |
@@ -1448,8 +1425,6 @@ process.on('warning', (warning) => { | |||
| 1448 | 1425 | ``` | |
| 1449 | 1426 | ||
| 1450 | 1427 | ```cjs | |
| 1451 | - const process = require('node:process'); | ||
| 1452 | - | ||
| 1453 | 1428 | process.on('warning', (warning) => { | |
| 1454 | 1429 | console.warn(warning.name); | |
| 1455 | 1430 | console.warn(warning.message); | |
@@ -1865,8 +1840,6 @@ if (someConditionNotMet()) { | |||
| 1865 | 1840 | ``` | |
| 1866 | 1841 | ||
| 1867 | 1842 | ```cjs | |
| 1868 | - const process = require('node:process'); | ||
| 1869 | - | ||
| 1870 | 1843 | // How to properly set the exit code while letting | |
| 1871 | 1844 | // the process exit gracefully. | |
| 1872 | 1845 | if (someConditionNotMet()) { | |
@@ -2408,8 +2381,6 @@ if (process.getegid) { | |||
| 2408 | 2381 | ``` | |
| 2409 | 2382 | ||
| 2410 | 2383 | ```cjs | |
| 2411 | - const process = require('node:process'); | ||
| 2412 | - | ||
| 2413 | 2384 | if (process.getegid) { | |
| 2414 | 2385 | console.log(`Current gid: ${process.getegid()}`); | |
| 2415 | 2386 | } | |
@@ -2438,8 +2409,6 @@ if (process.geteuid) { | |||
| 2438 | 2409 | ``` | |
| 2439 | 2410 | ||
| 2440 | 2411 | ```cjs | |
| 2441 | - const process = require('node:process'); | ||
| 2442 | - | ||
| 2443 | 2412 | if (process.geteuid) { | |
| 2444 | 2413 | console.log(`Current uid: ${process.geteuid()}`); | |
| 2445 | 2414 | } | |
@@ -2468,8 +2437,6 @@ if (process.getgid) { | |||
| 2468 | 2437 | ``` | |
| 2469 | 2438 | ||
| 2470 | 2439 | ```cjs | |
| 2471 | - const process = require('node:process'); | ||
| 2472 | - | ||
| 2473 | 2440 | if (process.getgid) { | |
| 2474 | 2441 | console.log(`Current gid: ${process.getgid()}`); | |
| 2475 | 2442 | } | |
@@ -2499,8 +2466,6 @@ if (process.getgroups) { | |||
| 2499 | 2466 | ``` | |
| 2500 | 2467 | ||
| 2501 | 2468 | ```cjs | |
| 2502 | - const process = require('node:process'); | ||
| 2503 | - | ||
| 2504 | 2469 | if (process.getgroups) { | |
| 2505 | 2470 | console.log(process.getgroups()); // [ 16, 21, 297 ] | |
| 2506 | 2471 | } | |
@@ -2529,8 +2494,6 @@ if (process.getuid) { | |||
| 2529 | 2494 | ``` | |
| 2530 | 2495 | ||
| 2531 | 2496 | ```cjs | |
| 2532 | - const process = require('node:process'); | ||
| 2533 | - | ||
| 2534 | 2497 | if (process.getuid) { | |
| 2535 | 2498 | console.log(`Current uid: ${process.getuid()}`); | |
| 2536 | 2499 | } | |
@@ -2735,8 +2698,6 @@ kill(process.pid, 'SIGHUP'); | |||
| 2735 | 2698 | ``` | |
| 2736 | 2699 | ||
| 2737 | 2700 | ```cjs | |
| 2738 | - const process = require('node:process'); | ||
| 2739 | - | ||
| 2740 | 2701 | process.on('SIGHUP', () => { | |
| 2741 | 2702 | console.log('Got SIGHUP signal.'); | |
| 2742 | 2703 | }); | |
@@ -3852,8 +3813,6 @@ if (process.getegid && process.setegid) { | |||
| 3852 | 3813 | ``` | |
| 3853 | 3814 | ||
| 3854 | 3815 | ```cjs | |
| 3855 | - const process = require('node:process'); | ||
| 3856 | - | ||
| 3857 | 3816 | if (process.getegid && process.setegid) { | |
| 3858 | 3817 | console.log(`Current gid: ${process.getegid()}`); | |
| 3859 | 3818 | try { | |
@@ -3897,8 +3856,6 @@ if (process.geteuid && process.seteuid) { | |||
| 3897 | 3856 | ``` | |
| 3898 | 3857 | ||
| 3899 | 3858 | ```cjs | |
| 3900 | - const process = require('node:process'); | ||
| 3901 | - | ||
| 3902 | 3859 | if (process.geteuid && process.seteuid) { | |
| 3903 | 3860 | console.log(`Current uid: ${process.geteuid()}`); | |
| 3904 | 3861 | try { | |
@@ -3942,8 +3899,6 @@ if (process.getgid && process.setgid) { | |||
| 3942 | 3899 | ``` | |
| 3943 | 3900 | ||
| 3944 | 3901 | ```cjs | |
| 3945 | - const process = require('node:process'); | ||
| 3946 | - | ||
| 3947 | 3902 | if (process.getgid && process.setgid) { | |
| 3948 | 3903 | console.log(`Current gid: ${process.getgid()}`); | |
| 3949 | 3904 | try { | |
@@ -3987,8 +3942,6 @@ if (process.getgroups && process.setgroups) { | |||
| 3987 | 3942 | ``` | |
| 3988 | 3943 | ||
| 3989 | 3944 | ```cjs | |
| 3990 | - const process = require('node:process'); | ||
| 3991 | - | ||
| 3992 | 3945 | if (process.getgroups && process.setgroups) { | |
| 3993 | 3946 | try { | |
| 3994 | 3947 | process.setgroups([501]); | |
@@ -4031,8 +3984,6 @@ if (process.getuid && process.setuid) { | |||
| 4031 | 3984 | ``` | |
| 4032 | 3985 | ||
| 4033 | 3986 | ```cjs | |
| 4034 | - const process = require('node:process'); | ||
| 4035 | - | ||
| 4036 | 3987 | if (process.getuid && process.setuid) { | |
| 4037 | 3988 | console.log(`Current uid: ${process.getuid()}`); | |
| 4038 | 3989 | try { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,6 @@ console.log(query.all()); | |||
| 59 | 59 | ``` | |
| 60 | 60 | ||
| 61 | 61 | ```cjs | |
| 62 | - 'use strict'; | ||
| 63 | 62 | const { DatabaseSync } = require('node:sqlite'); | |
| 64 | 63 | const database = new DatabaseSync(':memory:'); | |
| 65 | 64 | ||
@@ -325,7 +324,6 @@ database.loadExtension('./base64.dylib', 'sqlite3_base64_init'); | |||
| 325 | 324 | ``` | |
| 326 | 325 | ||
| 327 | 326 | ```cjs | |
| 328 | - 'use strict'; | ||
| 329 | 327 | const { DatabaseSync } = require('node:sqlite'); | |
| 330 | 328 | const database = new DatabaseSync(':memory:', { allowExtension: true }); | |
| 331 | 329 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -851,7 +851,6 @@ test('spies on a function', () => { | |||
| 851 | 851 | ``` | |
| 852 | 852 | ||
| 853 | 853 | ```cjs | |
| 854 | - 'use strict'; | ||
| 855 | 854 | const assert = require('node:assert'); | |
| 856 | 855 | const { mock, test } = require('node:test'); | |
| 857 | 856 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -326,8 +326,6 @@ collect(); | |||
| 326 | 326 | ``` | |
| 327 | 327 | ||
| 328 | 328 | ```cjs | |
| 329 | - 'use strict'; | ||
| 330 | - | ||
| 331 | 329 | const { Session } = require('node:inspector'); | |
| 332 | 330 | const session = new Session(); | |
| 333 | 331 | session.connect(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments