# @wbe/mfs

> nodejs fs wrapper

Latest version **0.3.0** (published 2024-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wbe/mfs
pnpm add @wbe/mfs
yarn add @wbe/mfs
bun add @wbe/mfs
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-03-26 |
| First published | 2022-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Willy Brauner |
| Maintainers | willybe |

## Links

- npm: https://www.npmjs.com/package/@wbe/mfs
- Repository: https://github.com/willybrauner/mfs
- Homepage: https://github.com/willybrauner/mfs#readme
- Issues: https://github.com/willybrauner/mfs/issues
- npm.io page: https://npm.io/package/@wbe/mfs

## Dependencies (1)

- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.1

## Recent versions

- 0.3.0 (latest) — 2024-03-26
- 0.2.0 — 2023-11-02
- 0.1.1 — 2023-06-22
- 0.1.0 — 2022-09-15

## README

# mfs

`mfs` (micro-fs) is a nodejs fs wrapper that provides a collection of high-level functions for manipulating files and directories.

## Installation

```shell
npm install @wbe/mfs
```

## Usage

```js
import { * as mfs } from '@wbe/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"
})();
```

## API

### Async functions

- fileExists

```ts
function fileExists(path: string): Promise<boolean>
```

- createFile

```ts
function createFile(path: string, content?: string): Promise<void>
```

- readFile

```ts
function readFile(path: string): Promise<string>
```

- removeFile

```ts
function removeFile(path: string): Promise<boolean>
```

- copyFile

```ts
function copyFile(
  src: string,
  dest: string,
  {
    transform,
    force,
  }: { transform?: (content: string) => Promise<string>; force?: boolean }
): Promise<void>
```

- dirExists

```ts
function dirExists(path: string): Promise<boolean>
```

- readDir

```ts
function readDir(path: string, recursive = true): Promise<string[]>
```

- removeDir

```ts
function removeDir(path: string): Promise<void>
```

- createDir

```ts
function createDir(path: string): Promise<string | undefined>
```

- copyDir

```ts
function copyDir(
  src: string,
  dest: string,
  { force }: { force?: boolean } = {}
): Promise<void>
```


### Sync functions

- fileExistsSync

```ts
function fileExistsSync(path: string): boolean
```

- createFileSync

```ts
function createFileSync(path: string, content?: string): void
```

- readFileSync

```ts
function readFileSync(path: string): string
```

- removeFileSync

```ts
function removeFileSync(path: string): boolean
```

- copyFileSync

```ts
function copyFileSync(
  src: string,
  dest: string,
  {
    transform,
    force,
  }: { transform?: (content: string) => string; force?: boolean }
): void
```

- dirExistsSync

```ts
function dirExistsSync(path: string): boolean
```

- readDirSync

```ts
function readDirSync(path: string, recursive = true): string[]
```

- removeDirSync

```ts
function removeDirSync(path: string): void
```

- createDirSync

```ts
function createDirSync(path: string): string | undefined
```

- copyDirSync

```ts
function copyDirSync(src: string, dest: string, { force }: { force?: boolean } = {}): void
```

## License

MIT

## Credits

© Willy Brauner

---
_Source: https://npm.io/package/@wbe/mfs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
