How to use the @bentley/imodeljs-quantity.ParserSpec.create function in @bentley/imodeljs-quantity

To help you get started, we’ve selected a few @bentley/imodeljs-quantity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / core / frontend / src / QuantityFormatter.ts View on Github external
protected async loadParsingSpecsForQuantityTypes(useImperial: boolean): Promise {
    const typeArray: QuantityType[] = [QuantityType.Length, QuantityType.Angle, QuantityType.Area, QuantityType.Volume, QuantityType.LatLong, QuantityType.Coordinate, QuantityType.Stationing, QuantityType.LengthSurvey, QuantityType.LengthEngineering];
    const activeMap = useImperial ? this._imperialParserSpecsByType : this._metricUnitParserSpecsByType;
    activeMap.clear();

    for (const quantityType of typeArray) {
      const formatPromise = this.getFormatByQuantityType(quantityType, useImperial);
      const unitPromise = this.getUnitByQuantityType(quantityType);
      const [format, outUnit] = await Promise.all([formatPromise, unitPromise]);
      const parserSpec = await ParserSpec.create(format, this, outUnit);
      activeMap.set(quantityType, parserSpec);
    }
    return Promise.resolve();
  }