@jsenv/util
Version:
Set of functions often needed when using Node.js.
11 lines (10 loc) • 382 B
JavaScript
export const statsToType = (stats) => {
if (stats.isFile()) return "file"
if (stats.isDirectory()) return "directory"
if (stats.isSymbolicLink()) return "symbolic-link"
if (stats.isFIFO()) return "fifo"
if (stats.isSocket()) return "socket"
if (stats.isCharacterDevice()) return "character-device"
if (stats.isBlockDevice()) return "block-device"
return undefined
}