0.2.9 ā€¢ Published 3 years ago

tiny-glob v0.2.9

Weekly downloads
377,373
License
MIT
Repository
github
Last release
3 years ago

"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

tsdx-extra@sparrowjs/builtincloud-archive-s3@rat.md/rollup-resolve@codewitchbella/microbundle@kolibrejs/builtingql_din_mod@vifjs/kit@iobroker-community-adapters/iobroker.device-watchertuum@infinitebrahmanuniverse/nolb-tiny-gexport-ts@saaspe/componentsexpand-react-bridge@everything-registry/sub-chunk-2948@leijingdao/tsdx@feltjs/gro@grogarden/grop149-tablesvelte-adapter-bun-maintained@mediakular/svelte-data-gridydb-codegen@edenjs/cli@dvaji/tsdx@eik/microbundleyest@efox/etscwebchewl_bpmnlint_es5wrap2wrenchnpm-ui-componentstestapatigedtiged2tiny-glob-clitimer-runnertiny.compiledteroshdl2temporal-test262-runnertemporaetts-for-girts3xttsdxtsdx-sasstsdx-with-svgtsdx2tsdxwtsdytsdxtsdx-esmtypebundlezqt@frontline-hq/rollup-merge-import@fullstax/svelte-i18n@era-ci/steps@gbozee/tsdxunplugin-resolve-esm-ts-pathsutsdxvite-plugin-multip@haysquare/svelte-multi-select@haysquare/svelte-multiselect@hasparus/microbundle@inti-ar/evm-chains@hproinformatica/functions@iobroker/adapter-dev@hideoo/create-app@iosio/node-util@iosio/x-project@iosio/create-x-project@incentum/cryptosveltekit-adapter-html-likesveltekit-adapter-chrome-extensiontehanu-tenbotehanu-teru@eslym/svelte-adapter-bun@epigraph/epigraph-analytics@heatmanofurioso/microbundle@gomah/tsdxdoloribussedqunitpyreswap-sdkquoprovidentregisseurrefinejs-reporesponsive-image-builderresponsive-react-appremdoloresresponsis-gantt-task-reactreact-router-v5-v6-bridged-featuresreact-plugin-package-corereact-redux-component-loaderrequirejs-esmsemantic-release-nexussafarifyrollup-configuredrollup-glob-optsshuutilssmooth-coresmoothstub-village
0.2.9

3 years ago

0.2.7

3 years ago

0.2.8

3 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.2.0

6 years ago

0.0.2

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago