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

zeptomatch

v2.0.0

Published

An absurdly small glob matcher that packs a punch.

Downloads

99,678

Readme

Zeptomatch

An absurdly small glob matcher that packs a punch.

Overview

The following syntax is supported:

| Syntax | Description | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------- | | * | Matches any character, except for the path separator, zero or more times. | | ** | Matches any character zero or more times. If it doesn't span the entire length of a path segment it's interpreted as a * instead. | | ? | Matches any character, except for the path separator, one time. | | \ | Matches the character after it in the glob literally. This is the escape operator. | | [abc] | Matches any of the characters in the class one time. | | [a-z] | Matches any of the characters in the range in the class one time. | | [^abc] | Matches any character, except for the characters the class, and the path separator, o∏ne time. Aliased as [!abc] also. | | [^a-z] | Matches any character, except for the characters in the range in the class, and the path separator, one time. Aliased as [!a-z] also. | | {foo,bar} | Matches any of the alternations, which are separated by a comma, inside the braces. | | {01..99} | Matches any of the numbers in the expanded range. Padding is supported and opt-in. | | {a..zz} | Matches any of the strings in the expanded range. Upper-cased ranges are supported and opt-in. | | !glob | Matches anything except the provided glob. Negations can only be used at the start of the glob. | | !!glob | Matches the provided glob. Negations can only be used at the start of the glob. |

Additional features and details:

  • Zeptomatch works pretty similarly to picomatch, since 1000+ of its tests are being used by this library.
  • Zeptomatch is opinionated, there are no options at all, which helps with keeping it tiny and manageable.
  • Zeptomatch is automatically memoized, the only ways to use it are always the most optimized ones available.
  • Zeptomatch automatically normalizes path separators, since matching Windows-style paths would most likely be a mistake.
  • Zeptomatch supports compiling a glob to a standalone regular expression.
  • Zeptomatch doesn't do anything special for file names starting with a dot.
  • Zeptomatch supports nesting braces indefinitely.

Limitations:

  • POSIX classes (e.g. [:alnum:]) are not supported. Implementing them seems a bit out of scope for a "zepto"-level library.
  • Extglobs (e.g. ?(foo)) are not supported. They might be in the future though.

Install

npm install --save zeptomatch

Usage

import zeptomatch from 'zeptomatch';

// Check if a glob matches a path

zeptomatch ( '*.js', 'abcd' ); // => false
zeptomatch ( '*.js', 'a.js' ); // => true
zeptomatch ( '*.js', 'a.md' ); // => false
zeptomatch ( '*.js', 'a/b.js' ); // => false

// Compile a glob to a regular expression

const re = zeptomatch.compile ( '*.js' ); // => /^[^/]*\.js$/s

Utilities

The following additional utilities are available, as standalone packages:

  • zeptomatch-escape: A little utility for escaping globs before passing them to zeptomatch.

License

MIT © Fabio Spampinato