Skip to content

A super tiny and ~350% faster alternative to node-glob πŸš€

License

Notifications You must be signed in to change notification settings

shaunstanislauslau/tiny-glob

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

68 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tiny Glob

tiny glob

version travis downloads

Tiny and extremely fast library to match files and folders using glob patterns.


"Globs" is the common name for a specific type of pattern used to match files and folders. It's the patterns you type when you do stuff like ls *.js in your shell or put src/* in a .gitignore file. When used to match filenames, it's sometimes called a "wildcard".

Install

npm install tiny-glob

Core Features

  • πŸ”₯ extremely fast: ~350% faster than node-glob and ~230% faster than fast-glob
  • πŸ’ͺ powerful: supports advanced globbing patterns (ExtGlob)
  • πŸ“¦ tiny: only ~70 LOC with 2 small dependencies
  • πŸ‘« friendly: simple and easy to use api

Usage

const glob = require('tiny-glob');

(async function(){
    let files = await glob('src/*/*.{js,md}');
    // => [ ... ] array of matching files
})();

API

glob(str, options)

Type: function
Returns: Array

Return array of matching files and folders This function is async and returns a promise.

str

Type: String

The glob pattern to match against.

options.cwd

Type: String
Default: '.'

Change default working directory.

options.dot

Type: Boolean
Default: false

Allow patterns to match filenames or directories that begin with a period (.).

options.absolute

Type: Boolean
Default: false

Return matches as absolute paths.

options.filesOnly

Type: Boolean
Default: false

Skip directories and return matched files only.

options.flush

Type: Boolean
Default: false

Flush the internal cache object.

Benchmarks

glob x 13,405 ops/sec Β±1.80% (85 runs sampled)
fast-glob x 25,745 ops/sec Β±2.76% (59 runs sampled)
tiny-glob x 102,658 ops/sec Β±0.79% (91 runs sampled)
Fastest is tiny-glob
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name      β”‚ Mean time               β”‚ Ops/sec     β”‚ Diff           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ glob      β”‚ 0.00007459990597268128  β”‚ 13,404.843  β”‚ N/A            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ fast-glob β”‚ 0.000038842529587611705 β”‚ 25,744.976  β”‚ 92.06% faster  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ tiny-glob β”‚ 0.00000974110141018254  β”‚ 102,657.796 β”‚ 298.75% faster β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Advanced Globbing

Learn more about advanced globbing

License

MIT Β© Terkel Gjervig

About

A super tiny and ~350% faster alternative to node-glob πŸš€

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%