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

ssed

v1.1.0

Published

Fed up with trying to remember sed's weird regex support? Me, too.

Downloads

68

Readme

ssed

I was fed up with sed's obtuse regular expression syntax/support. Yeah, when JavaScript has a more sensible implementation, you know you have troubles.

15 minutes later I had ssed. I think the README took longer than the tool!

Installation

npm install -g ssed

Usage

> commands | ssed

All commands use a "g/re/p"-like syntax:

cmd/match[/replace]

All rules are run on every line, the output of one is fed into the next. If any step filters the line, the rest of the rules are skipped and the next line is processed.

Substitute
sub/pattern/replace
s/pattern/replace

Replaces the first match.

echo what a test | ssed sub/w/W
=> What a test
echo what a test | ssed 's/(\w+)/$1$1'
=> whatwhat a test
Global Substitute
gsub/pattern/replace
g/pattern/replace

Replaces all occurences of the pattern.

echo what a test | ssed gsub/t/T
=> whaT a TesT
echo what a test | ssed g/[a-su-z]/.
=> ...t . t..t
"Take"
take/pattern
t/pattern

Prints the matching regex (or the entire line if there is no match).

echo 'what a test' | ssed 'take/t\w+'
=> test
echo -e "what
> a
> great test" | ssed '+/t\w+t'
=> what
a
test
"Nth"
1/pattern
2/pattern
3/pattern
...

Prints the n-th group in the regex (or the entire line if there is no match).

echo 'what a test' | ssed '1/(\w+) (\w+) (\w+)'
=> what
echo 'what a test' | ssed '2/(\w+) (\w+) (\w+)'
=> a
echo 'what a test' | ssed '3/(\w+) (\w+) (\w+)'
=> test
"Remove"
remove/pattern
rm/pattern
r/pattern

Removes the matching part of the regex (or the entire line if there is no match).

echo 'what a test' | ssed 'rm/t\w+'
=> what a
echo -e "what
> a
> great test" | ssed 'rm/t\w+t'
=> what
a
great
On
on/pattern
o/pattern

Turns on printing starting at the matching line. Until then, no lines will be printed. This feature uses a simple global "printOn" boolean, so don't go nesting multiple on commands, they'll step all over each other.

echo -e "what
> a
> great test" | ssed 'on/^a'
=> a
great test
After
after/pattern
a/pattern

Just like on but doesn't print the matching line, it starts printing on the following line.

Off
off/pattern
f/pattern

Turns off printing, only useful following an on or after command.

echo -e "this
> is
> a
> really
> great
> test" | ssed 'on/^a' off/test
=> a
really
great
Print
print/pattern
p/pattern

Prints the line if the pattern matches, skips it otherwise. I'm pretty sure this is an actual sed command! But who knows, sed is a mess.

echo -e "you
> get
> it
> by
> now,
> right?" | ssed 'p/[a-m]'
=> get
it
by
right?
Kill
kill/pattern
k/pattern

Skips matching lines, inverse of print.

echo -e "you
get
it
by
now,
right?" | ssed 'p/[a-m]'
=> you
now,
Delimiters

Other delimiters are supported. Trailing delimiter is optional.

sub|match|replace
s/match/replace/

Bracket delimiters “work”, but they don't have to actually match, e.g. these are all equivalent:

g{match}replace
g}match{replace
g}match}replace
g{match{replace
As-is

I offer this up as-is. I'm happy to discuss PRs and bug fixes, but feature requests will be summarily closed. Who has time for lazy programmers in <?= date('Y') %>!?