Skip to content

Commit

Permalink
fix(ext/node): add default methods to fs.StatsBase (#22750)
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy committed Mar 8, 2024
1 parent cc7d522 commit f2c1eda
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ext/node/polyfills/_fs/_fs_stat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ class StatsBase {
this.size = size;
this.blocks = blocks;
}

isFile() {
return false;
}
isDirectory() {
return false;
}
isSymbolicLink() {
return false;
}
isBlockDevice() {
return false;
}
isFIFO() {
return false;
}
isCharacterDevice() {
return false;
}
isSocket() {
return false;
}
}

// The Date constructor performs Math.floor() to the timestamp.
Expand Down
14 changes: 14 additions & 0 deletions tests/unit_node/_fs/_fs_stat_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ Deno.test("[std/node/fs] stat callback isn't called twice if error is thrown", a
},
});
});

Deno.test({
name: "[std/node/fs] stat default methods",
fn() {
const stats = new Stats();
assertEquals(stats.isFile(), false);
assertEquals(stats.isDirectory(), false);
assertEquals(stats.isBlockDevice(), false);
assertEquals(stats.isCharacterDevice(), false);
assertEquals(stats.isSymbolicLink(), false);
assertEquals(stats.isFIFO(), false);
assertEquals(stats.isSocket(), false);
},
});

0 comments on commit f2c1eda

Please sign in to comment.