createUnitsProvider Function

Returns a UnitsProvider that layers the basic BIS units under (or over) an optional primary provider. Typical use: layer an iModel's schema units on top of the bundled defaults from @itwin/core-quantity.

Precedence rules:

  • When primary is supplied and bisUnitsPolicy is "preferSchema" (the default): primary wins; basic BIS units fill any gaps where primary returns an invalid unit or throws.
  • When bisUnitsPolicy is "preferBundled": basic BIS units win; primary is consulted only when the basic provider can't answer.
  • getUnitsByFamily always merges results from both providers, deduplicated by UnitProps.name (fully-qualified). The first-consulted provider wins ties.
  • When no primary is supplied, the returned provider is exactly new BasicUnitsProvider() (no wrapper), preserving instanceof checks and keeping the hot path fast.

createUnitsProvider(options: CreateUnitsProviderOptions = {}): UnitsProvider

Parameter Type Description
options CreateUnitsProviderOptions  

Returns - UnitsProvider

Defined in

Last Updated: 01 May, 2026