Wrapper utility for file system operations using Node.js.
This is ESM-only.
Install via npm, directly from the repository.
npm install https://github.com/alexwkleung/fs-dir
Import fs-dir.
//import everything
import * as fsDir from 'fs-dir'
or
//import what you need from the package
import { readDirectory, removeExtension, filterByExtension, parseFile, writeToFile } from 'fs-dir'
- Read contents of a directory.
//type signature
function readDirectory(dirStr: string): string[]
- Remove extensions from files.
//type signature
function removeExtension(dirArr: string[]): string[]
- Filter directory files by extension.
//type signature
function filterByExtension(dirArr: string[], extension: string): string[]
- Read a file from a directory.
//type signature
function parseFile(path: string): string
- Write content into a file.
//type signature
function writeToFile(path: string, data: string): void