1. file-match
Match filepath is validated, or exclude filepath that don't need.
file-match
Package: file-match
Created by: douzi8
Last modified: Sat, 18 Jun 2022 00:37:04 GMT
Version: 1.0.2
License: ISC
Downloads: 276,289
Repository: https://github.com/douzi8/file-match

Install

npm install file-match
yarn add file-match

file-match

Match filepath is validated, or exclude filepath that don't need

 var fileMatch = require('file-match');

var filter = fileMatch('*.js');

filter('a.js');            // true
filter('path/a.js');       // false

var filter = fileMatch([
  '**/*',
  '!path/*.js'
  '!img/**/.{jpg,png,gif}'
]);

filter('src/demo.js')           // true
filter('path/demo.js')          // false
filter('path/path/demo.js')     // true
filter('img/demo.png')          // false
filter('img/path/demo.png')     // false

var filter = fileMatch([
  'path/*.js'
], true);

If the filter value is empty string or empty arry, it will always return false,
if it's null, will always return true.

filter description

  • *.js only match js files in current dir.
  • **/*.js match all js files.
  • path/*.js match js files in path.
  • !*.js exclude js files in current dir.
  • .{jpg,png,gif} means jpg, png or gif
'**/*'                 // Match all files
'!**/*.js'             // Exclude all js files
'**/*.{jpg,png,gif}'   // Match jpg, png, or gif files

ignore case

  • ignore {boolean} [ignore = false]

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