Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

AsConverterRegistry

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:75

One engine’s as <name> converters, the store behind IEnginePackage.asConverters (#710).

Held on the engine’s EngineContext, so a converter one engine registers is invisible to every other engine in the process, and unregistering a package from one engine leaves another’s copy in place. A unit’s prefix is carried by its case (mW is a milliwatt, MW a megawatt), so a converter is kept both under its exact spelling and under its lower-cased key, with the spellings each key has, and a folded spelling two units share refuses by name (#824). All three maps move together; none is meaningful without the others.

Every map is a Map, so a name such as constructor or __proto__ is a key like any other and resolves to nothing it was not given.

new AsConverterRegistry(): AsConverterRegistry;

AsConverterRegistry

readonly exact: Map<string, AsConverter>;

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:82

The converters whose registered name carries capitals, by that exact spelling.


readonly folded: Map<string, AsConverter>;

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:80

Converters by lower-cased key. A key two case-distinct spellings share holds a converter that refuses by name.

match(typed): AsConverterMatch;

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:153

How typed matches this registry; see AsConverterMatch.

ParameterTypeDescription
typedstringThe target as the reader wrote it.

AsConverterMatch


register(name, handler): void;

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:101

Register a converter. Warns (does not throw) on a name collision, since two independently authored packages picking one name is a real possibility and silently overwriting is worse than a visible warning. The warning is skipped when handler is the one already registered (a package’s converters are module-level constants, registered afresh by every engine that loads the package).

ParameterTypeDescription
namestringThe converter’s name, as a reader writes it after as.
handlerAsConverterThe converter.

void


resolve(typed):
| AsConverter
| undefined;

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:174

The converter an as target names. The spelling as typed is tried first, so as mW and as MW reach different units; then the lower-cased key, so as ISO8601 still reaches iso8601 and as n the newton. A folded spelling that two units share (as mw), or that would change a prefix’s case (as MV when only mV is registered), gets a converter that refuses by name (#824).

ParameterTypeDescription
typedstringThe target as the reader wrote it.

| AsConverter | undefined

The converter, or undefined when nothing is registered.


unregister(name): void;

Defined in: packages/engine/src/vm/AsConverterRegistry.ts:133

Reverse a register call. A name never registered is ignored.

ParameterTypeDescription
namestringThe name as it was registered.

void