easy file stuff I suppose
npm i file-ez
f-ez supports commonjs:
const fz = require('file-ez');
fz.res('./file.txt');
but also exports everything separately for esm:
import { res } from 'file-ez';
res('./file.txt');
Resolves a path relative to the file it's called in.
path
: an absolute path, or path relative to the current file
Recursively gathers all files in a directory and its subdirectories.
path
: an absolute path, or path relative to the current file
Makes import()
feel more like require()
, allows mixing esm and commonjs.
path
: an absolute path, path relative to the current file, or name of an installed package
full
: return the entire module instead of only default
Returns the contents of a file as a string.
path
: an absolute path, or path relative to the current file
Returns the contents of a file as a buffer.
path
: an absolute path, or path relative to the current file
Writes data to a file.
path
: an absolute path, or path relative to the current file
data
: what you want to write to the file