Skip to content

Commit ddd3d48

Browse files
committed
italicize variable names
1 parent 2f36172 commit ddd3d48

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The **Observable Runtime** implements reactivity in both [Observable Framework](
66

77
### Runtimes
88

9-
#### new Runtime(builtins, global)
9+
#### new Runtime(*builtins*, *global*)
1010

1111
[Source](https://github.com/observablehq/runtime/blob/main/src/runtime.js) · Returns a new [runtime](#runtimes). If *builtins* is specified, each property on the *builtins* object defines a builtin variable for the runtime. These builtins are available as named inputs to any [defined variables](#variable_define) on any [module](#modules) associated with this runtime. If a *global* function is specified, it will be invoked with the name of any unresolved reference, and must return the corresponding value or undefined (to trigger a ReferenceError); if *global* is not specified, unresolved values will be resolved from the global window.
1212

@@ -30,31 +30,31 @@ This would produce the following output:
3030
3131
Unlike [variables](#variables), builtins cannot depend on the value of other variables or builtins; they are defined with no inputs. If a builtin is defined as a function, it will be invoked lazily to determine the value of the builtin. If you wish for the value of a builtin to be a function, the builtin must be defined either as a promise that resolves to a function or as a function that returns a function. Builtins may also be defined as generators for dynamic values.
3232

33-
#### runtime.module(define, observer)
33+
#### *runtime*.module(*define*, *observer*)
3434

3535
[Source](https://github.com/observablehq/runtime/blob/main/src/runtime.js) · Returns a new [module](#modules) for this [runtime](#runtimes).
3636

3737
If *define* is specified, it is a function which defines the new module’s [variables](#variables) by calling *runtime*.module (with no arguments) and then calling [*module*.variable](#module_variable) on the returned module as desired. If this runtime already has a module for the specified *define* function, the existing module is returned; otherwise, a new module is created, and the *define* function is called, being passed this runtime and the specified *observer* factory function. If *define* is not specified, a new module is created and returned.
3838

3939
If an *observer* factory function is specified, it is called for each named variable in the returned module, being passed the variable’s name.
4040

41-
#### runtime.dispose()
41+
#### *runtime*.dispose()
4242

4343
[Source](https://github.com/observablehq/runtime/blob/main/src/runtime.js) · Disposes this runtime, invalidating all active variables and disabling future computation.
4444

4545
### Modules
4646

4747
A module is a namespace for [variables](#variables); within a module, variables should typically have unique names. [Imports](#variable_import) allow variables to be referenced across modules.
4848

49-
#### module.variable(observer)
49+
#### *module*.variable(*observer*)
5050

5151
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · Returns a new [variable](#variables) for this [module](#modules). The variable is initially undefined.
5252

5353
If *observer* is specified, the specified [observer](#observers) will be notified when the returned variable changes state, via the [observer.*pending*](#observer_pending), [observer.*fulfilled*](#observer_fulfilled) and [observer.*rejected*](#observer_rejected) methods. See the [standard inspector](https://github.com/observablehq/inspector/blob/master/README.md) for a convenient default observer implementation.
5454

5555
A variable without an associated *observer* is only computed if any transitive output of the variable has an *observer*; variables are computed on an as-needed basis for display. This is particularly useful when the runtime has multiple modules (as with [imports](#variable_import)): only the needed variables from imported modules are computed.
5656

57-
#### module.derive(specifiers, source)
57+
#### *module*.derive(*specifiers*, *source*)
5858

5959
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · Returns a derived copy of this [module](#modules), where each variable in *specifiers* is replaced by an [import](#variable_import) from the specified *source* module. The *specifiers* are specified as an array of objects with the following properties:
6060

@@ -81,43 +81,43 @@ module1.variable().import("c", module1_0);
8181

8282
The value of *c* in the derived module is now 1 + 3 = 4, whereas the value of *c* in the original module remains 1 + 2 = 3.
8383

84-
#### module.define(name, inputs, definition)
84+
#### *module*.define(*name*, *inputs*, *definition*)
8585

8686
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · A convenience method for [*variable*.define](#variable_define); equivalent to:
8787

8888
```js
8989
module.variable().define(name, inputs, definition)
9090
```
9191

92-
#### module.import(name, alias, from)
92+
#### *module*.import(*name*, *alias*, *from*)
9393

9494
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · A convenience method for [*variable*.import](#variable_import); equivalent to:
9595

9696
```js
9797
module.variable().import(name, alias, from)
9898
```
9999

100-
#### module.builtin(name, value)
100+
#### *module*.builtin(*name*, *value*)
101101

102102
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · Defines a built-in constant that is visible to all variables in this module. _Caution: any built-ins must be defined before variables are defined, and must not be redefined after._ For example, to define a `FileAttachment` function:
103103

104104
```js
105105
module.builtin("FileAttachment", (name) => FileAttachment(name))
106106
```
107107

108-
#### module.redefine(name, inputs, definition)
108+
#### *module*.redefine(*name*, *inputs*, *definition*)
109109

110110
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · Redefines the *variable* with the specified *name* on this module. If no such variable exists, or if more than one variable has the specified *name*, throws a runtime error.
111111

112-
#### module.value(name)
112+
#### *module*.value(*name*)
113113

114114
[Source](https://github.com/observablehq/runtime/blob/main/src/module.js) · Returns a promise to the next value of the *variable* with the specified *name* on this module. If no such variable exists, or if more than one variable has the specified *name*, throws a runtime error.
115115

116116
### Variables
117117

118118
A variable defines a piece of state in a reactive program, akin to a cell in a spreadsheet. Variables may be named to allow the definition of derived variables: variables whose value is computed from other variables’ values. Variables are scoped by a [module](#modules) and evaluated by a [runtime](#runtimes).
119119

120-
#### variable.define(name, inputs, definition)
120+
#### *variable*.define(*name*, *inputs*, *definition*)
121121

122122
[Source](https://github.com/observablehq/runtime/blob/main/src/variable.js) · Redefines this variable to have the specified *name*, taking the variables with the names specified in *inputs* as arguments to the specified *definition* function. If *name* is null or not specified, this variable is anonymous and may not be referred to by other variables. The named *inputs* refer to other variables (possibly [imported](#variable_import)) in this variable’s module. Circular inputs are not allowed; the variable will throw a ReferenceError upon evaluation. If *inputs* is not specified, it defaults to the empty array. If *definition* is not a function, the variable is defined to have the constant value of *definition*.
123123

@@ -177,7 +177,7 @@ b.define("bar", 2);
177177

178178
Likewise deleting *a* or *b* would allow the other variable to resolve to its desired value.
179179

180-
#### variable.import(name, alias, module)
180+
#### *variable*.import(*name*, *alias*, *module*)
181181

182182
[Source](https://github.com/observablehq/runtime/blob/main/src/variable.js) · Redefines this variable as an alias of the variable with the specified *name* in the specified [*module*](#modules). The subsequent name of this variable is the specified *name*, or if specified, the given *alias*. The order of arguments corresponds to the standard import statement: `import {name as alias} from "module"`. For example, consider a module which defines a variable named `foo`:
183183

@@ -213,22 +213,22 @@ To import `foo` into *module1* under the alias `bar`:
213213
module1.variable().import("foo", "bar", module0);
214214
```
215215

216-
#### variable.delete()
216+
#### *variable*.delete()
217217

218218
[Source](https://github.com/observablehq/runtime/blob/main/src/variable.js) · Deletes this variable’s current definition and name, if any. Any variable in this module that references this variable as an input will subsequently throw a ReferenceError. If exactly one other variable defined this variable’s previous name, such that that variable throws a ReferenceError due to its duplicate definition, that variable’s original definition is restored.
219219

220220
### Observers
221221

222222
An observer watches a [variable](#variables), being notified via asynchronous callback whenever the variable changes state. See the [standard inspector](https://github.com/observablehq/inspector) for a reference implementation.
223223

224-
#### observer.pending()
224+
#### *observer*.pending()
225225

226226
Called shortly before the variable is computed. For a generator variable, this occurs before the generator is constructed, but not before each subsequent value is pulled from the generator.
227227

228-
#### observer.fulfilled(value)
228+
#### *observer*.fulfilled(*value*)
229229

230230
Called shortly after the variable is fulfilled with a new *value*.
231231

232-
#### observer.rejected(error)
232+
#### *observer*.rejected(*error*)
233233

234234
Called shortly after the variable is rejected with the given *error*.

0 commit comments

Comments
 (0)