| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 64c23da commit 54e2167
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -353,7 +353,6 @@ process.on('exit', () => { | |||
| 353 | 353 | ||
| 354 | 354 | ```cjs | |
| 355 | 355 | const assert = require('node:assert'); | |
| 356 | - const process = require('node:process'); | ||
| 357 | 356 | ||
| 358 | 357 | const tracker = new assert.CallTracker(); | |
| 359 | 358 | ||
| 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 | |
|---|---|---|---|
@@ -1678,7 +1678,6 @@ setImmediate(() => { | |||
| 1678 | 1678 | ``` | |
| 1679 | 1679 | ||
| 1680 | 1680 | ```cjs | |
| 1681 | - 'use strict'; | ||
| 1682 | 1681 | const { eventLoopUtilization } = require('node:perf_hooks'); | |
| 1683 | 1682 | const { spawnSync } = require('node:child_process'); | |
| 1684 | 1683 | ||
@@ -2126,7 +2125,6 @@ setTimeout(() => {}, 1000); | |||
| 2126 | 2125 | ``` | |
| 2127 | 2126 | ||
| 2128 | 2127 | ```cjs | |
| 2129 | - 'use strict'; | ||
| 2130 | 2128 | const async_hooks = require('node:async_hooks'); | |
| 2131 | 2129 | const { | |
| 2132 | 2130 | performance, | |
@@ -2194,7 +2192,6 @@ await timedImport('some-module'); | |||
| 2194 | 2192 | <!-- eslint-disable no-global-assign --> | |
| 2195 | 2193 | ||
| 2196 | 2194 | ```cjs | |
| 2197 | - 'use strict'; | ||
| 2198 | 2195 | const { | |
| 2199 | 2196 | performance, | |
| 2200 | 2197 | PerformanceObserver, | |
@@ -2251,7 +2248,6 @@ createServer((req, res) => { | |||
| 2251 | 2248 | ``` | |
| 2252 | 2249 | ||
| 2253 | 2250 | ```cjs | |
| 2254 | - 'use strict'; | ||
| 2255 | 2251 | const { PerformanceObserver } = require('node:perf_hooks'); | |
| 2256 | 2252 | const http = require('node:http'); | |
| 2257 | 2253 | ||
@@ -2293,7 +2289,6 @@ createServer((socket) => { | |||
| 2293 | 2289 | ``` | |
| 2294 | 2290 | ||
| 2295 | 2291 | ```cjs | |
| 2296 | - 'use strict'; | ||
| 2297 | 2292 | const { PerformanceObserver } = require('node:perf_hooks'); | |
| 2298 | 2293 | const net = require('node:net'); | |
| 2299 | 2294 | const obs = new PerformanceObserver((items) => { | |
@@ -2327,7 +2322,6 @@ promises.resolve('localhost'); | |||
| 2327 | 2322 | ``` | |
| 2328 | 2323 | ||
| 2329 | 2324 | ```cjs | |
| 2330 | - 'use strict'; | ||
| 2331 | 2325 | const { PerformanceObserver } = require('node:perf_hooks'); | |
| 2332 | 2326 | const dns = require('node:dns'); | |
| 2333 | 2327 | 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'); | |
@@ -237,8 +233,6 @@ main().then(console.log); | |||
| 237 | 233 | ``` | |
| 238 | 234 | ||
| 239 | 235 | ```cjs | |
| 240 | - const process = require('node:process'); | ||
| 241 | - | ||
| 242 | 236 | process.on('multipleResolves', (type, promise, reason) => { | |
| 243 | 237 | console.error(type, promise, reason); | |
| 244 | 238 | setImmediate(() => process.exit(1)); | |
@@ -310,8 +304,6 @@ process.on('rejectionHandled', (promise) => { | |||
| 310 | 304 | ``` | |
| 311 | 305 | ||
| 312 | 306 | ```cjs | |
| 313 | - const process = require('node:process'); | ||
| 314 | - | ||
| 315 | 307 | const unhandledRejections = new Map(); | |
| 316 | 308 | process.on('unhandledRejection', (reason, promise) => { | |
| 317 | 309 | unhandledRejections.set(promise, reason); | |
@@ -394,7 +386,6 @@ console.log('This will not run.'); | |||
| 394 | 386 | ``` | |
| 395 | 387 | ||
| 396 | 388 | ```cjs | |
| 397 | - const process = require('node:process'); | ||
| 398 | 389 | const fs = require('node:fs'); | |
| 399 | 390 | ||
| 400 | 391 | process.on('uncaughtException', (err, origin) => { | |
@@ -483,8 +474,6 @@ nonexistentFunc(); | |||
| 483 | 474 | ``` | |
| 484 | 475 | ||
| 485 | 476 | ```cjs | |
| 486 | - const process = require('node:process'); | ||
| 487 | - | ||
| 488 | 477 | process.on('uncaughtExceptionMonitor', (err, origin) => { | |
| 489 | 478 | MyMonitoringTool.logSync(err, origin); | |
| 490 | 479 | }); | |
@@ -534,8 +523,6 @@ somePromise.then((res) => { | |||
| 534 | 523 | ``` | |
| 535 | 524 | ||
| 536 | 525 | ```cjs | |
| 537 | - const process = require('node:process'); | ||
| 538 | - | ||
| 539 | 526 | process.on('unhandledRejection', (reason, promise) => { | |
| 540 | 527 | console.log('Unhandled Rejection at:', promise, 'reason:', reason); | |
| 541 | 528 | // Application specific logging, throwing an error, or other logic here | |
@@ -562,8 +549,6 @@ const resource = new SomeResource(); | |||
| 562 | 549 | ``` | |
| 563 | 550 | ||
| 564 | 551 | ```cjs | |
| 565 | - const process = require('node:process'); | ||
| 566 | - | ||
| 567 | 552 | function SomeResource() { | |
| 568 | 553 | // Initially set the loaded status to a rejected promise | |
| 569 | 554 | this.loaded = Promise.reject(new Error('Resource not yet loaded!')); | |
@@ -615,8 +600,6 @@ process.on('warning', (warning) => { | |||
| 615 | 600 | ``` | |
| 616 | 601 | ||
| 617 | 602 | ```cjs | |
| 618 | - const process = require('node:process'); | ||
| 619 | - | ||
| 620 | 603 | process.on('warning', (warning) => { | |
| 621 | 604 | console.warn(warning.name); // Print the warning name | |
| 622 | 605 | console.warn(warning.message); // Print the warning message | |
@@ -752,8 +735,6 @@ process.on('SIGTERM', handle); | |||
| 752 | 735 | ``` | |
| 753 | 736 | ||
| 754 | 737 | ```cjs | |
| 755 | - const process = require('node:process'); | ||
| 756 | - | ||
| 757 | 738 | // Begin reading from stdin so the process does not exit. | |
| 758 | 739 | process.stdin.resume(); | |
| 759 | 740 | ||
@@ -1262,8 +1243,6 @@ process.debugPort = 5858; | |||
| 1262 | 1243 | ``` | |
| 1263 | 1244 | ||
| 1264 | 1245 | ```cjs | |
| 1265 | - const process = require('node:process'); | ||
| 1266 | - | ||
| 1267 | 1246 | process.debugPort = 5858; | |
| 1268 | 1247 | ``` | |
| 1269 | 1248 | ||
@@ -1400,8 +1379,6 @@ process.on('warning', (warning) => { | |||
| 1400 | 1379 | ``` | |
| 1401 | 1380 | ||
| 1402 | 1381 | ```cjs | |
| 1403 | - const process = require('node:process'); | ||
| 1404 | - | ||
| 1405 | 1382 | process.on('warning', (warning) => { | |
| 1406 | 1383 | console.warn(warning.name); // 'Warning' | |
| 1407 | 1384 | console.warn(warning.message); // 'Something happened!' | |
@@ -1493,8 +1470,6 @@ process.on('warning', (warning) => { | |||
| 1493 | 1470 | ``` | |
| 1494 | 1471 | ||
| 1495 | 1472 | ```cjs | |
| 1496 | - const process = require('node:process'); | ||
| 1497 | - | ||
| 1498 | 1473 | process.on('warning', (warning) => { | |
| 1499 | 1474 | console.warn(warning.name); | |
| 1500 | 1475 | console.warn(warning.message); | |
@@ -1888,8 +1863,6 @@ if (someConditionNotMet()) { | |||
| 1888 | 1863 | ``` | |
| 1889 | 1864 | ||
| 1890 | 1865 | ```cjs | |
| 1891 | - const process = require('node:process'); | ||
| 1892 | - | ||
| 1893 | 1866 | // How to properly set the exit code while letting | |
| 1894 | 1867 | // the process exit gracefully. | |
| 1895 | 1868 | if (someConditionNotMet()) { | |
@@ -2425,8 +2398,6 @@ if (process.getegid) { | |||
| 2425 | 2398 | ``` | |
| 2426 | 2399 | ||
| 2427 | 2400 | ```cjs | |
| 2428 | - const process = require('node:process'); | ||
| 2429 | - | ||
| 2430 | 2401 | if (process.getegid) { | |
| 2431 | 2402 | console.log(`Current gid: ${process.getegid()}`); | |
| 2432 | 2403 | } | |
@@ -2455,8 +2426,6 @@ if (process.geteuid) { | |||
| 2455 | 2426 | ``` | |
| 2456 | 2427 | ||
| 2457 | 2428 | ```cjs | |
| 2458 | - const process = require('node:process'); | ||
| 2459 | - | ||
| 2460 | 2429 | if (process.geteuid) { | |
| 2461 | 2430 | console.log(`Current uid: ${process.geteuid()}`); | |
| 2462 | 2431 | } | |
@@ -2485,8 +2454,6 @@ if (process.getgid) { | |||
| 2485 | 2454 | ``` | |
| 2486 | 2455 | ||
| 2487 | 2456 | ```cjs | |
| 2488 | - const process = require('node:process'); | ||
| 2489 | - | ||
| 2490 | 2457 | if (process.getgid) { | |
| 2491 | 2458 | console.log(`Current gid: ${process.getgid()}`); | |
| 2492 | 2459 | } | |
@@ -2516,8 +2483,6 @@ if (process.getgroups) { | |||
| 2516 | 2483 | ``` | |
| 2517 | 2484 | ||
| 2518 | 2485 | ```cjs | |
| 2519 | - const process = require('node:process'); | ||
| 2520 | - | ||
| 2521 | 2486 | if (process.getgroups) { | |
| 2522 | 2487 | console.log(process.getgroups()); // [ 16, 21, 297 ] | |
| 2523 | 2488 | } | |
@@ -2546,8 +2511,6 @@ if (process.getuid) { | |||
| 2546 | 2511 | ``` | |
| 2547 | 2512 | ||
| 2548 | 2513 | ```cjs | |
| 2549 | - const process = require('node:process'); | ||
| 2550 | - | ||
| 2551 | 2514 | if (process.getuid) { | |
| 2552 | 2515 | console.log(`Current uid: ${process.getuid()}`); | |
| 2553 | 2516 | } | |
@@ -2752,8 +2715,6 @@ kill(process.pid, 'SIGHUP'); | |||
| 2752 | 2715 | ``` | |
| 2753 | 2716 | ||
| 2754 | 2717 | ```cjs | |
| 2755 | - const process = require('node:process'); | ||
| 2756 | - | ||
| 2757 | 2718 | process.on('SIGHUP', () => { | |
| 2758 | 2719 | console.log('Got SIGHUP signal.'); | |
| 2759 | 2720 | }); | |
@@ -3864,8 +3825,6 @@ if (process.getegid && process.setegid) { | |||
| 3864 | 3825 | ``` | |
| 3865 | 3826 | ||
| 3866 | 3827 | ```cjs | |
| 3867 | - const process = require('node:process'); | ||
| 3868 | - | ||
| 3869 | 3828 | if (process.getegid && process.setegid) { | |
| 3870 | 3829 | console.log(`Current gid: ${process.getegid()}`); | |
| 3871 | 3830 | try { | |
@@ -3909,8 +3868,6 @@ if (process.geteuid && process.seteuid) { | |||
| 3909 | 3868 | ``` | |
| 3910 | 3869 | ||
| 3911 | 3870 | ```cjs | |
| 3912 | - const process = require('node:process'); | ||
| 3913 | - | ||
| 3914 | 3871 | if (process.geteuid && process.seteuid) { | |
| 3915 | 3872 | console.log(`Current uid: ${process.geteuid()}`); | |
| 3916 | 3873 | try { | |
@@ -3954,8 +3911,6 @@ if (process.getgid && process.setgid) { | |||
| 3954 | 3911 | ``` | |
| 3955 | 3912 | ||
| 3956 | 3913 | ```cjs | |
| 3957 | - const process = require('node:process'); | ||
| 3958 | - | ||
| 3959 | 3914 | if (process.getgid && process.setgid) { | |
| 3960 | 3915 | console.log(`Current gid: ${process.getgid()}`); | |
| 3961 | 3916 | try { | |
@@ -3999,8 +3954,6 @@ if (process.getgroups && process.setgroups) { | |||
| 3999 | 3954 | ``` | |
| 4000 | 3955 | ||
| 4001 | 3956 | ```cjs | |
| 4002 | - const process = require('node:process'); | ||
| 4003 | - | ||
| 4004 | 3957 | if (process.getgroups && process.setgroups) { | |
| 4005 | 3958 | try { | |
| 4006 | 3959 | process.setgroups([501]); | |
@@ -4043,8 +3996,6 @@ if (process.getuid && process.setuid) { | |||
| 4043 | 3996 | ``` | |
| 4044 | 3997 | ||
| 4045 | 3998 | ```cjs | |
| 4046 | - const process = require('node:process'); | ||
| 4047 | - | ||
| 4048 | 3999 | if (process.getuid && process.setuid) { | |
| 4049 | 4000 | console.log(`Current uid: ${process.getuid()}`); | |
| 4050 | 4001 | 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 | ||
@@ -316,7 +315,6 @@ database.loadExtension('./base64.dylib', 'sqlite3_base64_init'); | |||
| 316 | 315 | ``` | |
| 317 | 316 | ||
| 318 | 317 | ```cjs | |
| 319 | - 'use strict'; | ||
| 320 | 318 | const { DatabaseSync } = require('node:sqlite'); | |
| 321 | 319 | const database = new DatabaseSync(':memory:', { allowExtension: true }); | |
| 322 | 320 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -850,7 +850,6 @@ test('spies on a function', () => { | |||
| 850 | 850 | ``` | |
| 851 | 851 | ||
| 852 | 852 | ```cjs | |
| 853 | - 'use strict'; | ||
| 854 | 853 | const assert = require('node:assert'); | |
| 855 | 854 | const { mock, test } = require('node:test'); | |
| 856 | 855 | ||
| 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