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

pipemill

v2.3.2

Published

All your favorite *nix utilities in JavaScript.

Downloads

42

Readme

pipemill

All your favorite *nix utilities in JavaScript.

Pipemill allows manipulation of stdin process streams, chaining stdin between a series of JavaScript expressions.

Inspiration taken from the unix pipemill.

Install

npm i -g pipemill

Examples

Replace package.json license


cat package.json | pipepill -p 'stdin.replace("ISC", "MIT")'

Get the userId from an API request

curl https://jsonplaceholder.typicode.com/todos/1 | pipemill --parse -p 'stdin.userId'

Group AWS lambdas by VpcId

# aws lambda list-functions output
# {
#   "Functions": [
#       { "FunctionName": "LambdaA", "VpcConfig": { "VpcId": "vpc-12345" } },
#       { "FunctionName": "LambdaB", "VpcConfig": { "VpcId": "vpc-12345" } },
#       { "FunctionName": "LambdaC", "VpcConfig": { "VpcId": "vpc-123456" } },
#   ]
# }

aws lambda list-functions --region us-east-1 | pipemill --parse -p '_.groupBy(stdin.Functions, "VpcConfig.VpcId")'

# {
#    "vpc-12345": [
#         { "FunctionName": "LambdaA", "VpcConfig": { "VpcId": "vpc-12345" } },
#         { "FunctionName": "LambdaB", "VpcConfig": { "VpcId": "vpc-12345" } }
#     ],
#    "vpc-123456": [{ "FunctionName": "LambdaC", "VpcConfig": { "VpcId": "vpc-123456" } }]
# }

Grab file permissions from ls -l


# extract file permissions from ls -l
ls -l | pipemill --columnAt 0

# produces
# [ 'total',
# '-rw-r--r--',
# '-rw-r--r--',
# '-rwxr-xr-x']

# OR

ls -l | pipemill --split --map 'e.split(/\s+/g)' --map 'e[0]'

Find all unique open source licenses used in node_modules

find ./node_modules -iname 'package.json' | while read file; do 
    cat $file | pipemill --buffer --parse -p 'stdin.license'
done | pipemill --buffer --split -p 'stdin.filter(Boolean)' -p '_.uniq(stdin)'

# Outputs:
# [
#   'MIT',
#   '(MIT OR CC0-1.0)',
#   'Apache-2.0',
#   'BSD-2-Clause',
#   'BSD-3-Clause',
#   'ISC',
#   'CC-BY-3.0',
#   'CC0-1.0'
# ]

Get JSON files from directory

find . -iname '*.json' -type f | while read file; do echo $file | pipemill -p 'stdin.match(/\d+\.json/g)[0]'; done

# Outputs:
# 1.json
# 2.json
# etc ...

Parsing Apache logs


cat logs | pipemill --split -p 'stdin.map(e => e.split(" "))'

# Outputs:
# [
#   [
#     '192.168.2.20',
#     '-',
#     '-',
#     '[28/Jul/2006:10:27:10',
#     '-0300]',
#     '"GET',
#     '/cgi-bin/try/',
#     'HTTP/1.0"',
#     '200',
#     '3395'
#   ],
#   [
#     '127.0.0.1',
#     '-',
#     '-',
#     '[28/Jul/2006:10:22:04',
#     '-0300]',
#     '"GET',
#     '/',
#     'HTTP/1.0"',
#     '200',
#     '2216'
#   ],
#   [
#     '192.168.2.20',
#     '-',
#     '-',
#     '[28/Jul/2006:10:22:04',
#     '-0300]',
#     '"GET',
#     '/',
#     'HTTP/1.0"',
#     '200',
#     '2216'
#   ]
# ]

cat logs | pipemill --split \
    -p 'stdin.map(e => e.split(" "))' \
    -p 'stdin.map(e => e[0])' \
    -p '_.uniq(stdin)'

# Outputs:
# [ '192.168.2.20', '127.0.0.1' ]

cat logs | pipemill --split \
    -p 'stdin.map(e => e.split(" "))' \
    -p 'stdin.map(e => e[0])' \
    -p '_.uniq(stdin)' \
    --join

# Outputs:
# 192.168.2.20
# 127.0.0.1

Get AWS Lambdas grouped by attached layers

aws lambda list-functions --region us-east-1 | pipemill --parse \
-p 'nestedFor(stdin, "Functions.Layers", layer => {
        var arn = layer.Arn.split(":");
        layer.name = arn.slice(arn.length - 2).join(":");
}); return stdin;' \
-p '_.groupBy(stdin.Functions, e => _.map(e.Layers, "name").sort().join(","))'

# {
# 'layerA:92,layerB:32': [
#     {
#       FunctionName: 'lambdaA',
#       FunctionArn: 'arn:aws:lambda:us-east-1:123456789:function:lambdaA',
#       ...
#       Environment: [Object],
#       TracingConfig: [Object],
#       Layers: [Array],
#       PackageType: 'Zip'
#     }
#   ]
# }