I am doing a system rewrite and there is a certain amount of hard coding going on. There was a not very well thought out strategy of making the front end configurable by a CRM but its a bit of a mess. I have a dev console on the app and want to make the hard coded data visible there. There is a config module that only has functions of arity/0. I want the dev console to interrogate that module at run time - get the a list of the functions, iterate over it calling them and the dump the results on the page. Is this possible in Typescript. Its kinda of a thing I would <just do> on the BEAM but ya know, other progamming languages...
#Dynamically interrogate modules and call their functions at run time
6 messages · Page 1 of 1 (latest)
What about having all of these functions stored in an object that gets exported and then query the objectentries?
modules are introspectable in javascript too without doing anything special. just import * as stuff from './your/module.js' and then console.log(stuff) (or use a for..in loop to iterate over stuff's properties and call the functions or whatever)