1. file-set
Expands file paths and glob expressions, returning matched and unmatched files and directories
file-set
Package: file-set
Created by: 75lb
Last modified: Sat, 18 Jun 2022 00:38:41 GMT
Version: 5.1.3
License: MIT
Downloads: 1,039,258
Repository: https://github.com/75lb/file-set

Install

npm install file-set
yarn add file-set

view on npm
npm module downloads
Gihub repo dependents
Gihub package dependents
Node.js CI
js-standard-style

file-set

Expands a list of paths and glob expressions into three sets: "files", "directories" and "not existing". Each set in the output is a list of unique paths.

The library saves you the job of learning a globbing library, expanding a glob expression (e.g. lib/**/*), sifting through each result testing whether it's a file, directory or neither.

Usage

Expand two glob expressions ('*' and 'not/existing/*').

 import FileSet from 'file-set'
const fileSet = new FileSet()
await fileSet.add([ '*', 'not/existing/*' ])
console.log(fileSet)

The output has been organised into sets.

FileSet {
  files: [ 'LICENSE', 'package.json', 'README.md' ],
  dirs: [ 'jsdoc2md/', 'lib/', 'node_modules/', 'test/' ],
  notExisting: [ 'not/existing/*' ]
}

API

file-set

FileSet ⏏

Kind: Exported class

new FileSet()

fileSet.files : Array.<string>

The existing files found

Kind: instance property of FileSet

fileSet.dirs : Array.<string>

The existing directories found. Directory paths will always end with '/'.

Kind: instance property of FileSet

fileSet.notExisting : Array.<string>

Paths which were not found

Kind: instance property of FileSet

fileSet.add(patterns)

Add file patterns to the set.

Kind: instance method of FileSet

Param Type Description
patterns string | Array.<string> One or more file paths or glob expressions to inspect.

© 2014-22 Lloyd Brookes <[email protected]>.

Tested by test-runner.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code