3 ms·
Are the language/syntax differences documented somewhere? It's difficult to tell if something is an obscure early stage ecmascript proposal or a language featur
by arnioxux 9y ago
Are the language/syntax differences documented somewhere? It's difficult to tell if something is an obscure early stage ecmascript proposal or a language feature specific to observablehq. For example in https://beta.observablehq.com/@mbostock/introduction-to-notebooks https://beta.observablehq.com/@mbostock/introduction-to-note...
import {canvas as flood} with {height} from "@mbostock/randomized-flood-fill"
or how you define generators
i = {
let i = 0;
while (true) {
yield ++i;
}
}
etc
- mbostock 9y agoWe’re still writing more documentation, but there’s a bit more detail here (and I’ll be posting more soon): https://beta.observablehq.com/@mbostock/introduction-to-code https://beta.observablehq.com/@mbostock/introduction-to-code To summarize, the body of a cell is typically either an expression or a block statement, akin to the body of an arrow function. If a cell starts with name = …, then it has a name and can be referenced by other cells. So, the name = part is specific to Observable, but the expression and block statement is normal JavaScript. The import declaration is similar to a normal static ES import, but the with clause allows you to inject local definitions into the imported notebook.