Let's say I have javascript files on IPFS, for example, this. I want to build a piece of javascript (node) code that will retrieve the ipfs hash, and will then have to load the file(s) pointed to. So far I'm doing:
node.get(fileHash, (err, files) => {
// some check for error
files
.filter(file => file.type === 'file')
.forEach(file => {
vm.runInThisContext(
code = file.content.toString('utf8'),
options = { filename: file.name }
);
});
});
I don't really want to mess up with the filesystem (this will have to run in a browser) so I'd like to avoid writing the files and then requiring them.
Is there a better way to load javascript code that is stored in a variable (basically). I feel like I'm using some sort of eval ... which I don't like