1.0.0 • Published 4 months ago

ts-char-to-byte v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

ts-char-to-bytes

A simple TypeScript transformer to convert function calls to charToByte to a literal.

Motivation

Coming from C/C++ background, it pains me to have to make a function call to get the underlying byte value of a character. This is especially true when I'm calling this function at runtime over and over again. This transformer moves that runtime call to compile time.

This is really a proof-of-concept to help me learn how to write a TypeScript transformer.

Usage

First, you'll need to install something like ts-patch to allow you to specify a custom transformer.

Then, you'll need to install this package:

npm install ts-char-to-bytes

Finally, you'll need to specify the transformer in your tsconfig.json:

{
  "compilerOptions": {
    "plugins": [
      {
        "transform": "ts-char-to-bytes"
      }
    ]
  }
}