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

tweet-matches

v1.0.2

Published

Check if a tweet matches a twitter filter

Readme

tweet-matches

Check if a tweet matches a twitter filter. Since the Twitter API allows you only one or a couple connections from on IP at a time, tracking multiple queries to the streaming API at once requires some processing on your end.

This module implements the key part of that post-processing: checking whether a tweet matches a given value for the track parameter of the Twitter streaming API. Twitter's documentation for this parameter is here, and I've backed it up here.

Usage

var tweetMatches = require('tweet-matches');

var track = 'foo,bar bAZ , what is ';
var compiled = tweetMatches.compile(track);
tweetMatches({ text: 'foo' }, compiled); // true
tweetMatches({ text: 'some bAZ and some barrrr' }, compiled); // true
tweetMatches({ text: 'something else what' }, compiled); // false
tweetMatches({
  text: 'bAZ',
  quoted_status: {
    entities: {
      media: [ { display_url: 'bar.com' } ]
    }
  }
}, compiled); // true

With Twit

This module is best used to consume tweet objects from twit.

var track = 'anything, as usual';
var stream = T.stream('statuses/filter', { track: track }
var compiled = tweetMatches.compile(track);
stream.on('tweet', function(tweet) {
  tweetMatches(tweet, compiled); // true
});

Testing

Use test.js to test against the live twitter API. This module intends to implement exactly the logic that Twitter uses to decide which tweets to send to statuses/filter, so this test just compares our output to theirs.

$ node test.js 'value,for the,track parameter'
Connected
Matched 1 tweets
Matched 2 tweets
Matched 3 tweets
...

Of course if tweetMatches decides it's a match when it shouldn't, this won't tell you.

Related projects