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

dsa-gen

v1.0.0

Published

Smart toolkit for generating test cases, debugging algorithms, and analyzing performance.

Downloads

14

Readme

🚀 Smart DSA Toolkit – Debug Algorithms Like a Pro

npm version npm downloads License: MIT

A powerful toolkit to generate test cases, detect bugs, minimize failing inputs, and analyze algorithm performance.


⚡ 10-Second Demo

1. Compare your solutions and find the absolute smallest failing edge case:

npx dsa-gen compare brute.js optimized.js --preset=binary-search

Output:

❌ MISMATCH DETECTED
────────────────────────────
Input        : [2, 1, 2]
Expected     : 6
Got          : 5
────────────────────────────

🔍 Minimizing failing test case...
✅ Smallest failing case found!

❌ Minimal Failing Input
────────────────────────────
[2, 1, 2]
Expected     : 6
Got          : 5
────────────────────────────

Seed: 42
✅ Saved failing case to ./failing_case.json

❓ The Problem

  • Debugging large inputs is hard: When your Leetcode or CP solution fails on a 10,000-element array, finding the exact issue is nearly impossible.
  • Random test generators are dumb: Simple random outputs naturally miss critical edge cases (negatives, duplicates, boundaries).
  • Benchmarking is tedious: Setting up performance.now() loops with varying N lengths gets repetitive.

✅ The Solution

This toolkit changes the game by:

  1. Generating smart test cases mapped to algorithm constraints (e.g., sorting, binary search, graphs).
  2. Finding bugs automatically by cross-testing your optimized code against a brute-force approach.
  3. Minimizing failing cases (Delta-Debugging) automatically. Once it fails, it shrinks the array/string down to the absolute smallest reproducible failure.
  4. Benchmarking performance gracefully to dynamically estimate Big-O complexities.

🔥 Features List

  • 🧠 Smart test case generation (Arrays, Strings, Trees, Graphs, Matrices, Numbers)
  • 🎲 Problem-aware edge cases built-in
  • 🔬 Automatic minimizer (Killer Feature)
  • ⚖️ Comparator (brute vs optimized tests)
  • ⏱️ Benchmarking with O() complexity estimation
  • 🪄 Interactive CLI wizard with colorful outputs (chalk & inquirer)
  • 💾 Save / Load / Replay test suites
  • 🎚️ Presets & Difficulty Levels (easy, medium, hard)

📦 Installation

Install globally to use the CLI anywhere:

npm install -g dsa-gen

Or install as a dev dependency to use it programmatically in your testing workflow:

npm install dsa-gen --save-dev

🛠 Usage Examples

CLI Command List

You can trigger the interactive wizard simply using:

npx dsa-gen

Otherwise, invoke tools directly:

  • npx dsa-gen generate – Open test case generation wizard.
  • npx dsa-gen replay – Replays standard ./failing_case.json config.
  • npx dsa-gen compare – Trigger programmatic API info notice.
  • npx dsa-gen benchmark – Trigger programmatic API info notice.
  • npx dsa-gen visualize – Visualizes data structures as Ascii representations.

Programmatic Usage

1. Debugging with compareSolutions & Auto-Minimizer:

import { compareSolutions, generateArray } from 'dsa-gen';

const bruteForce = (arr) => { /* correct, slow logic */ };
const optimizedBuggy = (arr) => { /* fast logic w/ bug */ };

// Setup a generator using our difficulty presets
const generatorFn = () => [ generateArray({ size: 100, difficulty: 'hard' }) ];

compareSolutions(bruteForce, optimizedBuggy, {
  generatorFn,
  iterations: 1000,
  savePath: './failing_case.json', // Will export the minimal array here
  verbose: true
});

2. Educational Benchmarking runBenchmark:

import { runBenchmark, generateString } from 'dsa-gen';

const algorithm = (str) => { /* ... */ };
const generatorFn = (n) => [ generateString({ length: n }) ];

runBenchmark(algorithm, generatorFn, [10, 100, 1000, 10000]);

Output visually scales and automatically predicts O(N), O(N log N), O(1), or O(N^2).


🎯 Target Use Cases

  • Debugging algorithms: Find the exact edge cases where an optimized logic fails.
  • Interview preparation: Practice recognizing edge cases and testing tree/graph manipulations.
  • Competitive programming: Speed up testing locally before pushing to platforms like Codeforces.
  • Performance testing: Quickly assert O(N) constraints before submission.