Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexwkleung/fs-dir

Wrapper utility for file system operations using Node.js
https://github.com/alexwkleung/fs-dir

file-system nodejs utilities utility wrapper wrapper-functions

Last synced: 18 days ago
JSON representation

Wrapper utility for file system operations using Node.js

Awesome Lists containing this project

README

        

# fs-dir

Wrapper utility for file system operations using Node.js.

This is ESM-only.

# Installation

Install via npm, directly from the repository.

```bash
npm install https://github.com/alexwkleung/fs-dir
```

Import fs-dir.

```typescript
//import everything
import * as fsDir from 'fs-dir'
```

or

```typescript
//import what you need from the package
import { readDirectory, removeExtension, filterByExtension, parseFile, writeToFile } from 'fs-dir'
```

# Functions

1. Read contents of a directory.

```typescript
//type signature
function readDirectory(dirStr: string): string[]
```

2. Remove extensions from files.

```typescript
//type signature
function removeExtension(dirArr: string[]): string[]
```

3. Filter directory files by extension.

```typescript
//type signature
function filterByExtension(dirArr: string[], extension: string): string[]
```

4. Read a file from a directory.

```typescript
//type signature
function parseFile(path: string): string
```

5. Write content into a file.

```typescript
//type signature
function writeToFile(path: string, data: string): void
```

# License

[MIT License.](https://github.com/alexwkleung/fs-dir/blob/main/LICENSE)