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

@speedkit/rules

v1.1.6-0

Published

Baqend Speed Kit Rules

Readme

@speedkit/rules

A TypeScript rule engine for matching HTTP requests based on URL patterns, device type, cookies, storage, content type, and more. Used by Baqend Speed Kit to determine caching and optimization behavior.

Installation

npm install @speedkit/rules

Requires Node.js >= 22.11.0.

Usage

Defining Rules

Rules are plain objects matching the SpeedKitRule interface:

import { RuleSet, AndRule } from '@speedkit/rules';
import type { SpeedKitRule } from '@speedkit/rules';

const rule: SpeedKitRule = {
  host: /\.baqend\.com$/,
  contentType: ['script', 'style'],
  mobile: true,
};

Evaluating Rules

Use RuleSet to test requests against a collection of rules.

From JSON (most common):

const ruleSet = new RuleSet().fromJSON([
  { host: /\.baqend\.com$/, contentType: ['script', 'style'] },
  { pathname: /^\/api\/v1/, mobile: true },
]);

const matches = ruleSet.matches(request, { contentType: 'script' });

With pre-built AndRule instances:

import { RuleSet, AndRule } from '@speedkit/rules';

const ruleSet = new RuleSet([
  new AndRule().fromJSON({ host: /\.example\.com$/ }),
  new AndRule().fromJSON({ contentType: ['document'] }),
]);

Building incrementally:

const ruleSet = new RuleSet();
ruleSet.addRule(new AndRule().fromJSON({ url: /\/checkout/ }));
ruleSet.addRule(new AndRule().fromJSON({ mobile: true }));

ruleSet.removeRule(someRule); // returns true if found

Retrieving the matching rule:

const matchingRule = ruleSet.getMatchingRule(request, { contentType: 'document' });
if (matchingRule) {
  // first rule that matched
}

Available Conditions

| Property | Matches Against | Example | |---------------|------------------------------------|--------------------------------------| | url | Full URL (host + path + query) | /^www\.example\.com\// | | host | Domain and port | /\.example\.com$/ | | pathname | Path and search params | /^\/api\/v1/ | | hashparam | URL fragment parameters | /campaign/ | | cookie | Cookie name/value pairs or callback| /^PHPSESSID$/ | | storage | localStorage/sessionStorage entries| /^userLoggedIn=true$/ | | contentType | Resource MIME type categories | ['document', 'style', 'script'] | | mobile | Mobile device | true | | desktop | Desktop device | true | | tablet | Tablet device | true |

Condition Types

Conditions accept several formats:

  • String -- prefix matching
  • RegExp -- pattern matching
  • Array -- OR logic (matches if any element matches)
  • Function -- custom logic (cookies and storage only)

JSON Serialization

Rules support JSON serialization with special handling for RegExp and Function values:

const json = ruleSet.toJSON();
const restored = new RuleSet();
restored.fromJSON(json);

Development

npm install        # Install dependencies
npm run build      # Compile TypeScript
npm run lint       # Run ESLint
npm run test:unit  # Run tests

License

MIT