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

stripe-loaders-core

v0.1.0

Published

Core library for Stripe loaders

Downloads

7

Readme

Stripe Docs Sitemap Processor

A utility library for processing Stripe documentation sitemaps. This library helps you fetch, parse, and process sitemaps from Stripe's documentation site.

Features

  • Extract URLs from Stripe documentation sitemaps
  • Process sitemap index files to get all URLs from multiple sitemaps
  • Find newly added URLs by comparing current and previous URL lists
  • Configurable logging with custom logger support
  • Debug mode for detailed logging

Installation

npm install stripe-loader-core

Usage

Basic Usage

import { SitemapProcessor } from 'stripe-loader-core';

// Create a processor instance
const processor = new SitemapProcessor();

// Fetch and process a sitemap index
async function fetchAllDocs() {
  try {
    const urls = await processor.fetchAndProcessSitemapIndex('https://docs.stripe.com/sitemap.xml');
    console.log(`Found ${urls.length} URLs in the Stripe documentation`);
    return urls;
  } catch (error) {
    console.error('Error processing sitemap:', error);
    return [];
  }
}

// Find new URLs
function findNewContent(currentUrls, previousUrls) {
  const newUrls = processor.findNewUrls(currentUrls, previousUrls);
  console.log(`Found ${newUrls.length} new URLs`);
  return newUrls;
}

With Debug Mode

Enable debug mode to see detailed logs during processing:

// Create a processor with debug mode enabled
const processor = new SitemapProcessor({ debug: true });

// Now all processing will output detailed logs
const urls = await processor.fetchAndProcessSitemapIndex('https://docs.stripe.com/sitemap.xml');

Custom Logger

You can provide your own logger implementation:

import { SitemapProcessor, Logger } from '@stripe-loaders/core';

// Implement your own logger
class MyCustomLogger implements Logger {
  log(message: string): void {
    // Custom log implementation
    myLoggingService.info(message);
  }

  error(message: string): void {
    // Custom error implementation
    myLoggingService.error(message);
  }

  warn(message: string): void {
    // Custom warning implementation
    myLoggingService.warn(message);
  }
}

// Create a processor with custom logger
const processor = new SitemapProcessor({
  logger: new MyCustomLogger(),
});

Processing Individual Sitemaps

If you need to process a specific sitemap file:

// Process a single sitemap file
const urls = await processor.fetchAndProcessSitemap('https://docs.stripe.com/sitemap-api.xml');
console.log(`Found ${urls.length} API documentation URLs`);

Extracting URLs from Sitemap Content

If you already have the sitemap content:

// Extract URLs from sitemap content
const sitemapContent = '<?xml version="1.0" encoding="UTF-8"?>...'; // XML content
const urls = processor.extractUrlsFromSitemap(sitemapContent);

// Extract sitemap URLs from a sitemap index
const indexContent = '<?xml version="1.0" encoding="UTF-8"?>...'; // XML content
const sitemapUrls = processor.extractSitemapUrlsFromIndex(indexContent);

API Reference

SitemapProcessor

The main class for processing sitemaps.

Constructor

constructor(options: { debug?: boolean; logger?: Logger } = {})
  • options.debug: Enable debug mode (default: false)
  • options.logger: Custom logger implementation (default: ConsoleLogger)

Methods

  • extractUrlsFromSitemap(content: string, baseUrl?: string): string[]

    • Extract URLs from sitemap XML content
    • baseUrl defaults to 'https://docs.stripe.com/'
  • extractSitemapUrlsFromIndex(content: string): string[]

    • Extract sitemap URLs from a sitemap index XML content
  • findNewUrls(currentUrls: string[], previousUrls: string[]): string[]

    • Find URLs that exist in currentUrls but not in previousUrls
  • fetchAndProcessSitemap(url: string, baseUrl?: string): Promise<string[]>

    • Fetch a sitemap from the given URL and extract all URLs
  • fetchAndProcessSitemapIndex(indexUrl: string, baseUrl?: string): Promise<string[]>

    • Fetch a sitemap index and process all referenced sitemaps

Logger Interface

Interface for custom loggers.

interface Logger {
  log(message: string): void;
  error(message: string): void;
  warn(message: string): void;
}

License

MIT