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

@qnc/auto_escape

v1.0.0

Published

Composable html auto escaping

Readme

auto_escape

A BASIC type script utility for building html using tagged template literals, where all expressions are automatically escaped.

All it does is help you generate html while avoiding XSS vulnerabilities. Intended to replace templating libraries (eg. moustache.js).

Compared to templating, you have: PRO: minimal overhead, easy to read PRO: type script will check your types; no render-time errors CON: your html lives inside template strings literals in js files, so you don't get syntax highlighting

Useful when you don't want to set up a full "component framework" (eg. react, vue, lit, etc.).

Explanation by example

import {auto_escape, TrustedHTML} from '@qnc/autoescape';

// Static parts aren't escaped
console.assert(auto_escape`<i></i>`.html == "<i></i>");

// You can insert regular characters
console.assert(auto_escape`<i>${"apple"}</i>`.html == "<i>apple</i>");

// You can insert numbers
console.assert(auto_escape`<i>${1}</i>`.html == "<i>1</i>");

// You can insert arrays
console.assert(auto_escape`<i>${[1, 2, 3]}</i>`.html == "<i>123</i>");

// Special characters are escaped
console.assert(
    auto_escape`<i>${"<>\"'&"}</i>`.html == "<i>&lt;&gt;&quot;&#039;&amp;</i>",
);

// it's composable
const inner = auto_escape`<i>${3}</i>`;
console.assert(auto_escape`<b>${inner}</b>`.html == "<b><i>3</i></b>");

// You can use TrustedHTML to trust other sources of HTML
console.assert(
    auto_escape`<i>${new TrustedHTML("<i></i>")}</i>`.html == "<i><i></i></i>",
);

// You can put expressions in attributes
console.assert(
    auto_escape`<a href="mailto:${'"John Doe" <[email protected]>'}">email John Doe</a>`
        .html ==
        '<a href="mailto:&quot;John Doe&quot; &lt;[email protected]&gt;">email John Doe</a>',
);

// Slightly more complex case
const users = [
    { first_name: "Alex", last_name: "Fischer" },
    { first_name: "John", last_name: "Doe" },
    { first_name: "Jane", last_name: "Doe" },
];
console.assert(
    auto_escape`
        <ul>
            ${users.map((u) => auto_escape`<li>${u.first_name} ${u.last_name}</li>`)}
        </ul>
    `.html ==
        `
        <ul>
            <li>Alex Fischer</li><li>John Doe</li><li>Jane Doe</li>
        </ul>
    `,
);