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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fsm-validator

v1.5.2

Published

alternative for regular expressions

Readme

#fsm-validator

Intro

fsm-validator is an alternative to regular expressions however it allows you to write them in a more programmatic way. This could come in very handy if you'd want to generate a different fsm depending on some input.

Example

this is an example for what an email rule might look like \[a-z]+@[a-z]+\.[a-z]+\ and this is the what it would like using fsm-validator

start.plus(letters).normal('@').plus(letters).normal('.').plus(letters).accepting = true;

For an explanation about finite state machines there is a very good video about it on numberphile. finite state machine

How to use

First of all you need to make a finite state machine like the one in the image above. you do this by creating a Start state and then using it's methods to build it up. You can set a states accepting attribute to true this will mark it as a legal endstate, in 99% of all cases you'd want your final state to be the "accepting" state.

var letters = "abcdefghijklmonpqrstuvwxyz";
var start = new State();
start.plus(letters).normal(at).plus(letters).normal(dot).plus(letters).accepting = true;

Once you've made your fsm you can pass it a string and it will walk the fsm seeing if it fits the pattern. The total for the email rule looks like this.

var State = require("./js2/State");

var letters = "abcdefghijklmnopqrstuvwxyz";
var start = new State();

start.plus(letters).normal("@").plus(letters).normal(".").plus(letters).accepting = true;

console.log(start.consume("[email protected]"));

Functions

  • The black circle represents the State you're calling the method on
  • The green circle represents the State that is returned
  • The lines represent the symbols you can pass in the parameters

normal

normal

or

or

optional

optional

star

star

plus

plus

warning

The implementation of these finite state machines is a little different than regular expressions. Normally regular expressions consider a string valid if there is any possible way to complete the finite state machine. However the way these fsm's are implemented is that they will take the first path that is available, so the order in which you specify the rules does matter. For instance this regex \a+a\ would allow aa but start.plus("a").normal("a") wouldn't because it would keep looping in the a+ part and never reach the accepting state so be aware of this and try to avoid ambiguity.

still coming

  • documentation on all the classes and functions and how they work
  • more regex functions like search and replace
  • pre-made fsm's