dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

Support math functions #226

Closed canac closed 1 year ago

canac commented 1 year ago

I'm trying to use mathematical functions with this library (log2 specifically), but it seems that it needs to be enabled via a compile-time flag. When I compile it with -DSQLITE_ENABLE_MATH_FUNCTIONS on my machine, the file sizes seem to increase by about 10%.

--- a/build/size.txt
+++ b/build/size.txt
@@ -1,7 +1,7 @@
 sqlite.d.ts    ➜   3373 bytes
-sqlite.js      ➜ 859807 bytes
-sqlite.js.br   ➜ 283999 bytes
-sqlite.js.gz   ➜ 349663 bytes
-sqlite.wasm    ➜ 643797 bytes
-sqlite.wasm.br ➜ 227012 bytes
-sqlite.wasm.gz ➜ 268601 bytes
+sqlite.js      ➜ 900783 bytes
+sqlite.js.br   ➜ 303368 bytes
+sqlite.js.gz   ➜ 370769 bytes
+sqlite.wasm    ➜ 674529 bytes
+sqlite.wasm.br ➜ 243322 bytes
+sqlite.wasm.gz ➜ 286362 bytes

Is that an acceptable size increase to enable math functions? Or should I just fork to enable them for my own project?

canac commented 1 year ago

I got it working by forking this library, adding -DSQLITE_ENABLE_MATH_FUNCTIONS to the Makefile, and rebuilding. But I ended up deciding to do the math in JS-land instead. Hopefully this will help someone else in the future though.