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

shatterjs

v1.0.0

Published

Decompose JavaScript files into their fundamental components: shebang, header, body, and footer.

Downloads

6

Readme

ShatterJS

Since these things are so, we must agree that that which keeps its own form unchangingly, which has not been brought into being and is not destroyed, which neither receives into itself anything else from anywhere else, nor itself enters into anything anywhere, is one thing

Plato, Timaeus


Decomposes JavaScript files into their four fundamental components: shebang, header, body, and footer.

npm version npm downloads license bundle size

Features

  • Each component is an OOP object that can easily be worked with.
  • Header and Footer are subdivided further into comment blocks, comment lines or empty lines.

Warning

I have made the functionality as robust as I could currently foresee to accomplish the goals I had for this package.

Please keep in mind:

  • JavaScript document structure is complex, and it's likely I didn't consider all fringe cases and uses.
  • The abstract nature of how documents are decomposed could lead to a rapidly evolving API that may not be compatible with current versions.
  • I will release a new major version for each breaking change, following a period of evaluation on the current 1.0.0 version.

Note: Use in production environments with caution due to potential structural changes in future major versions


📦 Installation


npm install shatterjs

Or with Yarn:


yarn add shatterjs

🚀 Quick Start

import { Doc } from 'shatterjs';

const source = `
#!/usr/bin/env node
// This is a header comment
/* Multi-line
   block comment */
const hello = 'world';
console.log(hello);
// Footer note
`;

const doc = new Doc();
doc.from(source);

console.log('Shebang:', doc.shebang.content);
console.log('Header:', doc.head.content);
console.log('Body:', doc.body.content);
console.log('Footer:', doc.footer.content); 

🧩 Component Breakdown

Shebang

Detects the shebang line (if present).


Head

Captures decorative comments before code starts.

Body

Framed from the start of valid code to the end of valid code.


Footer

All content after the last line of valid code.


InlineComment

Single-line comments (e.g., // comment).


BlockComment

Block comments spanning multiple lines /* comment */


EmptyLine

A line filled only with whitespace or a single line break \n.

Project Links

I use GitHub as the primary public development spot: https://github.com/alexstevovich/shatterjs

Why ShatterJS?

I created ShatterJS for my licensing preamble package LawfulGood to identify whether a preamble already exists and where to insert a block of licensing code at the start of a document.

I modularized the functionality as I can see other use cases for this beyond script licensing.


License

Licensed under the Apache License 2.0.