npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parse-glob

v3.0.4

Published

Parse a glob pattern into an object of tokens.

Downloads

9,425,013

Readme

parse-glob NPM version Build Status

Parse a glob pattern into an object of tokens.

Changes from v1.0.0 to v3.0.4

  • all path-related properties are now on the path object
  • all boolean properties are now on the is object
  • adds base property

See the properties section for details.

Install with npm

$ npm i parse-glob --save
  • parses 1,000+ glob patterns in 29ms (2.3 GHz Intel Core i7)
  • Extensive unit tests (more than 1,000 lines), covering wildcards, globstars, character classes, brace patterns, extglobs, dotfiles and other complex patterns.

See the tests for hundreds of examples.

Usage

var parseGlob = require('parse-glob');

Example

parseGlob('a/b/c/**/*.{yml,json}');

Returns:

{ orig: 'a/b/c/**/*.{yml,json}',
  is:
   { glob: true,
     negated: false,
     extglob: false,
     braces: true,
     brackets: false,
     globstar: true,
     dotfile: false,
     dotdir: false },
  glob: '**/*.{yml,json}',
  base: 'a/b/c',
  path:
   { dirname: 'a/b/c/**/',
     basename: '*.{yml,json}',
     filename: '*',
     extname: '.{yml,json}',
     ext: '{yml,json}' } }

Properties

The object returned by parseGlob has the following properties:

  • orig: a copy of the original, unmodified glob pattern
  • is: an object with boolean information about the glob:
    • glob: true if the pattern actually a glob pattern
    • negated: true if it's a negation pattern (!**/foo.js)
    • extglob: true if it has extglobs (@(foo|bar))
    • braces: true if it has braces ({1..2} or .{txt,md})
    • brackets: true if it has POSIX brackets ([[:alpha:]])
    • globstar: true if the pattern has a globstar (double star, **)
    • dotfile: true if the pattern should match dotfiles
    • dotdir: true if the pattern should match dot-directories (like .git)
  • glob: the glob pattern part of the string, if any
  • base: the non-glob part of the string, if any
  • path: file path segments
    • dirname: directory
    • basename: file name with extension
    • filename: file name without extension
    • extname: file extension with dot
    • ext: file extension without dot

Related

  • glob-base: Returns an object with the (non-glob) base path and the actual pattern. | homepage
  • glob-parent: Strips glob magic from a string to provide the parent path | homepage
  • glob-path-regex: Regular expression for matching the parts of glob pattern. | homepage
  • is-glob: Returns true if the given string looks like a glob pattern. | homepage
  • micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… more | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Tests

Install dev dependencies:

$ npm i -d && npm test

Author

Jon Schlinkert

License

Copyright © 2014-2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on September 22, 2015.