To use the hasOwnProperty function from the fs-extra library in TypeScript, you can follow the below steps:
fs-extra npm package.21 chars2 lines
fs-extra module at the beginning of your TypeScript file.index.ts27 chars2 lines
hasOwnProperty function from the fs-extra module as shown below:index.ts138 chars6 lines
The hasOwnProperty function can be used to check if a specific property exists in the returned object of a fs method like fs.stat. In the above example, we are checking if the size property exists in the returned object of fs.stat before logging the value to the console.
Note: It is important to use await when calling asynchronous fs methods to make sure the call completes before checking the object properties.
gistlibby LogSnag