# m-fs

> Helper functions for node fs

Latest version **5.2.0** (published 2022-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install m-fs
pnpm add m-fs
yarn add m-fs
bun add m-fs
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.2.0 |
| Published | 2022-07-15 |
| First published | 2017-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mgenware |
| Maintainers | mgenware |

## Links

- npm: https://www.npmjs.com/package/m-fs
- Repository: https://github.com/mgenware/m-fs
- Issues: https://github.com/mgenware/m-fs/issues
- npm.io page: https://npm.io/package/m-fs

## Recent versions

- 5.2.0 (latest) — 2022-07-15
- 5.1.0 — 2021-12-08
- 5.0.0 — 2021-02-12
- 4.0.0 — 2020-07-07
- 3.0.0 — 2020-03-29
- 2.3.4 — 2019-12-21
- 2.3.3 — 2019-12-21
- 2.3.2 — 2019-09-01
- 2.3.1 — 2019-06-07
- 2.3.0 — 2019-04-25
- 2.2.0 — 2019-04-10
- 2.1.1 — 2019-04-09
- 2.1.0 — 2019-03-17
- 2.0.0 — 2018-12-02
- 1.0.3 — 2018-02-10
- … 4 more at https://npm.io/package/m-fs/versions

## README

# m-fs

[![Build Status](https://github.com/mgenware/m-fs/workflows/Build/badge.svg)](https://github.com/mgenware/m-fs/actions)
[![npm version](https://img.shields.io/npm/v/m-fs.svg?style=flat-square)](https://npmjs.com/package/m-fs)
[![Node.js Version](http://img.shields.io/node/v/m-fs.svg?style=flat-square)](https://nodejs.org/en/)

Helper functions for node fs.

## Installation

```sh
npm add m-fs
```

## Usage

```ts
import * as mfs from 'm-fs';
```

## API

### `readFileAsync`

Calls `fs.promises.readFile`.

### `writeFileAsync`

Calls `fs.promises.writeFile`. This method also makes ensure the target directory is created before writing the file.

### `statAsync`

Calls `fs.promises.stat`.

### `statOrNullAsync`

Like `statAsync`, but instead of throwing an error, it returns `null` in that case.

### `pathExists`, `dirExists`, `fileExists`

Returns `true` if the given path/directory/file exists.

### `subPaths`, `subDirs`, `subFiles`

```ts
await subPaths('./data/docs');
// ['backup', 'resume.pdf', 'readme.md']

await subPathsWithType('./data/docs');
// [{ path: 'backup', isFile: false }, { path: 'resume.pdf', isFile: true }, { path: 'readme.md', isFile: true }]

await subDirs('./data/docs');
// ['backup']

await subFiles('./data/docs');
// ['resume.pdf', 'readme.md']
```

### `mkdirp`

Calls `fs.promises.mkdir` with `{ recursive: true }`.

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