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

@effectionx/inline

v0.0.1

Published

Optimize deeply nested operations by collapsing yield delegation into a single iterator

Downloads

27

Readme

🚀 Inline

Collapse nested yield* delegation into a single flat iterator for performance-critical code paths.


On rare occasions, yield* syntax can cause a performance degradation, for example when there are many, many levels of recursion. The reason is because when javascript composes generators via yield*, each level of nesting creates an intermediate generator frame. The engine must unwind through every one of these frames on each call to .next(), .return(), or .throw(). For deeply nested or recursive operations, the cost of resuming a single yield point is O(depth).

Most of the time, this overhead is negligible and you should use plain yield* — it's type-safe, gives you clear stack traces, and composes naturally. But if you've profiled your code and identified deep yield* nesting as a bottleneck (e.g. recursive operations or tight inner loops with many layers of delegation), inline() lets you opt into a flat execution model where the cost is O(1) regardless of depth.

Instead of delegating with yield*:

let value = yield* someOperation();

Use inline() with a plain yield:

import { inline } from "@effectionx/inline";

let value = (yield inline(someOperation())) as SomeType;

The trade-off is that the return type is unknown (requiring a cast), and you lose the natural generator stack trace.

Note: Source map support for the build-time transforms is not yet available but is planned for a future release.

Build-time Transform

Instead of manually converting each yield* call, you can apply the inline optimization automatically at build time. The transform rewrites every yield* expression inside generator functions into the equivalent yield inline(...) call. This means you can benefit from type-safety and helpful stack traces while developing, but ship optimal code to production.

esbuild

import { build } from "esbuild";
import { inlinePlugin } from "@effectionx/inline/esbuild";

await build({
  entryPoints: ["src/index.ts"],
  bundle: true,
  plugins: [inlinePlugin()],
});

SWC

A compiled WASM plugin is available for use with @swc/core or any SWC-based toolchain (e.g. Next.js, Parcel):

import { transformSync } from "@swc/core";

let result = transformSync(source, {
  jsc: {
    experimental: {
      plugins: [["@effectionx/inline/swc", {}]],
    },
  },
});

Both transforms produce identical output: they add import { inline as $$inline } from "@effectionx/inline" and rewrite yield* expr() into (yield $$inline(expr())).

You can opt out of the transform for specific functions with a /** @noinline */ JSDoc annotation, or for an entire file by adding "no inline"; as the first statement.