import { assertEquals, assertInstanceOf, assertObjectMatch } from "jsr:@std/assert"
const
time_fields: (keyof FsEntryInfo)[] = ["mtime", "atime", "birthtime", "ctime"],
numeric_fields: (keyof FsEntryInfo)[] = ["size", "dev", "mode"]
const my_deno_json_stats = (await statEntry(identifyCurrentRuntime(), new URL(import.meta.resolve("../deno.json"))))!
assertObjectMatch(my_deno_json_stats, {
isFile: true,
isDirectory: false,
isSymlink: false,
})
time_fields.forEach((prop) => {
assertInstanceOf(my_deno_json_stats[prop], Date)
})
numeric_fields.forEach((prop: keyof FsEntryInfo) => {
assertEquals(typeof my_deno_json_stats[prop], "number")
})
// unlike node and deno, non-existing paths do not error, and instead `undefined` is returned.
const non_existing_path_stat = await statEntry(identifyCurrentRuntime(), new URL(import.meta.resolve("../hello/world/file.txt")))
assertEquals(non_existing_path_stat, undefined)
provides metadata information about a filesystem entry (file, folder) on supported runtimes (i.e. RUNTIME.DENO, RUNTIME.BUN, or RUNTIME.NODE). any symbolic links encountered at the provided
path
will be followed, and the referenced path will instead be examined.if the provided
path
does not exist on the filesystem, thenundefined
will be returned.only the fields that are common to windows, linux, and mac systems have been kept, while the stat fields specific to only a subset of the common platforms have been omitted.