Deno logoDeno

§Variables

§Functions

  • common

    Determines the common path from a set of paths, using an optional separator, which defaults to the OS default separator.

          import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
          const p = common([
            "./deno/std/path/mod.ts",
            "./deno/std/fs/mod.ts",
          ]);
          console.log(p); // "./deno/std/"
    
  • globToRegExp

    Convert a glob string to a regular expression.

    Tries to match bash glob expansion as closely as possible.

    Basic glob syntax:

    • * - Matches everything without leaving the path segment.
    • ? - Matches any single character.
    • {foo,bar} - Matches foo or bar.
    • [abcd] - Matches a, b, c or d.
    • [a-d] - Matches a, b, c or d.
    • [!abcd] - Matches any single character besides a, b, c or d.
    • [[:<class>:]] - Matches any character belonging to <class>.
    • \ - Escapes the next character for an os other than "windows".
    • ` - Escapes the next character for os set to "windows".
    • / - Path separator.
    • \ - Additional path separator only for os set to "windows".

    Extended syntax:

    • Requires { extended: true }.
    • ?(foo|bar) - Matches 0 or 1 instance of {foo,bar}.
    • @(foo|bar) - Matches 1 instance of {foo,bar}. They behave the same.
    • *(foo|bar) - Matches n instances of {foo,bar}.
    • +(foo|bar) - Matches n > 0 instances of {foo,bar}.
    • !(foo|bar) - Matches anything other than {foo,bar}.
    • See https://www.linuxjournal.com/content/bash-extended-globbing.

    Globstar syntax:

    Note the following properties:

    • The generated RegExp is anchored at both start and end.
    • Repeating and trailing separators are tolerated. Trailing separators in the provided glob have no meaning and are discarded.
    • Absolute globs will only match absolute paths, etc.
    • Empty globs will match nothing.
    • Any special glob syntax must be contained to one path segment. For example, ?(foo|bar/baz) is invalid. The separator will take precedence and the first segment ends with an unclosed group.
    • If a path segment ends with unclosed groups or a dangling escape prefix, a parse error has occurred. Every character for that segment is taken literally in this event.

    Limitations:

    • A negative group like !(foo|bar) will wrongly be converted to a negative look-ahead followed by a wildcard. This means that !(foo).js will wrongly fail to match foobar.js, even though foobar is not foo. Effectively, !(foo|bar) is treated like !(@(foo|bar)*). This will work correctly if the group occurs not nested at the end of the segment.
  • isGlob

    Test whether the given string is a glob

  • joinGlobs

    Like join(), but doesn't collapse "**/.." when globstar is true.

  • normalizeGlob

    Like normalize(), but doesn't collapse "**/.." when globstar is true.

§Interfaces

§Type Aliases