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

simple-glob

v0.2.0

Published

Simplified globbing, same as Grunt

Downloads

6,638

Readme

simple-glob

Simplified globbing, same as Grunt

Build Status Dependency Status NPM version Views

NPM

The inspiration for this project was to simplify globbing patterns to work the same way many are familiar with (i.e., the globbing patterns in Grunt). Instead of reinventing the wheel, I figured I'd just extract the code directly from Grunt's code base to get the exact same functionality that we know and love. Now, we can all enjoy the same globbing, even outside of Grunt!

Full disclaimer: The code contained in this project is 99% the original work of the Grunt.js team. I only renamed a couple things and moved things around a bit. I take no credit whatsoever and the original license is in tact, according to license conditions.

Note: The following documentation was taken mostly from Grunt's Configuring Tasks page.

Globbing patterns

It is often impractical to specify all source filepaths individually, so simple-glob supports filename expansion (also know as globbing) via the built-in node-glob and minimatch libraries.

While this isn't a comprehensive tutorial on globbing patterns, know that in a filepath:

  • * matches any number of characters, but not /
  • ? matches a single character, but not /
  • ** matches any number of characters, including /, as long as it's the only thing in a path part
  • {} allows for a comma-separated list of "or" expressions
  • ! at the beginning of a pattern will negate the match

All most people need to know is that foo/*.js will match all files ending with .js in the foo/ subdirectory, but foo/**/*.js will match all files ending with .js in the foo/ subdirectory and all of its subdirectories.

Also, in order to simplify otherwise complicated globbing patterns, simple-glob allows arrays of file paths or globbing patterns to be specified. Patterns are processed in-order, with !-prefixed matches excluding matched files from the result set. The result set is uniqued.

For example:

var glob = require('simple-glob');

// You can specify single files:
glob('foo/this.js');
// Or arrays of files:
glob(['foo/this.js', 'foo/that.js', 'foo/the-other.js']);
// Or you can generalize with a glob pattern:
glob('foo/th*.js');

// This single node-glob pattern:
glob('foo/{a,b}*.js');
// Could also be written like this:
glob(['foo/a*.js', 'foo/b*.js']);

// All .js files, in foo/, in alpha order:
glob(['foo/*.js']);
// Here, bar.js is first, followed by the remaining files, in alpha order:
glob(['foo/bar.js', 'foo/*.js']);

// All files except for bar.js, in alpha order:
glob(['foo/*.js', '!foo/bar.js']);
// All files in alpha order, but with bar.js at the end.
glob(['foo/*.js', '!foo/bar.js', 'foo/bar.js']);

For more on glob pattern syntax, see the node-glob and minimatch documentation.

Bitdeli Badge