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

snoop

v2.0.0

Published

Easy breezy test spies fo sheezy.

Downloads

11,794

Readme

snoop 🎵

npm version npm downloads Bun CI license

Easy breezy test spies fo sheezy.

Snoop Dogg

Create small, dependency-free function spies that record calls, results, errors, and relative call order. Snoop collaborates with everyone.

Installation

npm install --save-dev snoop

Other package managers:

yarn add --dev snoop
pnpm add --save-dev snoop
bun add --dev snoop

Usage

With uvu

import { snoop } from 'snoop';
import { test } from 'uvu';
import * as assert from 'uvu/assert';

const add = (a, b) => a + b;

test('add', () => {
  const addFn = snoop(add);
  const anotherAddFn = snoop(add);

  addFn.fn(1, 1);
  anotherAddFn.fn(1, 1);
  addFn.fn(2, 2);
  anotherAddFn.fn(2, 2);

  assert.ok(addFn.called);
  assert.not(addFn.notCalled);
  assert.not(addFn.calledOnce);
  assert.is(addFn.callCount, 2);
  assert.equal(addFn.calls[0].arguments, [1, 1]);
  assert.equal(addFn.calls[1].arguments, [2, 2]);
  assert.is(addFn.calls[0].result, 2);
  assert.is(addFn.calls[1].result, 4);
  assert.not(addFn.firstCall.error);
  assert.not(addFn.lastCall.error);
  assert.ok(addFn.calledBefore(anotherAddFn));
  assert.ok(addFn.calledAfter(anotherAddFn));
  assert.ok(addFn.calledImmediatelyBefore(anotherAddFn));
  assert.not(addFn.calledImmediatelyAfter(anotherAddFn));
});

test.run();

TypeScript declarations are included with the package.

API

snoop(fn)

Returns a spy object whose fn method invokes the supplied function and records each call.

The wrapper records thrown values in the call's error property and returns undefined instead of rethrowing them. This matches the package's existing behavior.

| Property or method | Description | | -------------------------------- | -------------------------------------------------------------- | | fn(...args) | Invokes the function and records its arguments and result. | | testID | Internal numeric identifier used for global call ordering. | | called | Whether the spy has been called at least once. | | notCalled | Whether the spy has never been called. | | calledOnce | Whether the spy has been called exactly once. | | callCount | Number of recorded calls. | | calls | All call records in invocation order. | | firstCall | First call record, or undefined before the first call. | | lastCall | Most recent call record, or undefined before the first call. | | calledBefore(other) | Whether this spy was called before the other spy. | | calledAfter(other) | Whether this spy was called after the other spy. | | calledImmediatelyBefore(other) | Whether this spy's latest call immediately preceded the other. | | calledImmediatelyAfter(other) | Whether this spy's latest call immediately followed the other. |

Each call record contains arguments, result, and error.

Runtime requirements

  • An ESM-compatible runtime or bundler
  • No runtime dependencies

Development

Install dependencies:

bun install

Run the tests:

bun run test

Format the project:

bun run format

License

MIT