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

code-analysis-variable-names

v1.0.5

Published

Parse a given javascript source using `acorn` and outputs the frequency of variable/parameters names used in the source.

Downloads

2

Readme

code-analysis-variable-names

What it does

Parse a given javascript source using acorn and outputs the frequency of variable/parameters names used in the source. (it can parse ES6/ES2015 sources)

How to install

You can install it globally or locally, globally being the easiest way to use it:

npm i -g code-analysis-variable-names
cavn index.js

Options

It has some options to adjust the output :

  • app.js : which file to parse
  • mandatory
  • no-top or --top 10 : only display the top 10 of the most used or everything
  • default: --top 30
  • no-summary : don't display the summary in the output
  • default: false
  • no-params : don't take into account the function parameters
  • default: false

Output

For instance, here is the output for react.js :

$ app react.js --top 10
# Total: 2126
# Total Distinct: 884
# Top 10:
42 i
40 invariant
28 nativeEvent
25 id
25 node
24 ReactElement
24 assign
24 props
23 key
23 propName

On a minified file, that's not very useful:

$ app react.min.js --top 10 --no-summary
258 e
214 t
191 n
168 o
158 r
147 i
112 a
87 u
72 s
65 l

jQuery likes loops :

$ app jquery.js --top 10 --no-summary
68 i
36 elem
20 ret
20 type
18 name
13 len
13 length
12 j
11 hooks
11 index

Limitations

It doesn't work with JSX syntax, nor with static propTypes = {} syntax used in ES6 classes.