a very very tiny (641 byte) math evaluator in javascript https://basilpa.ws/tinyexpr
Find a file
2025-09-24 14:42:27 -04:00
.gitignore initial commit 2025-09-22 04:33:30 -04:00
.prettierrc initial commit 2025-09-22 04:33:30 -04:00
LICENSE.md license 2025-09-24 14:42:27 -04:00
package.json another strict equality error 2025-09-24 13:51:11 -04:00
pnpm-lock.yaml fix literals being treated as operations, added some tests 2025-09-24 13:33:14 -04:00
pnpm-workspace.yaml initial commit 2025-09-22 04:33:30 -04:00
README.md another strict equality error 2025-09-24 13:51:11 -04:00
tinyexpr.js another strict equality error 2025-09-24 13:51:11 -04:00
tinyexpr.test.ts fix literals being treated as operations, added some tests 2025-09-24 13:33:14 -04:00
tinyexpr.ts another strict equality error 2025-09-24 13:51:11 -04:00
tsconfig.json initial commit 2025-09-22 04:33:30 -04:00

tinyexpr

a very very tiny (642 byte bundled, 424 byte gzipped) math evaluator in javascript

it isn't fast, it could be smaller, it isn't written well, but it was fun to make :)

developing

source is in tinyexpr.ts, go nuts

building

there is a prebuilt file called tinyexpr.js in the repo, but if you're hacking this and want to rebuild it use pnpm build

how it could be smaller

if you wanna take a shot at it:

  • roll tokenizing and evaluating into one step
  • use something other than recursive descent parsing
  • probably a lot of little hand optimizations