tooling to generate a JS/WebAssembly version of NBER TAXSIM
Uses the gfortran/dragonegg toolchain from StarGate01/Full-Stack-Fortran to convert taxsim.f
from fixed-mode f90 fortran into LLVM bitcode, then uses emscripten to convert LLVM bitcode into a JS/WASM wrapper.
Note: taxsim.f
is not included, and must be obtained separately from the NBER.
$ make taxsim.js
the Makefile
uses docker and the stargate01/f90wasm container to compile our fortran code. see Dockerfile
for the build commands.
function taxsim(input: String): Promise
function taxsim(input: Object): Promise
let input = "taxsimid,mstat,year,ltcg,idtl\n1,2,1970,100000,5"
let output = await taxsim(input)
let output = await taxsim({
year: 2020,
mstat: 2,
ltcg: 100000
})
- see demo.html (source) or the live version
-
bash:
$ printf "year,mstat\n2020,2" | node -e "require('./taxsim.js')()" $ node --input-type=module -e "import taxsim from './taxsim.js'; console.log(await taxsim({year:2020,mstat:2}))"
-
powershell:
> "year,mstat`n2020,2" | node -e "require('./taxsim.js')()"
-
d8:
$ printf "year,mstat\n2020,2\n" | d8 -e "load('./taxsim.js'); taxsim()" $ d8 -e "load('./taxsim.js'); function quit(){}; taxsim({year:2020,mstat:2}).then(console.log).catch(console.log)"
-
> download.file("https://taxsim.app/taxsim.wasm", "taxsim.wasm", mode="wb") > download.file("https://taxsim.app/taxsim.js", "taxsim.js") > library(V8) > ctx <- v8() > ctx$assign("wasmBinary", readBin("taxsim.wasm", raw(), file.info("taxsim.wasm")$size)) > ctx$source("taxsim.js") > ctx$call("taxsim", JS("{year:2020, mstat:2}"), JS("{wasmBinary}"), await=TRUE)