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

@wesr/snip

v1.0.0

Published

SNIP: Small N-gram Identifier for Pastes, a browser-local paste and text type classifier.

Readme

SNIP (Small N-gram Identifier for Pastes)

SNIP is a small browser-local classifier for pasted text and source snippets.

SNIP predicts a likely syntax or text label for pasted text, snippets, logs, configuration files, and text-like source files. It is designed for browser-local inference in applications where sending pasted content to a server is undesirable. It aims to be quick, small in size, and fairly accurate.

Links

Release Contents

  • model/snip_model.json - source model weights used to generate the embedded runtime model
  • src/snip.ts - dependency-free TypeScript source runtime
  • dist/snip.js - compiled JavaScript runtime
  • dist/snip.d.ts - TypeScript declarations
  • examples/node-example.mjs - minimal Node usage example
  • docs/index.html - browser demo page
  • metrics/ - evaluation metrics copied from the release candidate
  • MODEL_CARD.md - concise model card
  • REPORT.md - technical report

Quick Start

Install the package:

npm install @wesr/snip
import { classifyText } from "@wesr/snip";

const result = classifyText(`from fastapi import FastAPI

app = FastAPI()

@app.get("/notes/{note_id}")
def read_note(note_id: int):
    return {"note_id": note_id}
`);
console.log(result.label);

API

classifyText(text)

Classifies a string using the embedded SNIP model.

interface ClassificationResult {
  label: SnipLabel;
  predicted_label: SnipLabel;
  confidence: number;
  margin: number;
  alternatives: Array<[SnipLabel, number]>;
}
  • label is the accepted label after any configured fallback thresholds.
  • predicted_label is the highest-scoring raw prediction.
  • confidence is the score assigned to the winning label.
  • margin is the gap between the winning label and the runner-up. Larger margins generally indicate a clearer classification.
  • alternatives contains the top five labels and scores.

classifyTextAsync(text)

Yields once before classifying, which gives browser UI code an awaitable API and a chance to paint before SNIP runs.

import { classifyTextAsync } from "@wesr/snip";

const result = await classifyTextAsync("package main\n\nfunc main() {}\n");

sampleText(text)

Applies the model's bounded sampling strategy. Inputs up to 16 KiB are classified whole; larger inputs are represented by start, middle, and end windows.

Labels

The release model predicts:

bash, c, cpp, csharp, css, csv, diff, dockerfile, go, html, ini, java, javascript, json, log, lua, markdown, php, plain_text, powershell, python, ruby, rust, sql, toml, typescript, xml, yaml.

Size

  • Raw model JSON: 626,596 bytes
  • Gzip model JSON: 203,820 bytes

The runtime is written in TypeScript and has no runtime package dependencies.

License

SNIP is released under the BSD 3-Clause License. See LICENSE.