How to use the @bentley/imodeljs-quantity.BasicUnit 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
public async findUnit(unitLabel: string, unitFamily?: string): Promise {
    for (const entry of unitData) {
      if (unitFamily) {
        if (entry.unitFamily !== unitFamily)
          continue;
      }
      if (entry.displayLabel === unitLabel || entry.name === unitLabel) {
        const unitProps = new BasicUnit(entry.name, entry.displayLabel, entry.unitFamily, entry.altDisplayLabels);
        return Promise.resolve(unitProps);
      }

      if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
        if (entry.altDisplayLabels.findIndex((ref) => ref === unitLabel) !== -1) {
          const unitProps = new BasicUnit(entry.name, entry.displayLabel, entry.unitFamily, entry.altDisplayLabels);
          return Promise.resolve(unitProps);
        }
      }
    }

    return Promise.resolve(new BadUnit());
  }
github imodeljs / imodeljs / core / frontend / src / QuantityFormatter.ts View on Github external
public async getUnitsByFamily(unitFamily: string): Promise {
    const units: UnitProps[] = [];
    for (const entry of unitData) {
      if (entry.unitFamily !== unitFamily)
        continue;
      units.push(new BasicUnit(entry.name, entry.displayLabel, entry.unitFamily, entry.altDisplayLabels));
    }
    return Promise.resolve(units);
  }
github imodeljs / imodeljs / core / frontend / src / QuantityFormatter.ts View on Github external
public async findUnitByName(unitName: string): Promise {
    const unitDataEntry = this.findUnitDefinition(unitName);
    if (unitDataEntry) {
      return Promise.resolve(new BasicUnit(unitDataEntry.name, unitDataEntry.displayLabel, unitDataEntry.unitFamily, unitDataEntry.altDisplayLabels));
    }
    return Promise.resolve(new BadUnit());
  }