The __lookupSetter__
function is a built-in function in JavaScript that allows you to retrieve the setter function of a property. In the fs-extra
package, this function is used to override the default stat
method of the fs
module.
To use __lookupSetter__
in fs-extra
, you can follow the code snippet below:
index.tsx582 chars24 lines
In this example, we first get the original stat
function of the fs
module using __lookupSetter__
. Then, we define a new stat
function that logs a message to the console and calls the original stat
function. Finally, we override the original stat
function with the new stat
function using __defineSetter__
.
When you use fse.stat
to get the stats of a file, it will call the new stat
function instead of the original one. Then, the new stat
function will log a message to the console and call the original stat
function to get the file stats.
gistlibby LogSnag