Assuming you have already installed the fs-extra
library, you can use the stat
function to get the stats of a file using the promises
API in TypeScript as shown below:
index.ts236 chars13 lines
In the above code, we import the fs-extra
library and use the stat
function to get the stats of the file located at /path/to/file
. We use the getFileStats
function to handle the asynchronous call to the stat
function using the async/await
syntax. The stats object is then logged to the console. If an error occurs, we log the error to the console.
gistlibby LogSnag