• Stars
    star
    849
  • Rank 53,367 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Super tiny and ~350% faster alternative to node-glob

Tiny Glob

tiny glob

version CI downloads install size

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 ~45 LOC with 2 small dependencies
  • ๐Ÿ‘ซ friendly: simple and easy to use api
  • ๐ŸŽญ cross-platform: supports both unix and windows

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.

OBS: Please only use forward-slashes in glob expressions. Even on windows

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.

Windows

Though Windows may use /, \, or \\ as path separators, you can only use forward-slashes (/) when specifying glob expressions. Any back-slashes (\) will be interpreted as escape characters instead of path separators.

This is common across many glob-based modules; see node-glob for corroboration.

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

More Repositories

1

awesome-creative-coding

Creative Coding: Generative Art, Data visualization, Interaction Design, Resources.
HTML
12,228
star
2

prompts

โฏ Lightweight, beautiful and user-friendly interactive prompts
JavaScript
8,805
star
3

ramme

Unofficial Instagram Desktop App.
JavaScript
3,319
star
4

zet

Set() as it should be.
JavaScript
521
star
5

sqliterally

Lightweight SQL query builder
JavaScript
263
star
6

terkelg

A website inside an SVG, inside an image, inside HTML, inside markdown, inside a GitHub readme.md.
TypeScript
223
star
7

facon

Tiny utility (365B) to create DOM elements with manner.
JavaScript
222
star
8

deakins

๐ŸŽฅ Small Canvas 2D Camera
TypeScript
135
star
9

math

Math snippets with graphic programming in mind.
113
star
10

zuckerberg.smile

๐Ÿค– Control Mark Zuckerbergs smile property
JavaScript
89
star
11

skaler

A (329B) client-side image resizer.
JavaScript
88
star
12

workshy

A small (376B) lazy function scheduler for a butter smooth main thread.
JavaScript
80
star
13

math-toolbox

Lightweight and modular math toolbox
JavaScript
76
star
14

globrex

Glob to regular expression with support for extended globs.
JavaScript
67
star
15

cantinflas

Tiny mustache-like template engine in ~50 LOC.
JavaScript
65
star
16

sisteransi

ANSI escape codes for some terminal swag.
JavaScript
58
star
17

eliminate

Delete files and directories without all the bullshit.
JavaScript
52
star
18

terkel.com-2016

My Personal website. Build with Vue and ThreeJS.
JavaScript
40
star
19

powerwalker

๐ŸƒWalk directories recursively.
JavaScript
28
star
20

hent

A small utility to fetch remote files into buffers
JavaScript
23
star
21

npm-scripts-as-build-tool

Nuggets on how to use NPM Scripts as your build tool. You don't need Grunt or Gulp
21
star
22

cursor-travel

๐Ÿ“ Measure how far your cursor travels.
Swift
19
star
23

favorite-awesomeness

A tiny collection of my favorite awesomelists
18
star
24

shrinktome

๐Ÿ“˜Shrink facebook by 5% every 10th second. You're welcome!
JavaScript
16
star
25

stopgap

Easily create/remove temporary directories.
JavaScript
16
star
26

simultan

Simultaneously run an async function on any iterable with limited concurrency
JavaScript
15
star
27

cursormuseum

A very brief history of pointing devices
CSS
14
star
28

mkdirplz

Make directories recursively -plz ๐Ÿ™
JavaScript
13
star
29

antedate

A tiny pre-renderer for client side applications.
JavaScript
13
star
30

webpack-starter

'Just Add Water' Webpack 2, babel and glslify gourmet mix.
JavaScript
13
star
31

starter

No tooling starter because simplicity is the ultimate sophistication.
CSS
13
star
32

1d

๐ŸฅžMake multi-dimensional arrays as flat as a pancake.
JavaScript
11
star
33

utters

Small (257B) promise wrapper for SpeechSynthesisUtterance
JavaScript
11
star
34

globalyzer

Detect and extract the static part of a glob string.
JavaScript
10
star
35

vimrc

I heard you like escape rooms?
Vim Script
10
star
36

foldersstructure

macOS Automator workflow to scaffold my project directory structure.
10
star
37

threejs-create

Create a generic three.js application for quick prototyping
JavaScript
9
star
38

exclamation

Holy Stratosphere, Robin exclamationsโ—
JavaScript
7
star
39

invisible

The Invisible Game: Huckle buckle beanstalk
JavaScript
6
star
40

brolly

Internet of Things Umbrella Game.
JavaScript
6
star
41

yeezify

Instantly change all images on any given webpage to Kanye West.
JavaScript
6
star
42

IMDb-Runtimes

A simple Google Chrome extension to convert runtimes on IMDb to hours and minutes.
JavaScript
4
star
43

judgedbycover

A Twitter bot that judge books based on their cover.
JavaScript
3
star
44

dmjx-intro

Website for DMJX freshers' weekend
HTML
1
star
45

terkeliknibe

I created this website after nearly four months of apartment searching
SCSS
1
star