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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AsConverterRegistry(): AsConverterRegistry;Returns
Section titled “Returns”AsConverterRegistry
Properties
Section titled “Properties”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.
folded
Section titled “folded”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.
Methods
Section titled “Methods”match()
Section titled “match()”match(typed): AsConverterMatch;Defined in: packages/engine/src/vm/AsConverterRegistry.ts:153
How typed matches this registry; see AsConverterMatch.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
typed | string | The target as the reader wrote it. |
Returns
Section titled “Returns”register()
Section titled “register()”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).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
name | string | The converter’s name, as a reader writes it after as. |
handler | AsConverter | The converter. |
Returns
Section titled “Returns”void
resolve()
Section titled “resolve()”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).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
typed | string | The target as the reader wrote it. |
Returns
Section titled “Returns”| AsConverter
| undefined
The converter, or undefined when nothing is registered.
unregister()
Section titled “unregister()”unregister(name): void;Defined in: packages/engine/src/vm/AsConverterRegistry.ts:133
Reverse a register call. A name never registered is ignored.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
name | string | The name as it was registered. |
Returns
Section titled “Returns”void