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

@hmb-research/x-ray-crawler

v2.1.0

Published

x-ray's crawler

Downloads

115

Readme

x-ray Crawler

CI Security Audit Release npm version License: MIT

Friendly web crawler for x-ray.

Features

  • Full TypeScript support with type definitions
  • Extensible drivers
  • Request and response hooks
  • Rate limiting
  • Delayed requests
  • Concurrency support
  • Request timeout
  • Total request limiting

Example

function http(ctx, fn) {
  superagent.get(ctx.url, fn)
}

var crawl = Crawler(http)
  .throttle(3, '1s')
  .delay('1s', '10s')
  .concurrency(2)
  .limit(20)

crawl('http://lapwinglabs.com', function(err, ctx) {
  if (err) throw err
  console.log('status code: %s', ctx.status)
  console.log('status body: %s', ctx.body)
})

TypeScript Support

x-ray-crawler includes full TypeScript type definitions for enhanced development experience with IntelliSense and type checking.

Basic TypeScript Usage

import Crawler = require('@hmb-research/x-ray-crawler');
import { Context, Driver, CrawlerCallback } from '@hmb-research/x-ray-crawler';

// Create a crawler instance
const crawl = Crawler();

// Use with typed callback
crawl('http://example.com', (err: Error | null, ctx: Context) => {
  if (err) {
    console.error(err.message);
    return;
  }

  // Full type safety for context properties
  console.log('Status:', ctx.status);        // number
  console.log('Body:', ctx.body);            // string | object
  console.log('URL:', ctx.url);              // string
  console.log('Headers:', ctx.headers);      // Record<string, string>
});

Custom Driver with Types

import Crawler = require('@hmb-research/x-ray-crawler');
import { Driver, Context, CrawlerCallback } from '@hmb-research/x-ray-crawler';

// Implement a custom driver with full type safety
const customDriver: Driver = (ctx: Context, callback: CrawlerCallback) => {
  // Your custom implementation
  ctx.status = 200;
  ctx.body = { data: 'custom response' };
  ctx.set({ 'Content-Type': 'application/json' });
  callback(null, ctx);
};

const crawl = Crawler(customDriver);

Chaining with Type Safety

const crawl = Crawler()
  .concurrency(5)                    // number
  .timeout(5000)                     // number | string
  .delay(100, 500)                   // (number | string, number | string)
  .throttle(10, '1s')                // (number, number | string)
  .limit(100)                        // number
  .request((req) => {                // Request hook
    console.log('Request:', req);
  })
  .response((res) => {               // Response hook
    console.log('Response:', res);
  });

// All methods return the crawler instance for chaining
crawl('http://example.com', (err, ctx) => {
  if (!err) console.log(ctx.status);
});

Type Definitions

The package exports the following TypeScript types:

  • Context - HTTP context object with request/response data
  • Driver - Function type for custom drivers
  • Crawler - Main crawler interface with all methods
  • CrawlerCallback - Callback function type
  • RequestHook - Request modification hook type
  • ResponseHook - Response modification hook type
  • DriverOptions - Options for HTTP driver configuration

Type Checking

Run type checking with:

npm run test:types

Installation

npm install @hmb-research/x-ray-crawler

Documentation

Test

Run the test suite:

npm test

Run TypeScript type checking:

npm run test:types

Run tests with coverage:

npm run test:coverage

Development

CI/CD Pipeline

This project uses GitHub Actions for continuous integration and deployment:

  • Automated Testing: Tests run on Node.js 18.x, 20.x, and 22.x
  • Security Auditing: Daily vulnerability scans and dependency reviews
  • Automated Releases: Semantic versioning based on conventional commits
  • NPM Publishing: Automatic package publishing on release

See CI/CD Guide for detailed documentation.

Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Setting up your development environment
  • Coding standards and commit message conventions
  • Pull request process
  • Testing guidelines

Quick Start for Contributors:

# Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/x-ray-crawler.git
cd x-ray-crawler

# Install dependencies
npm install

# Run tests
npm test

# Create a feature branch
git checkout -b feature/my-feature

# Make changes and commit using conventional commits
git commit -m "feat: add new feature"

# Push and create a pull request
git push origin feature/my-feature

Commit Message Format

This project uses Conventional Commits for automated versioning:

  • feat: - New feature (minor version bump)
  • fix: - Bug fix (patch version bump)
  • docs: - Documentation changes
  • chore: - Maintenance tasks

Example: feat: add support for custom headers

License

(The MIT License)

Copyright (c) 2015 Matthew Mueller [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.