minimatch

  • Version 10.2.4
  • Published
  • 535 kB
  • 1 dependency
  • BlueOak-1.0.0 license

Install

npm i minimatch
yarn add minimatch
pnpm add minimatch

Overview

a glob matcher in javascript

Index

Variables

variable GLOBSTAR

const GLOBSTAR: Symbol;

    variable minimatch

    const minimatch: {
    (p: string, pattern: string, options?: MinimatchOptions): boolean;
    sep: Sep;
    GLOBSTAR: typeof GLOBSTAR;
    filter: (pattern: string, options?: MinimatchOptions) => (p: string) => boolean;
    defaults: (def: MinimatchOptions) => typeof minimatch;
    braceExpand: (pattern: string, options?: MinimatchOptions) => string[];
    makeRe: (pattern: string, options?: MinimatchOptions) => false | MMRegExp;
    match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];
    AST: typeof AST;
    Minimatch: typeof Minimatch;
    escape: (
    s: string,
    {
    windowsPathsNoEscape,
    magicalBraces,
    }?: Pick<MinimatchOptions, 'windowsPathsNoEscape' | 'magicalBraces'>
    ) => string;
    unescape: (
    s: string,
    {
    windowsPathsNoEscape,
    magicalBraces,
    }?: Pick<MinimatchOptions, 'windowsPathsNoEscape' | 'magicalBraces'>
    ) => string;
    };

      variable sep

      const sep: Sep;

        Functions

        function braceExpand

        braceExpand: (pattern: string, options?: MinimatchOptions) => string[];

          function defaults

          defaults: (def: MinimatchOptions) => typeof minimatch;

            function escape

            escape: (
            s: string,
            {
            windowsPathsNoEscape,
            magicalBraces,
            }?: Pick<MinimatchOptions, 'windowsPathsNoEscape' | 'magicalBraces'>
            ) => string;
            • Escape all magic characters in a glob pattern.

              If the MinimatchOptions.windowsPathsNoEscape option is used, then characters are escaped by wrapping in [], because a magic character wrapped in a character class can only be satisfied by that exact character. In this mode, \ is _not_ escaped, because it is not interpreted as a magic character, but instead as a path separator.

              If the MinimatchOptions.magicalBraces option is used, then braces ({ and }) will be escaped.

            function filter

            filter: (pattern: string, options?: MinimatchOptions) => (p: string) => boolean;

              function makeRe

              makeRe: (pattern: string, options?: MinimatchOptions) => false | MMRegExp;

                function match

                match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];

                  function unescape

                  unescape: (
                  s: string,
                  {
                  windowsPathsNoEscape,
                  magicalBraces,
                  }?: Pick<MinimatchOptions, 'windowsPathsNoEscape' | 'magicalBraces'>
                  ) => string;
                  • Un-escape a string that has been escaped with escape.

                    If the MinimatchOptions.windowsPathsNoEscape option is used, then square-bracket escapes are removed, but not backslash escapes.

                    For example, it will turn the string '[*]' into *, but it will not turn '\\*' into '*', because \ is a path separator in windowsPathsNoEscape mode.

                    When windowsPathsNoEscape is not set, then both square-bracket escapes and backslash escapes are removed.

                    Slashes (and backslashes in windowsPathsNoEscape mode) cannot be escaped or unescaped.

                    When magicalBraces is not set, escapes of braces ({ and }) will not be unescaped.

                  Classes

                  class AST

                  class AST {}

                    constructor

                    constructor(type: ExtglobType, parent?: AST, options?: MinimatchOptions);

                      property depth

                      readonly depth: number;

                        property hasMagic

                        readonly hasMagic: boolean;

                          property id

                          id: number;

                            property options

                            readonly options: MinimatchOptions;

                              property type

                              type: ExtglobType;

                                method clone

                                clone: (parent: AST) => AST;

                                  method copyIn

                                  copyIn: (part: AST | string) => void;

                                    method fromGlob

                                    static fromGlob: (pattern: string, options?: MinimatchOptions) => AST;

                                      method isEnd

                                      isEnd: () => boolean;

                                        method isStart

                                        isStart: () => boolean;

                                          method push

                                          push: (...parts: (string | AST)[]) => void;

                                            method toJSON

                                            toJSON: () => any[];

                                              method toMMPattern

                                              toMMPattern: () => MMRegExp | string;

                                                method toRegExpSource

                                                toRegExpSource: (
                                                allowDot?: boolean
                                                ) => [re: string, body: string, hasMagic: boolean, uflag: boolean];

                                                  method toString

                                                  toString: () => string;

                                                    class Minimatch

                                                    class Minimatch {}

                                                      constructor

                                                      constructor(pattern: string, options?: MinimatchOptions);

                                                        property comment

                                                        comment: boolean;

                                                          property empty

                                                          empty: boolean;

                                                            property globParts

                                                            globParts: string[][];

                                                              property globSet

                                                              globSet: string[];

                                                                property isWindows

                                                                isWindows: boolean;

                                                                  property maxGlobstarRecursion

                                                                  maxGlobstarRecursion: number;

                                                                    property negate

                                                                    negate: boolean;

                                                                      property nocase

                                                                      nocase: boolean;

                                                                        property nonegate

                                                                        nonegate: boolean;

                                                                          property options

                                                                          options: MinimatchOptions;

                                                                            property partial

                                                                            partial: boolean;

                                                                              property pattern

                                                                              pattern: string;

                                                                                property platform

                                                                                platform: Platform;

                                                                                  property preserveMultipleSlashes

                                                                                  preserveMultipleSlashes: boolean;

                                                                                    property regexp

                                                                                    regexp: false | MMRegExp;

                                                                                      property set

                                                                                      set: ParseReturnFiltered[][];

                                                                                        property windowsNoMagicRoot

                                                                                        windowsNoMagicRoot: boolean;

                                                                                          property windowsPathsNoEscape

                                                                                          windowsPathsNoEscape: boolean;

                                                                                            method adjascentGlobstarOptimize

                                                                                            adjascentGlobstarOptimize: (globParts: string[][]) => string[][];

                                                                                              method braceExpand

                                                                                              braceExpand: () => string[];

                                                                                                method debug

                                                                                                debug: (..._: any[]) => void;

                                                                                                  method defaults

                                                                                                  static defaults: (def: MinimatchOptions) => typeof Minimatch;

                                                                                                    method firstPhasePreProcess

                                                                                                    firstPhasePreProcess: (globParts: string[][]) => string[][];

                                                                                                      method hasMagic

                                                                                                      hasMagic: () => boolean;

                                                                                                        method levelOneOptimize

                                                                                                        levelOneOptimize: (globParts: string[][]) => string[][];

                                                                                                          method levelTwoFileOptimize

                                                                                                          levelTwoFileOptimize: (parts: string | string[]) => string[];

                                                                                                            method make

                                                                                                            make: () => void;

                                                                                                              method makeRe

                                                                                                              makeRe: () => false | MMRegExp;

                                                                                                                method match

                                                                                                                match: (f: string, partial?: boolean) => boolean;

                                                                                                                  method matchOne

                                                                                                                  matchOne: (file: string[], pattern: ParseReturn[], partial?: boolean) => boolean;

                                                                                                                    method parse

                                                                                                                    parse: (pattern: string) => ParseReturn;

                                                                                                                      method parseNegate

                                                                                                                      parseNegate: () => void;

                                                                                                                        method partsMatch

                                                                                                                        partsMatch: (
                                                                                                                        a: string[],
                                                                                                                        b: string[],
                                                                                                                        emptyGSMatch?: boolean
                                                                                                                        ) => false | string[];

                                                                                                                          method preprocess

                                                                                                                          preprocess: (globParts: string[][]) => string[][];

                                                                                                                            method secondPhasePreProcess

                                                                                                                            secondPhasePreProcess: (globParts: string[][]) => string[][];

                                                                                                                              method slashSplit

                                                                                                                              slashSplit: (p: string) => string[];

                                                                                                                                Interfaces

                                                                                                                                interface MinimatchOptions

                                                                                                                                interface MinimatchOptions {}

                                                                                                                                  property allowWindowsEscape

                                                                                                                                  allowWindowsEscape?: boolean;

                                                                                                                                  property braceExpandMax

                                                                                                                                  braceExpandMax?: number;
                                                                                                                                  • max number of {...} patterns to expand. Default 100_000.

                                                                                                                                  property debug

                                                                                                                                  debug?: boolean;
                                                                                                                                  • print LOTS of debugging output

                                                                                                                                  property dot

                                                                                                                                  dot?: boolean;
                                                                                                                                  • allow matches that start with . even if the pattern does not

                                                                                                                                  property flipNegate

                                                                                                                                  flipNegate?: boolean;
                                                                                                                                  • invert the results of negated matches

                                                                                                                                  property magicalBraces

                                                                                                                                  magicalBraces?: boolean;
                                                                                                                                  • consider braces to be "magic" for the purpose of hasMagic

                                                                                                                                  property matchBase

                                                                                                                                  matchBase?: boolean;
                                                                                                                                  • If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, a?b would match the path /xyz/123/acb, but not /xyz/acb/123.

                                                                                                                                  property maxExtglobRecursion

                                                                                                                                  maxExtglobRecursion?: number;
                                                                                                                                  • Max depth to traverse for nested extglobs like *(a|b|c)

                                                                                                                                    Default is 2, which is quite low, but any higher value swiftly results in punishing performance impacts. Note that this is *not* relevant when the globstar types can be safely coalesced into a single set.

                                                                                                                                    For example, *(a|@(b|c)|d) would be flattened into *(a|b|c|d). Thus, many common extglobs will retain good performance and never hit this limit, even if they are excessively deep and complicated.

                                                                                                                                    If the limit is hit, then the extglob characters are simply not parsed, and the pattern effectively switches into noextglob: true mode for the contents of that nested sub-pattern. This will typically _not_ result in a match, but is considered a valid trade-off for security and performance.

                                                                                                                                  property maxGlobstarRecursion

                                                                                                                                  maxGlobstarRecursion?: number;
                                                                                                                                  • Max number of non-adjacent ** patterns to recursively walk down.

                                                                                                                                    The default of 200 is almost certainly high enough for most purposes, and can handle absurdly excessive patterns.

                                                                                                                                  property nobrace

                                                                                                                                  nobrace?: boolean;
                                                                                                                                  • do not expand {x,y} style braces

                                                                                                                                  property nocase

                                                                                                                                  nocase?: boolean;
                                                                                                                                  • ignore case

                                                                                                                                  property nocaseMagicOnly

                                                                                                                                  nocaseMagicOnly?: boolean;
                                                                                                                                  • ignore case only in wildcard patterns

                                                                                                                                  property nocomment

                                                                                                                                  nocomment?: boolean;
                                                                                                                                  • do not treat patterns starting with # as a comment

                                                                                                                                  property noext

                                                                                                                                  noext?: boolean;
                                                                                                                                  • do not expand extglobs like +(a|b)

                                                                                                                                  property noglobstar

                                                                                                                                  noglobstar?: boolean;
                                                                                                                                  • treat ** the same as *

                                                                                                                                  property nonegate

                                                                                                                                  nonegate?: boolean;
                                                                                                                                  • do not treat patterns starting with ! as a negation

                                                                                                                                  property nonull

                                                                                                                                  nonull?: boolean;
                                                                                                                                  • return the pattern if nothing matches

                                                                                                                                  property optimizationLevel

                                                                                                                                  optimizationLevel?: number;
                                                                                                                                  • A number indicating the level of optimization that should be done to the pattern prior to parsing and using it for matches.

                                                                                                                                  property partial

                                                                                                                                  partial?: boolean;
                                                                                                                                  • Compare a partial path to a pattern. As long as the parts of the path that are present are not contradicted by the pattern, it will be treated as a match. This is useful in applications where you're walking through a folder structure, and don't yet have the full path, but want to ensure that you do not walk down paths that can never be a match.

                                                                                                                                  property platform

                                                                                                                                  platform?: Platform;
                                                                                                                                  • operating system platform

                                                                                                                                  property preserveMultipleSlashes

                                                                                                                                  preserveMultipleSlashes?: boolean;
                                                                                                                                  • do not collapse multiple / into a single /

                                                                                                                                  property windowsNoMagicRoot

                                                                                                                                  windowsNoMagicRoot?: boolean;
                                                                                                                                  • When a pattern starts with a UNC path or drive letter, and in nocase:true mode, do not convert the root portions of the pattern into a case-insensitive regular expression, and instead leave them as strings.

                                                                                                                                    This is the default when the platform is win32 and nocase:true is set.

                                                                                                                                  property windowsPathsNoEscape

                                                                                                                                  windowsPathsNoEscape?: boolean;
                                                                                                                                  • treat \\ as a path separator, not an escape character

                                                                                                                                  Type Aliases

                                                                                                                                  type MMRegExp

                                                                                                                                  type MMRegExp = RegExp & {
                                                                                                                                  _src?: string;
                                                                                                                                  _glob?: string;
                                                                                                                                  };

                                                                                                                                    type ParseReturn

                                                                                                                                    type ParseReturn = ParseReturnFiltered | false;

                                                                                                                                      type ParseReturnFiltered

                                                                                                                                      type ParseReturnFiltered = string | MMRegExp | typeof GLOBSTAR;

                                                                                                                                        type Platform

                                                                                                                                        type Platform =
                                                                                                                                        | 'aix'
                                                                                                                                        | 'android'
                                                                                                                                        | 'darwin'
                                                                                                                                        | 'freebsd'
                                                                                                                                        | 'haiku'
                                                                                                                                        | 'linux'
                                                                                                                                        | 'openbsd'
                                                                                                                                        | 'sunos'
                                                                                                                                        | 'win32'
                                                                                                                                        | 'cygwin'
                                                                                                                                        | 'netbsd';

                                                                                                                                          type Sep

                                                                                                                                          type Sep = '\\' | '/';

                                                                                                                                            Package Files (4)

                                                                                                                                            Dependencies (1)

                                                                                                                                            Dev Dependencies (6)

                                                                                                                                            Peer Dependencies (0)

                                                                                                                                            No peer dependencies.

                                                                                                                                            Badge

                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/minimatch.

                                                                                                                                            • Markdown
                                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/minimatch)
                                                                                                                                            • HTML
                                                                                                                                              <a href="https://www.jsdocs.io/package/minimatch"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>