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

@typesugar/playground

v0.1.1

Published

🧊 Browser-compatible typesugar bundle for the interactive playground

Readme

@typesugar/playground

Browser-compatible bundle for the typesugar interactive playground.

Features

  • Browser-compatible: Runs entirely in the browser without Node.js
  • Preprocessor support: Transform .sts files with custom syntax (HKT, pipeline, cons)
  • Macro transformation: Expand typesugar macros at compile time
  • In-memory caching: LRU cache for fast repeated transformations
  • TypeScript transformer: Uses TypeScript's transformer API

Installation

npm install @typesugar/playground

Usage

import { transform, preprocess } from "@typesugar/playground";

// Transform TypeScript with macros
const result = transform(`
  import { staticAssert } from "typesugar";
  staticAssert(1 + 1 === 2);
`);

console.log(result.code);
console.log(result.diagnostics);

// Preprocess .sts files (custom syntax)
const { code, changed } = preprocess(`const result = x |> f |> g;`, { fileName: "test.sts" });

API

transform(code, options?)

Transform TypeScript code with typesugar macros.

Options:

  • fileName?: string - File name (affects preprocessing for .sts files)
  • verbose?: boolean - Enable verbose logging
  • cacheSize?: number - Maximum cache entries (default: 100)

Returns: TransformResult

  • original: string - Original source code
  • code: string - Transformed code
  • sourceMap: RawSourceMap | null - Source map
  • changed: boolean - Whether the code was modified
  • diagnostics: TransformDiagnostic[] - Any errors or warnings
  • preprocessed?: boolean - Whether preprocessing was applied

preprocessCode(code, options?)

Preprocess code with custom syntax (pipeline |>, HKT F<_>, cons ::).

clearCache()

Clear the transformation cache.

getCacheStats()

Get cache statistics as a string.

Limitations

The browser playground has some limitations compared to the full transformer:

  1. No file system access: includeStr(), includeJson(), and includeBytes() macros are not available
  2. Limited type checking: Type-aware macros may have reduced functionality without a full project context

Bundle Size

The browser bundle includes:

  • @typesugar/preprocessor - Custom syntax transforms
  • @typesugar/core - Macro registry and context
  • @typesugar/macros - Built-in macro implementations

TypeScript itself is a peer dependency and must be loaded separately.

License

MIT