UNPKG

@sitemark/exifr

Version:

📑 The fastest and most versatile JavaScript EXIF reading library.

24 lines (20 loc) • 662 B
import { isNode } from './buff-util.js'; let _fs = undefined; // lazy-loaded /** * A safe way of accessing the Node.js fs module. This shouldn't be used in code run by the browser. */ function fs() { if (!isNode) { throw new Error('Node.js fs module is not available outside of node.'); } if (!_fs) { // Doing it with eval() avoids web bundlers from replacing it with a generic import and bundling the module. const fs = eval('require')('fs'); _fs = fs != null ? fs.promises : undefined; } if (!_fs) { throw new Error('Node.js fs module is not available.'); } return _fs; } export { fs };