Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/alexwkleung/fs-dir
- Owner: alexwkleung
- License: mit
- Created: 2023-04-26T22:21:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-30T17:14:36.000Z (over 1 year ago)
- Last Synced: 2024-11-07T14:31:24.732Z (2 months ago)
- Topics: file-system, nodejs, utilities, utility, wrapper, wrapper-functions
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)