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

@pleger/synccc

v0.1.0

Published

Sync/cc-style callback flattening powered by AspectScript

Readme

Synccc

npm version

Synccc is a modern Sync/cc-style package built on top of AspectScript. It lets you write callback-based asynchronous flows in a sequential style.

This implementation follows the core idea from the paper: two aspects coordinate suspension/resumption around asynchronous operations and callback execution.

Install

npm install @pleger/synccc

Quick Start

const AspectScript = require("aspectscript");
const Synccc = require("@pleger/synccc");

const runtime = AspectScript.createAspectScript(globalThis);
const synccc = new Synccc({ aspectScript: runtime });

const asyncRequest = synccc.setAsyncOperation(function asyncRequest(url, callback) {
  setTimeout(() => callback({ url, body: "ok" }), 20);
});

(async () => {
  const result = await synccc.run(() => {
    const a = asyncRequest("/book", function () {});
    const b = asyncRequest("/chapter/1", function () {});
    return [a, b];
  });

  console.log(result);
})();

Paper-Style Example (Book Handler)

const book = asyncRequest("book:1", function () {});
const chapters = book.chaptersURL.map((chapterURL) => asyncRequest(chapterURL, function () {}));
const images = chapters.map((chapter) => chapter.imagesURL.map((imageURL) => asyncRequest(imageURL, function () {})));

This works with Synccc.run(...) and preserves the left-to-right call order.

API

new Synccc(options?)

  • options.aspectScript: AspectScript runtime instance (default: global AspectScript runtime)
  • options.asyncOperation: optional async operation to register immediately

synccc.setAsyncOperation(fn, options?)

Registers an asynchronous operation and returns a wrapped function.

Options:

  • callbackIndex (default: -1): callback argument position
  • errorFirst (default: false): Node-style (err, value) callback mode
  • responseIndex (default: 0, or 1 when errorFirst: true)
  • responseSelector(args): custom value extractor

await synccc.run(handler, ...args)

Executes a synchronous-looking handler and resolves with its final value.

synccc.enable() / synccc.disable()

Manually deploy/undeploy internal aspects.

Tests

npm test

Current suite includes 16 tests covering:

  • single and nested flows
  • map-based paper example
  • callback position customization
  • error-first callbacks
  • deterministic ordering
  • call join point compatibility
  • concurrency guardrails

Browser Demo Website

Interactive demo is in docs/.

Run locally:

npm run website:sync
cd docs
python3 -m http.server 4173

Then open http://127.0.0.1:4173.

Citation

If you use this package in research, please cite:

Continuations and Aspects to Tame Callback Hell on the Web. Paul Leger, Hiroaki Fukuda, Ismael Figueroa. Journal of Universal Computer Science, volume 27, number 9, pp.955-978, September 2021. DOI: https://doi.org/10.3897/jucs.72205

License

MIT