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

redflare

v0.0.0

Published

Experimental JavaScript static analyzer

Downloads

2

Readme

Redflare

Experimental early work-in-progress JavaScript static analyzer tool.

Design goals:

  • Full program analyzer Tool should work with the entire program codebase to produce the best results. This allows to track every call site of each function and highlight all the dead code.
  • No extra syntax It shouldn't introduce any custom type definitions or annotations. Platform or library APIs should be defined using standard JavaScript.
  • Static assertions Adds static assertions to JavaScript, a way to ensure conditions are always true without running the program.

Installation

The fastest way to get started is to install Redflare CLI globally.

npm install redflare -g

Usage

First, make sure you use modern version of Node like v4 or newer. Redflare needs program entry point as an input (for now there is no support for require() so all code needs to be in one file):

redflare index.js

Example:

function foo(x) {
  return x / 5;
}

foo('string');

outputs:

index.js:2:9
 1| function foo(x) {
 2|   return x / 5;
  |          ^^^^^
  |          error: division of string by number
 3| }
 4|

Static assertions

Redflare adds global static assertion function __STATIC_ASSERT(expr[, message]). Expression needs to evaluate into known at analysis-time truthy value or error will be reported. It's also useful to add type checks to the code.

__STATIC_ASSERT(true);
__STATIC_ASSERT(true === true, 'this should be true');
__STATIC_ASSERT(typeof value === 'string', 'value should be a string');
__STATIC_ASSERT(typeof value === 'number' && value > 0, 'value should be a positive number');

How does it work?

Redflare is an abstract interpreter JavaScript VM that operates on abstract values instead of an actual values. For example, <any number>, <positive number>, <any boolean> or just <any> are all valid abstract values. JavaScript operators can be defined in terms of abstract values, like expression (<any number> + <any number>) results in another <any number>, so we can easily infer result values or types of expressions. As another example, typeof <any number> results in actual value number.

Todo

  • Add all the missing operators
  • Loops (for, for-of, for-in, do-while, while)
  • Objects/arrays/tuples
  • More builtin functions
  • require() / import
  • Function side-effect analysis
  • Event loop, setTimeout etc
  • More consistent and configurable errors
  • ES2015 support

License

MIT