when<R> method
R?
when<R>({
- R file(
- File file
- R directory(
- Directory directory
- R link(
- Link link
Handle every possible FS entity.
Implementation
R? when<R>({
R Function(File file)? file,
R Function(Directory directory)? directory,
R Function(Link link)? link,
}) {
if (fs.isFileSync(path)) {
return file?.call(this as File);
} else if (fs.isDirectorySync(path)) {
return directory?.call(this as Directory);
} else {
return link?.call(this as Link);
}
}