Reference
Expressions
Expressions may be used in two contexts:
- value - when using the
rngo.value
JSON schema extension to generate realistic values - rate - when specifying a dynamic event rate in the stream
rate
field - duration - when setting the
start
andend
of the simution.
Context
Each context has entrypoint methods that may be referenced in expressions without explicit qualification.
Value
Method | Returns | Notes |
.streams | Object [Stream ] | A map of every stream in the workspace, keyed by its name. |
.data | DataCatalog | A map of all enums provided by rngo. See Enums for more. |
.sim | Simulation | The simulation state when the value is being generated. |
Rate
Method | Returns | Notes |
.sim | Simulation | The simulation state when the rate is being sampled. |
Duration
Method | Args | Returns | Notes |
.daysAgo | days : Number | Timestamp | Returns the number of days prior to the time when the expression is evaluated. |
.yearsAgo | years : Number | Timestamp | Returns the number of years prior to the time when the expression is evaluated. |
.daysFromNow | days : Number | Timestamp | Returns the number of days after the time when the expression is evaluated. |
.yearsFromNow | years : Number | Timestamp | Returns the number of years after the time when the expression is evaluated. |
API
DataCatalog
Categorized data sets used to further narrow valid stream output beyond the JSON Schema definition.
See Data Catalog for more.
Stream
The state of a stream at the current point in the simulation. Stream
extends Set
so you can also call Set
methods on a Stream
instance.
Example: The set of all id
values in the posts
stream
stream.posts.last.id
Method | Returns | Notes |
.first | Value | Null | The first value generated by the stream, if any. |
.last | Value | Null | The last value generated by the stream, if any. |
Set
A collection of Value
s, that is potentially very large. Commonly used to specify rngo.value
in a schema.
Example: A random value in the fullName
enum
enum.fullName.random
Method | Returns | Notes |
.random | Value | Null | Returns a random value from the set, or null if empty. |
.unique | Value | Null | Returns a random value from the set that has not been previously returned. If all values have been returned, or if the set is empty, returns null. |
Simulation
Information about the current state of the simulation.
Example: The current time in the simulation
sim.now
Method | Returns | Notes |
.now | Timestamp | The current UTC wall clock time within the simulation. |
.offset | Number | The integer number of milliseconds since the simulation started. |
Data Types
Value
Any value generated by a stream. It is a recursive union type with any of the following variants:
Array
An ordered collection, generic over type T
.
Method | Returns | Notes |
[{index}] | T | Null | Returns the value at the specified integer index, if ones exists. |
Object
An associated array, generic over value type T
.
Method | Returns | Notes |
.{property} | T | Null | Returns the value of a named property, if it exists. |
Boolean
Either true or false.
Null
A value that represents the absence of a value.
Number
An integer or floating point number.
String
A sequence of Unicode characters.
Timestamp
An ISO 8901 UTC timestamp.
Method | Returns | Notes |
.string | String | The ISO 8901 representation of the timestamp. |