Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/fs.ts>stat

A JavaScript extension package for building strong and modern applications.
Latest
function stat
import { stat } from "https://deno.land/x/ayonli_jsext@v0.9.72/fs.ts";

Returns the information of the given file or directory.

NOTE: This function can also be used in Cloudflare Workers.

Examples

Example 1

// with the default storage
import { stat } from "@ayonli/jsext/fs";

const info = await stat("/path/to/file.txt");
console.log(`${info.name} is a ${info.kind}, its size is ${info.size} bytes, with MIME type ${info.type}.`);

Example 2

// with a user-selected directory as root (Chromium only)
import { stat } from "@ayonli/jsext/fs";

const root = await window.showDirectoryPicker();
const info = await stat("/path/to/file.txt", { root });
console.log(`${info.name} is a ${info.kind}, its size is ${info.size} bytes, with MIME type ${info.type}.`);

Parameters

target: string | FileSystemFileHandle | FileSystemDirectoryHandle
optional
options: StatOptions = [UNSUPPORTED]

Returns

Promise<FileInfo>