nodejs fs wrapper
npm install @cher-ami/mfsmfs (micro-fs) is a nodejs fs wrapper that provides a collection of high-level functions for manipulating files and directories.
``shell`
npm install @cher-ami/mfs
`js
import { * as mfs } from '@cher-ami/mfs';
(async () => {
// create a new file in a non-existing directory
await mfs.createFile('/test/foo.txt', 'Hello World');
const content = await mfs.readFile('/test/foo.txt');
console.log(content); // -> "Hello World"
})();
`
- fileExists
`ts`
function fileExists(path: string): Promise
- createFile
`ts`
function createFile(path: string, content?: string): Promise
- readFile
`ts`
function readFile(path: string): Promise
- removeFile
`ts`
function removeFile(path: string): Promise
- copyFile
`ts`
function copyFile(
src: string,
dest: string,
{
transform,
force,
}: { transform?: (content: string) => Promise
): Promise
- dirExists
`ts`
function dirExists(path: string): Promise
- readDir
`ts`
function readDir(path: string, recursive = true): Promise
- removeDir
`ts`
function removeDir(path: string): Promise
- createDir
`ts`
function createDir(path: string): Promise
- copyDir
`ts``
function copyDir(
src: string,
dest: string,
{ force }: { force?: boolean } = {}
): Promise
MIT
© Willy Brauner