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

elm-xref

v4.1.1

Published

Cross referencing tool for Elm - find usages and unused code

Downloads

109

Readme

elm-xref Build Status Build status

Cross-referencing tools for Elm. Find unused code, and figure out where specific functions are used.

Installation

npm i -g elm-xref

Usage

To index a project and find unused functions, execute elm-xref in the same directory as your elm.json. This works for both application as well as package projects.

To find usages of a function, specify the fully qualified function name as an argument.

Examples on rtfeldman/elm-spa-example@c8c3201:

# To find unused functions:
$ elm-xref
Unused functions:
 - /Users/ilias/Src/elm/elm-spa-example/src/Api.elm:294:1       Api.cacheStorageKey
 - /Users/ilias/Src/elm/elm-spa-example/src/Api.elm:299:1       Api.credStorageKey
 - /Users/ilias/Src/elm/elm-spa-example/src/Api.elm:73:1        Api.decode
 - /Users/ilias/Src/elm/elm-spa-example/src/Author.elm:120:1    Author.follow
 - /Users/ilias/Src/elm/elm-spa-example/src/Author.elm:125:1    Author.unfollow
 - /Users/ilias/Src/elm/elm-spa-example/src/Avatar.elm:55:1     Avatar.toMaybeString
 - /Users/ilias/Src/elm/elm-spa-example/src/Email.elm:30:7      Email.Email
 - /Users/ilias/Src/elm/elm-spa-example/src/Email.elm:44:1      Email.decoder
 - /Users/ilias/Src/elm/elm-spa-example/src/Email.elm:39:1      Email.encode
 - /Users/ilias/Src/elm/elm-spa-example/src/Email.elm:34:1      Email.toString
 - /Users/ilias/Src/elm/elm-spa-example/src/Main.elm:112:7      Main.ChangedRoute
 - /Users/ilias/Src/elm/elm-spa-example/src/Page.elm:26:7       Page.Login
 - /Users/ilias/Src/elm/elm-spa-example/src/Page.elm:27:7       Page.Register
 - /Users/ilias/Src/elm/elm-spa-example/src/Page.elm:28:7       Page.Settings
 - /Users/ilias/Src/elm/elm-spa-example/src/Page/Settings.elm:90:7      Page.Settings.Valid
 - /Users/ilias/Src/elm/elm-spa-example/src/Page/Settings.elm:456:1     Page.Settings.nothingIfEmpty
 - /Users/ilias/Src/elm/elm-spa-example/src/Route.elm:19:7      Route.Root

# To find usages of `Maybe.Just`:
$ elm-xref Maybe.Just
Usages:
 - Api.storeCredWith (113)
 - Article.faveDecoder (231)
 - Article.favorite (221)
 - Article.Comment.post (80, 81)
 - Article.Slug.urlParser (22)
 - Author.followDecoder (145)
 - Author.requestFollow (132)
 - Main.changeRouteTo (179)
 - Page.Article.Editor.create (535, 536)
 - Page.Article.Editor.edit (560)
 - Page.Article.Editor.getSlug (583, 586, 589, 592, 595)
 - Page.Settings.nothingIfEmpty (462)
 - Session.cred (42)
 - Session.viewer (32)
 - Username.urlParser (43)

Value constructors of types are also tracked. Note that only constructing values is tracked as usage - pattern matches and destructuring are not tracked as usage.

Usage tracking isn't terribly clever. This tool only does static analysis and does not attempt to evaluate any expressions. As a result, functions that only appear in "obviously unreachable code" (i.e. conditionals that always evaluate to False) do very much count as usage.

Roadmap

  • [ ] Support whitelisting (f.e. with phantom types or internal modules with consistent API)
  • [ ] Show unused parameters
  • [ ] Support type aliases (as function and in type signatures)

License

See the LICENSE file.