Socket
Socket
Sign inDemoInstall

files-folder

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    files-folder

Lightweight library to grab all files or folders in a directory.


Version published
Maintainers
1
Install size
11.1 kB
Created

Readme

Source

files-folder

Lightweight library to get all files or folders from any directory.

MIT License

Installation

Use the package manager npm to install files-folder.

npm i files-folder

Usage

Synchronous methods

import { getFilesSync, getFoldersSync } from "files-folder";

const folders = getFoldersSync("src");
console.log(folders); // string[]

const files = getFilesSync("src");
console.log(files); // string[]

Asynchronous methods

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.

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

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 first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Keywords

FAQs

Last updated on 10 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc