0.0.0 • Published 2 years ago

type-math v0.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Type-Math

thanks to typescript 4.8, we can now do any math we want using string literals and then cast it back to a number

this enables many more possibilities for the actual calculations. For example:

import { M } from "type-math";

type T = M<1023904812930, "+", 13482194249>;
// => 1037387007179

which previously would never have been possible

Usage

type-math supports all the following operations with the M type:

  • Addition
  • Subtraction
  • Multiplication
  • Exponentiation
  • Division
  • Modulo
  • Greater Than
  • Greater Than or Equal To
  • Less Than
  • Less Than or Equal To
  • Equals