1.0.0 • Published 2 years ago

enoent v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

enoent

Simple Module which replaces fs.exists

Import

const { exists, existsAsync } = require('enoent')

Usage

// Callback
exists('RANDOMFILE.txt', (result) => {
    console.log('RANDOMFILE.txt', result)
})

// Promisified
const result = await existsAsync('RANDOMFILE.txt')
console.log('RANDOMFILE.txt', result)

Replacing the fs function

Put this where you normally would import fs

const fs = require('fs')
fs.exists = require('enoent').exists

And you can use

fs.exists('myfile.txt', (result) => {
    console.log(result)
})