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

@cheatoid/tstl-extensions

v1.2.0

Published

Plugin for TSTL which provides various low-level extensions

Downloads

14

Readme

TSTL Extensions

npm (scoped)

Plugin for TSTL which provides various low-level extensions.

🛠 Installation

  1. Get the latest package from npm:
    npm install -D @cheatoid/tstl-extensions
    # or
    yarn add -D @cheatoid/tstl-extensions
  2. Edit your tsconfig.json file accordingly to enable the plugin:
    {
      "compilerOptions": {
        "types": [
    +     "@typescript-to-lua/language-extensions",
    +     "@cheatoid/tstl-extensions",
        ]
      },
      "tstl": {
        "luaPlugins": [
    +     { "name": "@cheatoid/tstl-extensions/index.js" },
        ]
      }
    }

✨ Features

Note: This plugin exposes most of low-level functionality via special functions which are prefixed with double-underscore (__).

continue support

If your target Lua environment supports continue statement (such as Garry's Mod Lua)...
Due to specific nature of this feature, you must explicitly opt-in by modifying your tsconfig.json file by appending the following:

{
  "tstl": {
    "luaPlugins": [
      {
        "name": "@cheatoid/tstl-extensions/index.js",
+       "hasContinue": true
      }
    ]
  }
}

With this change applied, you can use continue in your TS code and it will emit a continue statement in Lua.

goto & label support

Only usable if your target Lua environment supports goto and labels (such as Lua 5.2+ or JIT)...
The following table is hopefully self-explanatory: | TypeScript | Lua | | :------------------: | :------------: | | __goto("MyLabel") | goto MyLabel | | __label("MyLabel") | ::MyLabel:: |

Efficient swapping

This allows you to swap two values without a temporary variable:
The following table is hopefully self-explanatory: | TypeScript | Lua | | :----------------------: | :-------------------------------: | | __swap(arr[0], arr[1]) | arr[1], arr[2] = arr[2], arr[1] |

unsafe_cast

This is useful in-place replacement for as any casting, because it allows to "find all references" quickly.
For example, instead of writing foo as any as TheFoo (or <TheFoo><any>foo), you can instead do unsafe_cast<TheFoo>(foo).

next iterator support

Call __next using for-of loop, you may optionally want to specify a starting index.
Example usage:

for (const [k, v] of __next(_G)) {
    print(k, v);
}

Transpiles to:

for k, v in next, _G do
    print(k, v)
end

Aggressive inlining

Function calls have certain performance overhead. This feature allows to inline the body of the given function in-place, which can be beneficial in hot-path for high-performance code. It mostly just works, but consider it as experimental.
Currently there is a drawback in the implementation, the target function must be defined in the same file where you want to inline it.
Simple example:

function InlineExample(name: string) {
    print(`Hello, ${name}`);
    print("The code to be inlined goes here");
}
const john = "John";
__inline(InlineExample, john);
__inline(InlineExample, "Moon");

Transpiles to:

local john = "John"
do
    local name = john
    print("Hello, " .. name)
    print("The code to be inlined goes here")
end
do
    local name = "Moon"
    print("Hello, " .. name)
    print("The code to be inlined goes here")
end

Top-level return

This feature allows you to bypass TypeScript limitation - ts(1108) error.
You should only consider this as a last resort option (hint: try using export assignment export = ...), or if you want to bail out from a script.
Simply call __return, you may optionally pass additional arguments to be returned at call site.

And more...

I am just tired to go over all of them... I hope there is a little bit of something for everyone to enjoy. :P

📜 History

This plugin was initially published at GitHub Gist (here), which is outdated as of now, perhaps you may still find something interesting down in the comments.

👏 Credits

Special thanks to TypeScriptToLua developers and contributors for their awesome project.