The Javascript Library

The bml library is mostly exposed by a single function:

bml(sourceString: string, renderSettings: object?)

where sourceString is a single string holding the contents of a complete bml document, and renderSettings is an optional Object with the following properties:

setting default purpose
randomSeed null a random seed for the render session. may be any Object. All bml documents rendered on the same bml version with the same random seed should result in the same output, assuming the bml document's eval block is deterministic or uses the provided functions for random components
allowEval true A boolean flag controlling whether eval blocks should be allowed in this render. If false, eval blocks will cause an error to be thrown. This is primarily useful for security purposes.

Static analysis

The library can also perform static analysis on BML documents to approximate how many possible branches there are in a given document. This does a rough back-of-the-envelope approximation of the number of possible branches through the document. It has several shortcomings, especially when dealing with refs and silent forks.

analyze(bmlDocument: string): { possibleOutcomes: bigint }