Open a10k opened 3 years ago
Thanks for the report!
You're, right, this
isn't defined correctly for .module()
and .cell()
, but seems to work correctly for .moduleToESModule()
. This notebook goes into the problem a little deeper.
Pretty sure it's got to do with how we use f = new Function(...)
, seems like there's a few Function methods like .call
or .bind
that we may to need use, will try to debug further...
@asg017 I can look into this later too if you need a hand!
I see in your example in readme file is wrong -> new Interpreter({module: module, observer: observer}).
This Interpreter are much more flexible and functionality. However i just wonder how to deal with built in variables i.e. md, html etc. I mean how to delete or change existing one using this Interpreter?
Hey @Srabutdotcom , for changing which builtin cells are used in your implementation, that's the job of the runtime, not the interpreter. The interpreter takes in a runtime module as an input, where that module already has the builtin cells included. Using this example from the runtime readme, you can do something like:
const runtime = new Runtime({color: "red"});
This creates a new runtime with different builtin cells (in this case, a cell called color
that has a value of "red"
). Then, you create a module with that runtime and pass it into the Interpreter like so:
const main = runtime.module();
const interpret = new Interpreter();
const observer = () => true
await interpret.cell(" example = `The value of color is ${color}` ", main, observer);
await main.value("example") // "The value of color is red"
Also, feel free to ask more questions in #29 , which is about the new Interpreter/Compiler API, or create a new issue (since this issue is about another problem)
Hai @asg017 ,
Sorry, i mean standard library. lets for example we have 3 md in 3 different cells.
md 1st md
md second
md third md
how do we change or update md second
for example?
@Srabutdotcom please file a new issue with details on what youre trying to do, and whatever code you have. Also see #29 for example of the new Interpreter.
when defining a cell, the value of 'this' is set as window, while for the compiled output of the same code it will be undefined by default.