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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-moss

v1.0.0

Published

A Node.js client for Stanford MOSS (Measure Of Software Similarity)

Readme

🕵️‍♂️ node-moss > "Because Ctrl+C Ctrl+V is not a Design Pattern."

npm version License: MIT TypeScript

🧐 What is this?

Welcome to node-moss, the sleekest, strictly-typed Node.js client for Stanford's MOSS (Measure of Software Similarity). Whether you are a Professor tired of grading the same code 50 times, or a TA hunting for the "Stack Overflow Special," this package connects you to the MOSS server faster than your students can say "git clone."

🚀 Installation

Stop reinventing the wheel. Install the detective:

npm install node-moss

⚡ The "Sting Operation" (Quick Start)

Here is how you catch the impostors in under 10 lines of code:

TypeScript

import { MOSS } from 'node-moss';

(async () => {
  // 1. Badge up (Use your Stanford MOSS User ID)
  const client = new MOSS("YOUR_USER_ID");

  // 2. Set the rules of engagement
  client.setLanguage("cc"); // C++
  client.setResultLimit(10); // Top 10 copycats

  // 3. Load the evidence
  // You can add files one by one...
  await client.addBaseFile("./skeleton_code.cpp"); // The code you gave them
  await client.addFile("./submission_A.cpp");
  await client.addFile("./submission_B.cpp");

  // ... OR just throw a wildcard net 🕸️
  await client.addByWildcard("./students/assignment1/*.cpp");

  // 4. Send it to the lab 🧪
  console.log("🔍 Scanning for duplicates...");
  const reportUrl = await client.send();

  console.log("🚨 BUSTED! View report here:", reportUrl);
})();

🧰 Features (The Toolkit)

  • 🕵️ Wildcard Support: Don't add files manually like a caveman. Use addByWildcard('./*.js').
  • 👮‍♂️ Base Files: Upload the skeleton code so MOSS knows what not to flag.
  • 💬 Polyglot: Speaks fluent C, Java, Python, ASCII, and dozens more.
  • 📜 TypeScript Native: Fully typed. No more guessing what options are available.
  • 🚀 Async/Await: Non-blocking, because you have other bugs to fix.

🌍 Supported Languages

MOSS supports the following languages (use the exact code with setLanguage()):

| Language | Code | |-----------------------|--------------| | C | c | | C++ | cc | | Java | java | | ML | ml | | Pascal | pascal | | Ada | ada | | Lisp | lisp | | Scheme | scheme | | Haskell | haskell | | Fortran | fortran | | ASCII files | ascii | | VHDL | vhdl | | Perl | perl | | MATLAB | matlab | | Python | python | | MIPS assembly | mips | | Prolog | prolog | | SPICE | spice | | Visual Basic | vb | | C# | csharp | | Modula-2 | modula2 | | 8086 assembly | a8086 | | JavaScript | javascript | | PL/SQL | plsql | | Verilog | verilog |

Note: This is the full list from the official MOSS Perl script. May Some changes are done.

The Methods

🔍 Getters

Retrieve current configuration values.

| Method | Returns | Description | | :--- | :--- | :--- | | getUserID() | string | Returns the current User ID. | | getSupportedLanguages() | string[] | Returns a list of all supported languages. | | getComment() | string | Returns the current comment string. | | getDirectoryMode() | number | Returns 0 or 1. | | getIgnoreLimit() | number | Returns the current ignore limit. | | getResultLimit() | number | Returns the current result limit. | | getExperimentalServer() | number | Returns the experimental server status. |

🛠️ Configuration (Setters)

Customize how MOSS processes your files.

| Method | Description | Default Value | | :--- | :--- | :--- | | setLanguage(lang) | Set the programming language (e.g., 'c', 'java', 'python'). | 'c' | | setDirectoryMode(mode) | Set to 1 to group files by directory (useful for multi-file projects). | 0 (Off) | | setResultLimit(n) | The number of matching files to show in the results. | 250 | | setIgnoreLimit(n) | Ignore code passages that appear in more than n files (helps ignore common boilerplate). | 10 | | setComment(text) | A string attached to the report for your own reference. | "" | | setExperimentalServer(x) | Set to 1 to use the experimental MOSS server. | 0 | | setUserID(id) | Updates the User ID (if not set in constructor). | - |

📂 File Management

Methods to load student code and skeleton code.

| Method | Description | Async? | | :--- | :--- | :--- | | addFile(path) | Adds a specific submission file to be checked. | ✅ Yes | | addBaseFile(path) | Adds "skeleton" or "base" code. MOSS will ignore matches found in these files. | ✅ Yes | | addByWildcard(pattern) | Adds multiple files using a glob pattern (e.g., ./src/*.js). | ✅ Yes |

🚀 Execution

The command to start the analysis.

| Method | Description | Returns | | :--- | :--- | :--- | | send() | Uploads all files and settings to Stanford MOSS and awaits the response. | Promise<string> (The URL) |

⚠️ Important Note

This is a client. You still need a valid MOSS User ID from Stanford.

  • Don't have one? Send an email to [email protected] with the body registeruser-mail <your_email>.

🤝 Contributing

Found a bug? Want to add support? Your are welcomed! Fork it, fix it, ship it.

📜 License

This project is licensed under MIT License LICENSE file. 2025 MIT © Abdelhalim Yasser

Go forth and keep the code clean. 🧹