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

grepgrep

v0.1.3

Published

A grep-like command that uses JavaScript-flavored regular expressions.

Downloads

104

Readme

GrepGrep (gg)

A grep-like command that uses JavaScript-flavored regular expressions.

This is significantly inspired by, and tested against, the wonderful ripgrep.

Features

  • Regexes are expressed in JavaScript's flavor of regular expressions.
  • Regexes that match this regex: ^/(.*)/([a-z]*)$, will automatically be split into their source and flags parts.
  • Regexes are always executed in something equivalent to ripgrep's "multiline" mode.
  • Binary files are ignored by default, like in ripgrep.
  • Hidden files/folders are ignored by default, like in ripgrep.
  • Ignored files/folders are not searched into by default, like in ripgrep.
  • Searching inside a folder always automatically searches into it recursively.
  • Searching using globs as targets, expressed in zeptomatch's flavor, is supported too.
  • The sorting order of the output is always deterministic, unlike in ripgrep.
  • The most common flags from grep and ripgrep should be supported.

Misfeatures

  • Searching in parallel is supported to some degree, but it's opt-in, since worker threads in JS are pretty bad and they end up making this command slower in many cases...
  • Some flags you may be used to could be missing here, please open an issue about what you need.

Install

npm install -g grepgrep

Usage

gg 0.1.2

USAGE

  gg [pattern] [targets...]
  gg needle src
  gg /^needle/mi src --max-filesize 50K
  gg needle src -i
  gg needle 'node_modules/**/*.js'
  gg $'ascii\'string' src --no-ignore --hidden

ARGUMENTS

  [pattern]     The JavaScript regex to search for
  [targets...]  The files or directories to search into, or globs

OPTIONS

  --help                              Display help for the command
  --version, -v                       Display the version number
  --after-context, -A <number>        Print this number of lines after each match
  --before-context, -B <number>       Print this number of lines before each match
  --binary                            Search into binary files too
  --byte-offset, -b                   Print the byte offset for each match
  --context, -C <number>              Print this number of lines before and after each match
  --context-separator <string>        The string to print between non-adjacent output lines
  --count, -c                         Print only the number of line matches
  --count-matches                     Print only the number of individual matches
  --field-context-separator <string>  The string to print in the gutter for context lines
  --field-match-separator <string>    The string to print in the gutter for matching lines
  --filename, -H                      Print file names before each match
  --files                             Print the paths of files that would be searched into
  --files-with-match, -l              Print only the paths of files with matches
  --files-without-match, -L           Print only the paths of files without matches
  --fixed-strings, -F                 Treat the pattern as a literal string instead of a regex
  --heading                           Print file names as headings before the matches for each file
  --hidden, -.                        Search into hidden files and hidden directories too
  --ignore-case, -i                   Ignore the casing when searching
  --line-number, -n                   Print the line number for each match
  --line-regexp, -x                   Consider only matches surrounded by line boundaries
  --max-count, -m <number>            Maximum number of matching lines to print
  --max-depth, -d <number>            Maximum directories depth to search into
  --max-filesize <number+suffix?>     Maximum size of each file to search into, with optional G/M/K/B suffix
  --min-filesize <number+suffix?>     Minimum size of each file to search into, with optional G/M/K/B suffix
  --no-ignore                         Do not respect .gitignore, .ignore and .rgignore files
  --no-ignore-dot                     Do not respect .ignore and .rgignore files
  --no-ignore-parent                  Do not look for ignore files above the current work directory
  --no-ignore-vcs                     Do not respect .gitignore files
  --only-matching, -o                 Print only the matched parts in each line, individually
  --passthru                          Print all lines in each file
  --quiet, -q                         Do not print anything to stdout
  --sort <dimension>                  Sort results ascendingly by accessed/created/modified/path/size
  --sortr <dimension>                 Sort results descendingly by accessed/created/modified/path/size
  --threads, -j <number>              Number of worker threads to use for searching
  --type, -t <extensions...>          Search only into files with the specified extensions
  --type-not, -T <extensions...>      Do not search into files with the specified extensions
  --word-regexp, -w                   Consider only matches surrounded by word boundaries

License

MIT © Fabio Spampinato