Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tinyglobby

SuperchupuDev36.1mMIT0.2.12TypeScript support: included

A fast and minimal alternative to globby and fast-glob

glob, patterns, fast, implementation

readme

tinyglobby

npm version monthly downloads

A fast and minimal alternative to globby and fast-glob, meant to behave the same way.

Both globby and fast-glob present some behavior no other globbing lib has, which makes it hard to manually replace with something smaller and better.

This library uses only two subdependencies, compared to globby's 23 and fast-glob's 17.

Usage

import { glob, globSync } from 'tinyglobby';

await glob(['files/*.ts', '!**/*.d.ts'], { cwd: 'src' });
globSync(['src/**/*.ts'], { ignore: ['**/*.d.ts'] });

API

  • glob(patterns: string | string[], options: GlobOptions): Promise<string[]>: Returns a promise with an array of matches.
  • globSync(patterns: string | string[], options: GlobOptions): string[]: Returns an array of matches.
  • convertPathToPattern(path: string): string: Converts a path to a pattern depending on the platform.
  • escapePath(path: string): string: Escapes a path's special characters depending on the platform.
  • isDynamicPattern(pattern: string, options?: GlobOptions): boolean: Checks if a pattern is dynamic.

Options

  • patterns: An array of glob patterns to search for. Defaults to ['**/*'].
  • ignore: An array of glob patterns to ignore.
  • cwd: The current working directory in which to search. Defaults to process.cwd().
  • absolute: Whether to return absolute paths. Defaults to false.
  • dot: Whether to allow entries starting with a dot. Defaults to false.
  • deep: Maximum depth of a directory. Defaults to Infinity.
  • followSymbolicLinks: Whether to traverse and include symbolic links. Defaults to true.
  • caseSensitiveMatch: Whether to match in case-sensitive mode. Defaults to true.
  • expandDirectories: Whether to expand directories. Disable to best match fast-glob. Defaults to true.
  • onlyDirectories: Enable to only return directories. Disables onlyFiles if set. Defaults to false.
  • onlyFiles: Enable to only return files. Defaults to true.
  • debug: Enable debug logs. Useful for development purposes.

Used by

tinyglobby is downloaded many times by projects all around the world. Here's a list of notable projects that use it:

changelog

0.2.12

Fixed

  • Using .. inside ignore patterns could sometimes make the optimizer ignore parent directories

Changed

  • The debug option now logs skipped directories

0.2.11

I've opened a sponsorships page! Consider sponsoring at https://github.com/sponsors/SuperchupuDev if you'd like to support the development of this project. This is a huge release in a technical aspect that took many months to get right.

Added

  • New optimizer to avoid crawling directories with entries that will never match.

    This is a huge performance improvement and it should solve most if not all performance issues in the library.

    This has taken many months to figure out and implement and has gotten through three different implementations with the help and/or advice of many people, most from e18e:

  • Other performance improvements, such as early returning without patterns by bluwy and micro-optimizations by Torathion

  • debug option. Useful for development purposes

Fixed

  • Usage of escaped patterns with a cwd that partially matches the pattern
  • Unsupported usages of backslashes making the library really slow. It should be way faster now thanks to the new optimizer

0.2.10

Added

  • Re-enabled symlinks resolution. Big thanks to thecodrr for fixing the critical bug upstream

Fixed

  • Processing of absolute negative patterns
  • Negative ignore patterns are now not processed for consistency with fast-glob

0.2.9

Changed

  • Temporarily reverted resolution of symbolic links due to a critical bug. See #54 for more info

0.2.8

Fixed

  • Escaped symbols (i.e. "\\[") in the inferred common root producing empty matches

Changed

  • Improved the common root inference algorithm to optimize non-trailing ** patterns

0.2.7

Added

  • Support for providing patterns as a string
  • followSymbolicLinks option
  • escapePath utility function by @benmccann
  • isDynamicPattern utility function
  • convertPathToPattern utility function

Fixed

  • . as a pattern now works as expected
  • Globbing no longer returns an empty string when matching the root directory
  • Handling of escaped symbols in patterns

Changed

  • Relicensed the project to the MIT license
  • Disabled source maps on release builds for smaller bundle size
  • Improved the common root inference algorithm

0.2.6

Added

  • Full support for absolute paths as patterns
  • caseSensitiveMatch option

0.2.5

Fixed

  • Using a pattern that doesn't end with special characters with expandDirectories disabled no longer produces incorrect matches

0.2.4

Fixed

  • Using a pattern that can't infer a common root with absolute enabled no longer produces incorrect matches

0.2.3

Added

  • Support for leading ../ in patterns

Changed

  • A common root is now inferred from the patterns if possible to avoid unnecessary crawling

0.2.2

Added

  • Basic handling of absolute patterns

Fixed

  • Adding trailing slashes to the end of patterns no longer returns incorrect results
  • Matching directories without expandDirectories without a trailing slash now works correctly

0.2.1

Fixed

  • Using an empty array of patterns no longer acts as ['**/*']

Changed

  • Windows now uses forward slashes instead of backslashes
  • Modified ignore behavior to vastly improve performance when ignoring whole directories

0.2.0

BREAKING CHANGES

The library no longer sets dot to true internally by default. It now defaults it to false, just like globby and fast-glob.

You can configure this by using the new dot option.

Added

  • Support for specifying the patterns option as the first argument to better approach a drop-in globby replacement
await glob(['src/*.ts'], { ignore: ['_secret'] });

// you can still specify it in the options object
await glob({ patterns: ['src/*.ts'], ignore: ['_secret'] });
  • Support for non-absolute paths in cwd
  • dot option
  • deep option
  • onlyFiles option

0.1.2

Added

  • onlyDirectories option

0.1.1

Added

  • ignore option
  • expandDirectories option