1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00

fix(node): add ppid getter for node:process (#22167)

This commit adds `ppid` getter for `node:process` to improve Node
compatibility one step further.

There is one problem though, which is that `Deno.ppid`, which
`process.ppid` internally calls, is actually of type `bigint` although
it's supposed to be `number`. I filed an issue for this (#22166). For
the time being, explciit type conversion from `bigint` to `number` is
applied to match the Node.js behavior.
This commit is contained in:
Yusuke Tanaka 2024-02-01 12:48:27 +09:00 committed by GitHub
parent cfb57b1855
commit 66e6ed65e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -121,6 +121,14 @@ Deno.test({
},
});
Deno.test({
name: "process.ppid",
fn() {
assertEquals(typeof process.ppid, "number");
assertEquals(process.ppid, Deno.ppid);
},
});
Deno.test({
name: "process.on",
async fn() {

View file

@ -558,6 +558,11 @@ class Process extends EventEmitter {
return pid;
}
/** https://nodejs.org/api/process.html#processppid */
get ppid() {
return Deno.ppid;
}
/** https://nodejs.org/api/process.html#process_process_platform */
get platform() {
if (!platform) {