How to use the @bentley/imodeljs-quantity.Format 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 loadStdFormat(type: QuantityType, imperial: boolean): Promise {
    let formatData: any;

    const formatArray = imperial ? defaultsFormats.imperial : defaultsFormats.metric;
    for (const entry of formatArray) {
      if (entry.type === type as number) {
        formatData = entry.format;
        const format = new Format("stdFormat");
        await format.fromJson(this, formatData);
        return Promise.resolve(format);
      }
    }
    throw new BentleyError(BentleyStatus.ERROR, "IModelApp must define a formatsProvider class to provide formats for tools");
  }