https://github.com/maarcosv99/files-folder
Lightweight library to grab all files and folders in a directory.
https://github.com/maarcosv99/files-folder
files filesystem nodejs npm-package pathfinder typescript
Last synced: 6 months ago
JSON representation
Lightweight library to grab all files and folders in a directory.
- Host: GitHub
- URL: https://github.com/maarcosv99/files-folder
- Owner: Maarcosv99
- License: mit
- Created: 2023-01-03T12:21:08.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-03T16:29:45.000Z (over 2 years ago)
- Last Synced: 2025-03-23T20:51:16.650Z (7 months ago)
- Topics: files, filesystem, nodejs, npm-package, pathfinder, typescript
- Language: TypeScript
- Homepage: https://npm.im/files-folder
- Size: 89.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# files-folder
Lightweight library to get all files or folders from any directory.
[](https://choosealicense.com/licenses/mit/)
## Installation
Use the package manager [npm](https://www.npmjs.com/) to install files-folder.
```bash
npm i files-folder
```## Usage
**Synchronous methods**
```typescript
import { getFilesSync, getFoldersSync } from "files-folder";const folders = getFoldersSync("src");
console.log(folders); // string[]const files = getFilesSync("src");
console.log(files); // string[]
```**Asynchronous methods**
```typescript
import { getFilesAsync, getFoldersAsync } from "files-folder";const folders = await getFoldersAsync("src");
console.log(folders); // string[]const files = await getFilesAsync("src");
console.log(files); // string[]
```**Get the relative or full path**
This parameter works for all functions.
```typescript
import { getFilesAsync, getFoldersSync } from "files-folder";getFoldersSync("src", { full_path: false }); // src/**
await getFilesAsync("src", { full_path: true }); // home/**
```**Filter files using regex or function**
```typescript
import { getFilesSync, getFilesAsync } from "files-folder";getFilesSync("src", { filter: /\.ts$/ }); // src/**/*.ts
await getFilesAsync("src", {
filter: (filename) => filename.endsWith(".ts"),
}); // src/**/*.ts
```## Contributing
Pull requests are welcome. For major changes, [please open an issue](https://github.com/Maarcosv99/files-folder/issues) first
to discuss what you would like to change.Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)