@itwin/core-quantity 4.0.0-dev.48 → 4.0.0-dev.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/lib/cjs/Constants.d.ts +27 -27
  2. package/lib/cjs/Constants.js +52 -52
  3. package/lib/cjs/Constants.js.map +1 -1
  4. package/lib/cjs/Exception.d.ts +26 -26
  5. package/lib/cjs/Exception.js +38 -38
  6. package/lib/cjs/Exception.js.map +1 -1
  7. package/lib/cjs/Formatter/Format.d.ts +91 -91
  8. package/lib/cjs/Formatter/Format.js +328 -328
  9. package/lib/cjs/Formatter/Format.js.map +1 -1
  10. package/lib/cjs/Formatter/FormatEnums.d.ts +133 -133
  11. package/lib/cjs/Formatter/FormatEnums.js +318 -318
  12. package/lib/cjs/Formatter/FormatEnums.js.map +1 -1
  13. package/lib/cjs/Formatter/Formatter.d.ts +44 -44
  14. package/lib/cjs/Formatter/Formatter.js +371 -371
  15. package/lib/cjs/Formatter/Formatter.js.map +1 -1
  16. package/lib/cjs/Formatter/FormatterSpec.d.ts +39 -39
  17. package/lib/cjs/Formatter/FormatterSpec.js +101 -101
  18. package/lib/cjs/Formatter/FormatterSpec.js.map +1 -1
  19. package/lib/cjs/Formatter/Interfaces.d.ts +62 -62
  20. package/lib/cjs/Formatter/Interfaces.js +17 -17
  21. package/lib/cjs/Formatter/Interfaces.js.map +1 -1
  22. package/lib/cjs/Interfaces.d.ts +86 -86
  23. package/lib/cjs/Interfaces.js +9 -9
  24. package/lib/cjs/Interfaces.js.map +1 -1
  25. package/lib/cjs/Parser.d.ts +93 -93
  26. package/lib/cjs/Parser.js +592 -592
  27. package/lib/cjs/Parser.js.map +1 -1
  28. package/lib/cjs/ParserSpec.d.ts +34 -34
  29. package/lib/cjs/ParserSpec.js +47 -47
  30. package/lib/cjs/ParserSpec.js.map +1 -1
  31. package/lib/cjs/Quantity.d.ts +27 -27
  32. package/lib/cjs/Quantity.js +46 -46
  33. package/lib/cjs/Quantity.js.map +1 -1
  34. package/lib/cjs/Unit.d.ts +25 -25
  35. package/lib/cjs/Unit.js +44 -44
  36. package/lib/cjs/Unit.js.map +1 -1
  37. package/lib/cjs/core-quantity.d.ts +19 -19
  38. package/lib/cjs/core-quantity.js +35 -35
  39. package/lib/cjs/core-quantity.js.map +1 -1
  40. package/lib/esm/Constants.d.ts +27 -27
  41. package/lib/esm/Constants.js +48 -48
  42. package/lib/esm/Constants.js.map +1 -1
  43. package/lib/esm/Exception.d.ts +26 -26
  44. package/lib/esm/Exception.js +34 -34
  45. package/lib/esm/Exception.js.map +1 -1
  46. package/lib/esm/Formatter/Format.d.ts +91 -91
  47. package/lib/esm/Formatter/Format.js +323 -323
  48. package/lib/esm/Formatter/Format.js.map +1 -1
  49. package/lib/esm/Formatter/FormatEnums.d.ts +133 -133
  50. package/lib/esm/Formatter/FormatEnums.js +302 -302
  51. package/lib/esm/Formatter/FormatEnums.js.map +1 -1
  52. package/lib/esm/Formatter/Formatter.d.ts +44 -44
  53. package/lib/esm/Formatter/Formatter.js +367 -367
  54. package/lib/esm/Formatter/Formatter.js.map +1 -1
  55. package/lib/esm/Formatter/FormatterSpec.d.ts +39 -39
  56. package/lib/esm/Formatter/FormatterSpec.js +97 -97
  57. package/lib/esm/Formatter/FormatterSpec.js.map +1 -1
  58. package/lib/esm/Formatter/Interfaces.d.ts +62 -62
  59. package/lib/esm/Formatter/Interfaces.js +13 -13
  60. package/lib/esm/Formatter/Interfaces.js.map +1 -1
  61. package/lib/esm/Interfaces.d.ts +86 -86
  62. package/lib/esm/Interfaces.js +8 -8
  63. package/lib/esm/Interfaces.js.map +1 -1
  64. package/lib/esm/Parser.d.ts +93 -93
  65. package/lib/esm/Parser.js +588 -588
  66. package/lib/esm/Parser.js.map +1 -1
  67. package/lib/esm/ParserSpec.d.ts +34 -34
  68. package/lib/esm/ParserSpec.js +43 -43
  69. package/lib/esm/ParserSpec.js.map +1 -1
  70. package/lib/esm/Quantity.d.ts +27 -27
  71. package/lib/esm/Quantity.js +42 -42
  72. package/lib/esm/Quantity.js.map +1 -1
  73. package/lib/esm/Unit.d.ts +25 -25
  74. package/lib/esm/Unit.js +39 -39
  75. package/lib/esm/Unit.js.map +1 -1
  76. package/lib/esm/core-quantity.d.ts +19 -19
  77. package/lib/esm/core-quantity.js +23 -23
  78. package/lib/esm/core-quantity.js.map +1 -1
  79. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.js","sourceRoot":"","sources":["../../../src/Formatter/Formatter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAuB,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhI;;GAEG;AACH,MAAM,eAAe,GAAG,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,iBAAiB;IAOrB,YAAY,KAAa,EAAE,SAA8B,EAAE,MAAe;QANlE,cAAS,GAAW,CAAC,CAAC;QACtB,eAAU,GAAW,CAAC,CAAC;QACvB,iBAAY,GAAW,CAAC,CAAC;QACzB,0BAAqB,GAAW,CAAC,CAAC;QAClC,eAAU,GAAa,EAAE,CAAC;QAGhC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAmB,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEO,SAAS,CAAC,KAAa,EAAE,WAAmB;QAClD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC3C,MAAM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AI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC;YAC3E,cAAc,GAAG,MAAM,GAAG,kBAAkB,GAAG,MAAM,CAAC;;YAEtD,cAAc,GAAG,kBAAkB,CAAC;QAEtC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC,MAAM;YACtE,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAErD,OAAO,cAAc,CAAC;IACxB,CAAC;;AAzTD,gEAAgE;AACjD,0BAAgB,GAAG,OAAO,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { QuantityConstants } from \"../Constants\";\nimport { QuantityError, QuantityStatus } from \"../Exception\";\nimport { FormatterSpec } from \"./FormatterSpec\";\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"./FormatEnums\";\n\n/** rounding additive\n * @internal\n */\nconst FPV_ROUNDFACTOR = 0.50000000001;\n\n/** A private helper class used to format fraction part of value into a numerator and denominator.\n * @internal\n */\nclass FractionalNumeric {\n private _integral: number = 0;\n private _numerator: number = 0;\n private _denominator: number = 1;\n private _greatestCommonFactor: number = 1;\n private _textParts: string[] = [];\n\n constructor(value: number, precision: FractionalPrecision, reduce: boolean) {\n this.calculate(value, precision as number);\n this.formTextParts(reduce);\n }\n\n private calculate(value: number, denominator: number) {\n const positiveValue = Math.abs(value);\n this._denominator = denominator;\n this._integral = Math.floor(positiveValue);\n const fractionPart = positiveValue - this._integral;\n this._numerator = Math.floor(fractionPart * this._denominator + FPV_ROUNDFACTOR);\n\n if (0 !== denominator && (this._numerator / this._denominator) === 1) {\n this._numerator = 0;\n this._integral += 1;\n } else {\n this._greatestCommonFactor = this.getGreatestCommonFactor(this._numerator, this._denominator);\n }\n }\n\n /** Determine the GCD given two values. This value can be used to reduce a fraction.\n * See algorithm description http://en.wikipedia.org/wiki/Euclidean_algorithm\n */\n private getGreatestCommonFactor(numerator: number, denominator: number): number {\n let r;\n while (denominator !== 0) {\n r = numerator % denominator;\n numerator = denominator;\n denominator = r;\n }\n return (numerator < 0) ? -numerator : numerator;\n }\n\n public get greatestCommonFactor(): number { return this._greatestCommonFactor; }\n public get hasFractionPart(): boolean { return this._textParts.length > 0; }\n public get isZero(): boolean { return 0 === this._numerator; }\n\n public getIntegralString(): string {\n if (this._textParts.length > 0)\n return this._textParts[0];\n\n return \"\";\n }\n\n public getNumeratorString(): string {\n if (this._textParts.length >= 3)\n return this._textParts[1];\n\n return \"\";\n }\n\n public getDenominatorString(): string {\n if (this._textParts.length >= 3)\n return this._textParts[2];\n\n return \"\";\n }\n\n private formTextParts(reduce: boolean): void {\n let numerator = this._numerator;\n let denominator = this._denominator;\n\n if (reduce && this._greatestCommonFactor > 1) {\n numerator /= this.greatestCommonFactor;\n denominator /= this.greatestCommonFactor;\n }\n\n this._textParts.push(this._integral.toFixed(0));\n if (numerator > 0) {\n this._textParts.push(numerator.toFixed(0));\n this._textParts.push(denominator.toFixed(0));\n }\n }\n}\n\n/** A helper class that contains methods used to format quantity values based on a format that are defined via the Format class.\n * @beta\n */\nexport class Formatter {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private static FPV_MINTHRESHOLD = 1.0e-14;\n\n private static isNegligible(value: number): boolean { return (Math.abs(value) < Formatter.FPV_MINTHRESHOLD); }\n\n /** Return floating point value rounded by specific rounding factor.\n * @param value Value to be rounded.\n * @param roundTo Rounding factor.\n */\n private static roundDouble(value: number, roundTo: number): number {\n if (Formatter.isNegligible(roundTo))\n return value;\n\n roundTo = Math.abs(roundTo);\n let rnd = FPV_ROUNDFACTOR + (value / roundTo);\n const iVal = Math.floor(rnd);\n rnd = iVal * roundTo;\n return (value < 0.0) ? -rnd : rnd;\n }\n\n /** Generate a formatted text string integer value insert 1000 separators if appropriate.\n * @param wholePart Integer value to be formatted.\n */\n private static integerPartToText(wholePart: number, spec: FormatterSpec): string {\n // build invariant string represent wholePart\n let formattedValue = wholePart.toFixed(0);\n\n if ((formattedValue.length > 3) && (spec.format.hasFormatTraitSet(FormatTraits.Use1000Separator) && (spec.format.thousandSeparator.length > 0))) {\n let numSeparators = Math.floor(formattedValue.length / 3);\n let groupLength = formattedValue.length % 3;\n\n if (groupLength === 0) {\n numSeparators = numSeparators - 1;\n groupLength = groupLength + 3;\n }\n\n let outString = formattedValue.substr(0, groupLength);\n\n for (let i = 1; i <= numSeparators; i += 1) {\n outString = outString + spec.format.thousandSeparator + formattedValue.substr(groupLength, 3);\n groupLength = groupLength + 3;\n }\n\n formattedValue = outString;\n }\n\n return formattedValue;\n }\n\n /** Trim trailing \"0\" from the text that represent the fractional part of a floating point value.\n * @param strVal The value string.\n */\n private static trimTrailingZeroes(strVal: string): string {\n let lastNonZeroCharIndex = -1;\n for (let i = strVal.length - 1; i >= 0; i--) {\n if (strVal.charCodeAt(i) !== QuantityConstants.CHAR_DIGIT_ZERO) {\n lastNonZeroCharIndex = i;\n break;\n }\n }\n if (lastNonZeroCharIndex >= 0)\n return strVal.substr(0, lastNonZeroCharIndex + 1);\n return \"\";\n }\n\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\n * @param compositeValue The value for this part of the composite\n * @param isLastPart If false the composite value should be a whole value, if true then the value should be formatted as a floating point value.\n * @param label Label for this part of the composite. This will be either the default unit label or a custom label specified the format specification.\n */\n private static formatCompositePart(compositeValue: number, isLastPart: boolean, label: string, spec: FormatterSpec): string {\n let componentText = \"\";\n if (!isLastPart) {\n componentText = Formatter.integerPartToText(compositeValue, spec);\n } else {\n componentText = Formatter.formatMagnitude(compositeValue, spec);\n }\n\n if (spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\n componentText = componentText + spec.format.uomSeparator + label;\n } else {\n if (!isLastPart)\n componentText = `${componentText}:`;\n }\n\n return componentText;\n }\n\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\n * @param magnitude quantity value\n * @param fromUnit quantity unit\n */\n private static formatComposite(magnitude: number, spec: FormatterSpec): string {\n const compositeStrings: string[] = [];\n\n // Caller will deal with appending +||-||() value sign as specified by formatting options so just format positive value\n let posMagnitude = Math.abs(magnitude);\n\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < spec.unitConversions.length; i++) {\n const currentLabel = spec.unitConversions[i].label;\n const unitConversion = spec.unitConversions[i].conversion;\n\n if (i > 0 && unitConversion.factor < 1.0)\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification..`);\n if (i > 0 && unitConversion.offset !== 0)\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification..`);\n\n let unitValue = (posMagnitude * unitConversion.factor) + unitConversion.offset + Formatter.FPV_MINTHRESHOLD; // offset should only ever be defined for major unit\n if (0 === i) {\n const precisionScale = Math.pow(10, 8); // use a fixed round off precision of 8 to avoid loss of precision in actual magnitude\n unitValue = Math.floor(unitValue * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\n if ((Math.abs(unitValue) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\n return \"\";\n }\n\n if (i < spec.format.units!.length - 1) {\n const wholePart = Math.floor(unitValue);\n const componentText = Formatter.formatCompositePart(wholePart, false, currentLabel, spec);\n posMagnitude = unitValue - wholePart;\n compositeStrings.push(componentText);\n } else {\n const componentText = Formatter.formatCompositePart(unitValue, true, currentLabel, spec);\n compositeStrings.push(componentText);\n }\n }\n\n return compositeStrings.join(spec.format.spacer ? spec.format.spacer : \"\");\n }\n\n /** Format a quantity value into a single text string. Imitate how formatting done by server method NumericFormatSpec::FormatDouble.\n * @param magnitude quantity value\n */\n private static formatMagnitude(magnitude: number, spec: FormatterSpec): string {\n let posMagnitude = Math.abs(magnitude);\n if ((Math.abs(posMagnitude) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\n return \"\";\n\n if (spec.format.hasFormatTraitSet(FormatTraits.ApplyRounding))\n posMagnitude = Math.abs(Formatter.roundDouble(magnitude, spec.format.roundFactor));\n\n const isSci = ((posMagnitude > 1.0e12) || spec.format.type === FormatType.Scientific);\n const isDecimal = (isSci || spec.format.type === FormatType.Decimal);\n const isFractional = (!isDecimal && spec.format.type === FormatType.Fractional);\n /* const usesStops = spec.format.type === FormatType.Station; */\n const isPrecisionZero = spec.format.precision === DecimalPrecision.Zero;\n const isKeepSingleZero = spec.format.hasFormatTraitSet(FormatTraits.KeepSingleZero);\n const precisionScale = Math.pow(10.0, spec.format.precision);\n const isKeepTrailingZeroes = spec.format.hasFormatTraitSet(FormatTraits.TrailZeroes);\n let expInt = 0.0;\n\n if (isSci && (posMagnitude !== 0.0)) {\n let exp = Math.log10(posMagnitude);\n let negativeExp = false;\n if (exp < 0.0) {\n exp = -exp;\n negativeExp = true;\n }\n\n expInt = Math.floor(exp);\n if (spec.format.type === FormatType.Scientific) {\n if (spec.format.scientificType === ScientificType.ZeroNormalized && posMagnitude > 1.0)\n expInt += 1.0;\n else if (spec.format.scientificType === ScientificType.Normalized && posMagnitude < 1.0)\n expInt += 1.0;\n\n if (negativeExp)\n expInt = -expInt;\n }\n\n const factor = Math.pow(10.0, -expInt);\n posMagnitude *= factor;\n }\n\n let formattedValue = \"\";\n if (isDecimal) {\n const actualVal = isPrecisionZero ? posMagnitude + FPV_ROUNDFACTOR : posMagnitude + Formatter.FPV_MINTHRESHOLD;\n let wholePart = Math.floor(actualVal);\n let fractionPart = actualVal - wholePart;\n if (!isPrecisionZero) {\n fractionPart = Math.abs(fractionPart) * precisionScale + FPV_ROUNDFACTOR;\n if (fractionPart >= precisionScale) {\n wholePart += 1;\n fractionPart -= precisionScale;\n }\n }\n\n formattedValue = Formatter.integerPartToText(wholePart, spec);\n if (isPrecisionZero) {\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint) && !isKeepSingleZero)\n formattedValue = formattedValue + spec.format.decimalSeparator;\n else if (isKeepSingleZero)\n formattedValue = `${formattedValue + spec.format.decimalSeparator}0`;\n } else {\n fractionPart = Math.floor(fractionPart) / precisionScale;\n let fractionString = fractionPart.toFixed(spec.format.precision);\n // remove leading \"0.\"\n fractionString = fractionString.substr(2).padEnd(spec.format.precision, \"0\");\n if (!isKeepTrailingZeroes)\n fractionString = Formatter.trimTrailingZeroes(fractionString);\n\n if (fractionString.length > 0)\n formattedValue = formattedValue + spec.format.decimalSeparator + fractionString;\n else {\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\n formattedValue = formattedValue + spec.format.decimalSeparator + (isKeepSingleZero ? \"0\" : \"\");\n }\n }\n\n if (isSci) {\n const expString = `e${expInt.toFixed(0)}`;\n formattedValue = formattedValue + expString;\n }\n } else if (isFractional) {\n const fn = new FractionalNumeric(posMagnitude, spec.format.precision as FractionalPrecision, true);\n formattedValue = fn.getIntegralString();\n\n if (!fn.isZero && fn.hasFractionPart) {\n const wholeFractionSeparator = spec.format.hasFormatTraitSet(FormatTraits.FractionDash) ? \"-\" : \" \";\n const fractionString = `${fn.getNumeratorString()}/${fn.getDenominatorString()}`;\n formattedValue = formattedValue + wholeFractionSeparator + fractionString;\n }\n } else /* if (usesStops)*/ {\n // we assume that stopping value is always positive\n posMagnitude = Math.floor(posMagnitude * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\n\n const denominator = (Math.pow(10, spec.format.stationOffsetSize!));\n const tVal = Math.floor(posMagnitude); // this is the integer part only\n const hiPart = Math.floor(tVal / denominator);\n const lowPart = tVal - hiPart * denominator;\n const fract = posMagnitude - tVal;\n const fractionPart = Math.floor(fract * precisionScale + FPV_ROUNDFACTOR);\n const stationString = hiPart.toFixed(0) + spec.format.stationSeparator + lowPart.toFixed(0).padStart(spec.format.stationOffsetSize!, \"0\");\n let fractionString = \"\";\n if (fractionPart > 0) {\n fractionString = (fractionPart/precisionScale).toFixed(spec.format.precision);\n // remove leading \"0.\"\n fractionString = fractionString.substr(2).padEnd(spec.format.precision, \"0\");\n if (!isKeepTrailingZeroes)\n fractionString = Formatter.trimTrailingZeroes(fractionString);\n\n formattedValue = stationString + spec.format.decimalSeparator + fractionString;\n } else {\n if (isKeepTrailingZeroes)\n fractionString = spec.format.decimalSeparator + \"\".padEnd(spec.format.precision, \"0\");\n else if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\n fractionString = spec.format.decimalSeparator;\n formattedValue = stationString + fractionString;\n }\n }\n return formattedValue;\n }\n\n /** Format a quantity value into a single text string based on the current format specification of this class.\n * @param magnitude defines the value to spec.format.\n * @param spec A FormatterSpec object the defines specification for the magnitude and unit conversions for the formatter.\n */\n public static formatQuantity(magnitude: number, spec: FormatterSpec): string {\n const valueIsNegative = magnitude < 0.0;\n let prefix = \"\";\n let suffix = \"\";\n let formattedValue = \"\";\n switch (spec.format.showSignOption) {\n case ShowSignOption.NegativeParentheses:\n if (valueIsNegative) {\n prefix = \"(\";\n suffix = \")\";\n }\n break;\n\n case ShowSignOption.OnlyNegative:\n if (valueIsNegative)\n prefix = \"-\";\n\n break;\n\n case ShowSignOption.SignAlways:\n if (valueIsNegative)\n prefix = \"-\";\n else\n prefix = \"+\";\n\n break;\n\n case ShowSignOption.NoSign:\n default:\n break;\n }\n\n let formattedMagnitude = \"\";\n\n if (spec.format.hasUnits) {\n formattedMagnitude = Formatter.formatComposite(magnitude, spec);\n } else {\n // unitless quantity\n formattedMagnitude = Formatter.formatMagnitude(magnitude, spec);\n if (formattedMagnitude.length > 0 && spec.unitConversions.length > 0 && spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\n if (spec.format.hasFormatTraitSet(FormatTraits.PrependUnitLabel))\n formattedMagnitude = spec.unitConversions[0].label + spec.format.uomSeparator + formattedMagnitude;\n else\n formattedMagnitude = formattedMagnitude + spec.format.uomSeparator + spec.unitConversions[0].label;\n }\n }\n // add Sign prefix and suffix as necessary\n if ((prefix.length > 0 || suffix.length > 0) && formattedMagnitude.length > 0)\n formattedValue = prefix + formattedMagnitude + suffix;\n else\n formattedValue = formattedMagnitude;\n\n if (spec.format.minWidth && spec.format.minWidth < formattedValue.length)\n formattedValue.padStart(spec.format.minWidth, \" \");\n\n return formattedValue;\n }\n\n}\n"]}
1
+ {"version":3,"file":"Formatter.js","sourceRoot":"","sources":["../../../src/Formatter/Formatter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAuB,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhI;;GAEG;AACH,MAAM,eAAe,GAAG,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,iBAAiB;IAOrB,YAAY,KAAa,EAAE,SAA8B,EAAE,MAAe;QANlE,cAAS,GAAW,CAAC,CAAC;QACtB,eAAU,GAAW,CAAC,CAAC;QACvB,iBAAY,GAAW,CAAC,CAAC;QACzB,0BAAqB,GAAW,CAAC,CAAC;QAClC,eAAU,GAAa,EAAE,CAAC;QAGhC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAmB,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEO,SAAS,CAAC,KAAa,EAAE,WAAmB;QAClD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC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AI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;aACtG;SACF;QACD,0CAA0C;QAC1C,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC;YAC3E,cAAc,GAAG,MAAM,GAAG,kBAAkB,GAAG,MAAM,CAAC;;YAEtD,cAAc,GAAG,kBAAkB,CAAC;QAEtC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC,MAAM;YACtE,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAErD,OAAO,cAAc,CAAC;IACxB,CAAC;;AAzTD,gEAAgE;AACjD,0BAAgB,GAAG,OAAO,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { FormatterSpec } from \"./FormatterSpec\";\r\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"./FormatEnums\";\r\n\r\n/** rounding additive\r\n * @internal\r\n */\r\nconst FPV_ROUNDFACTOR = 0.50000000001;\r\n\r\n/** A private helper class used to format fraction part of value into a numerator and denominator.\r\n * @internal\r\n */\r\nclass FractionalNumeric {\r\n private _integral: number = 0;\r\n private _numerator: number = 0;\r\n private _denominator: number = 1;\r\n private _greatestCommonFactor: number = 1;\r\n private _textParts: string[] = [];\r\n\r\n constructor(value: number, precision: FractionalPrecision, reduce: boolean) {\r\n this.calculate(value, precision as number);\r\n this.formTextParts(reduce);\r\n }\r\n\r\n private calculate(value: number, denominator: number) {\r\n const positiveValue = Math.abs(value);\r\n this._denominator = denominator;\r\n this._integral = Math.floor(positiveValue);\r\n const fractionPart = positiveValue - this._integral;\r\n this._numerator = Math.floor(fractionPart * this._denominator + FPV_ROUNDFACTOR);\r\n\r\n if (0 !== denominator && (this._numerator / this._denominator) === 1) {\r\n this._numerator = 0;\r\n this._integral += 1;\r\n } else {\r\n this._greatestCommonFactor = this.getGreatestCommonFactor(this._numerator, this._denominator);\r\n }\r\n }\r\n\r\n /** Determine the GCD given two values. This value can be used to reduce a fraction.\r\n * See algorithm description http://en.wikipedia.org/wiki/Euclidean_algorithm\r\n */\r\n private getGreatestCommonFactor(numerator: number, denominator: number): number {\r\n let r;\r\n while (denominator !== 0) {\r\n r = numerator % denominator;\r\n numerator = denominator;\r\n denominator = r;\r\n }\r\n return (numerator < 0) ? -numerator : numerator;\r\n }\r\n\r\n public get greatestCommonFactor(): number { return this._greatestCommonFactor; }\r\n public get hasFractionPart(): boolean { return this._textParts.length > 0; }\r\n public get isZero(): boolean { return 0 === this._numerator; }\r\n\r\n public getIntegralString(): string {\r\n if (this._textParts.length > 0)\r\n return this._textParts[0];\r\n\r\n return \"\";\r\n }\r\n\r\n public getNumeratorString(): string {\r\n if (this._textParts.length >= 3)\r\n return this._textParts[1];\r\n\r\n return \"\";\r\n }\r\n\r\n public getDenominatorString(): string {\r\n if (this._textParts.length >= 3)\r\n return this._textParts[2];\r\n\r\n return \"\";\r\n }\r\n\r\n private formTextParts(reduce: boolean): void {\r\n let numerator = this._numerator;\r\n let denominator = this._denominator;\r\n\r\n if (reduce && this._greatestCommonFactor > 1) {\r\n numerator /= this.greatestCommonFactor;\r\n denominator /= this.greatestCommonFactor;\r\n }\r\n\r\n this._textParts.push(this._integral.toFixed(0));\r\n if (numerator > 0) {\r\n this._textParts.push(numerator.toFixed(0));\r\n this._textParts.push(denominator.toFixed(0));\r\n }\r\n }\r\n}\r\n\r\n/** A helper class that contains methods used to format quantity values based on a format that are defined via the Format class.\r\n * @beta\r\n */\r\nexport class Formatter {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private static FPV_MINTHRESHOLD = 1.0e-14;\r\n\r\n private static isNegligible(value: number): boolean { return (Math.abs(value) < Formatter.FPV_MINTHRESHOLD); }\r\n\r\n /** Return floating point value rounded by specific rounding factor.\r\n * @param value Value to be rounded.\r\n * @param roundTo Rounding factor.\r\n */\r\n private static roundDouble(value: number, roundTo: number): number {\r\n if (Formatter.isNegligible(roundTo))\r\n return value;\r\n\r\n roundTo = Math.abs(roundTo);\r\n let rnd = FPV_ROUNDFACTOR + (value / roundTo);\r\n const iVal = Math.floor(rnd);\r\n rnd = iVal * roundTo;\r\n return (value < 0.0) ? -rnd : rnd;\r\n }\r\n\r\n /** Generate a formatted text string integer value insert 1000 separators if appropriate.\r\n * @param wholePart Integer value to be formatted.\r\n */\r\n private static integerPartToText(wholePart: number, spec: FormatterSpec): string {\r\n // build invariant string represent wholePart\r\n let formattedValue = wholePart.toFixed(0);\r\n\r\n if ((formattedValue.length > 3) && (spec.format.hasFormatTraitSet(FormatTraits.Use1000Separator) && (spec.format.thousandSeparator.length > 0))) {\r\n let numSeparators = Math.floor(formattedValue.length / 3);\r\n let groupLength = formattedValue.length % 3;\r\n\r\n if (groupLength === 0) {\r\n numSeparators = numSeparators - 1;\r\n groupLength = groupLength + 3;\r\n }\r\n\r\n let outString = formattedValue.substr(0, groupLength);\r\n\r\n for (let i = 1; i <= numSeparators; i += 1) {\r\n outString = outString + spec.format.thousandSeparator + formattedValue.substr(groupLength, 3);\r\n groupLength = groupLength + 3;\r\n }\r\n\r\n formattedValue = outString;\r\n }\r\n\r\n return formattedValue;\r\n }\r\n\r\n /** Trim trailing \"0\" from the text that represent the fractional part of a floating point value.\r\n * @param strVal The value string.\r\n */\r\n private static trimTrailingZeroes(strVal: string): string {\r\n let lastNonZeroCharIndex = -1;\r\n for (let i = strVal.length - 1; i >= 0; i--) {\r\n if (strVal.charCodeAt(i) !== QuantityConstants.CHAR_DIGIT_ZERO) {\r\n lastNonZeroCharIndex = i;\r\n break;\r\n }\r\n }\r\n if (lastNonZeroCharIndex >= 0)\r\n return strVal.substr(0, lastNonZeroCharIndex + 1);\r\n return \"\";\r\n }\r\n\r\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\r\n * @param compositeValue The value for this part of the composite\r\n * @param isLastPart If false the composite value should be a whole value, if true then the value should be formatted as a floating point value.\r\n * @param label Label for this part of the composite. This will be either the default unit label or a custom label specified the format specification.\r\n */\r\n private static formatCompositePart(compositeValue: number, isLastPart: boolean, label: string, spec: FormatterSpec): string {\r\n let componentText = \"\";\r\n if (!isLastPart) {\r\n componentText = Formatter.integerPartToText(compositeValue, spec);\r\n } else {\r\n componentText = Formatter.formatMagnitude(compositeValue, spec);\r\n }\r\n\r\n if (spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\r\n componentText = componentText + spec.format.uomSeparator + label;\r\n } else {\r\n if (!isLastPart)\r\n componentText = `${componentText}:`;\r\n }\r\n\r\n return componentText;\r\n }\r\n\r\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\r\n * @param magnitude quantity value\r\n * @param fromUnit quantity unit\r\n */\r\n private static formatComposite(magnitude: number, spec: FormatterSpec): string {\r\n const compositeStrings: string[] = [];\r\n\r\n // Caller will deal with appending +||-||() value sign as specified by formatting options so just format positive value\r\n let posMagnitude = Math.abs(magnitude);\r\n\r\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\r\n for (let i = 0; i < spec.unitConversions.length; i++) {\r\n const currentLabel = spec.unitConversions[i].label;\r\n const unitConversion = spec.unitConversions[i].conversion;\r\n\r\n if (i > 0 && unitConversion.factor < 1.0)\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification..`);\r\n if (i > 0 && unitConversion.offset !== 0)\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification..`);\r\n\r\n let unitValue = (posMagnitude * unitConversion.factor) + unitConversion.offset + Formatter.FPV_MINTHRESHOLD; // offset should only ever be defined for major unit\r\n if (0 === i) {\r\n const precisionScale = Math.pow(10, 8); // use a fixed round off precision of 8 to avoid loss of precision in actual magnitude\r\n unitValue = Math.floor(unitValue * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\r\n if ((Math.abs(unitValue) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\r\n return \"\";\r\n }\r\n\r\n if (i < spec.format.units!.length - 1) {\r\n const wholePart = Math.floor(unitValue);\r\n const componentText = Formatter.formatCompositePart(wholePart, false, currentLabel, spec);\r\n posMagnitude = unitValue - wholePart;\r\n compositeStrings.push(componentText);\r\n } else {\r\n const componentText = Formatter.formatCompositePart(unitValue, true, currentLabel, spec);\r\n compositeStrings.push(componentText);\r\n }\r\n }\r\n\r\n return compositeStrings.join(spec.format.spacer ? spec.format.spacer : \"\");\r\n }\r\n\r\n /** Format a quantity value into a single text string. Imitate how formatting done by server method NumericFormatSpec::FormatDouble.\r\n * @param magnitude quantity value\r\n */\r\n private static formatMagnitude(magnitude: number, spec: FormatterSpec): string {\r\n let posMagnitude = Math.abs(magnitude);\r\n if ((Math.abs(posMagnitude) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\r\n return \"\";\r\n\r\n if (spec.format.hasFormatTraitSet(FormatTraits.ApplyRounding))\r\n posMagnitude = Math.abs(Formatter.roundDouble(magnitude, spec.format.roundFactor));\r\n\r\n const isSci = ((posMagnitude > 1.0e12) || spec.format.type === FormatType.Scientific);\r\n const isDecimal = (isSci || spec.format.type === FormatType.Decimal);\r\n const isFractional = (!isDecimal && spec.format.type === FormatType.Fractional);\r\n /* const usesStops = spec.format.type === FormatType.Station; */\r\n const isPrecisionZero = spec.format.precision === DecimalPrecision.Zero;\r\n const isKeepSingleZero = spec.format.hasFormatTraitSet(FormatTraits.KeepSingleZero);\r\n const precisionScale = Math.pow(10.0, spec.format.precision);\r\n const isKeepTrailingZeroes = spec.format.hasFormatTraitSet(FormatTraits.TrailZeroes);\r\n let expInt = 0.0;\r\n\r\n if (isSci && (posMagnitude !== 0.0)) {\r\n let exp = Math.log10(posMagnitude);\r\n let negativeExp = false;\r\n if (exp < 0.0) {\r\n exp = -exp;\r\n negativeExp = true;\r\n }\r\n\r\n expInt = Math.floor(exp);\r\n if (spec.format.type === FormatType.Scientific) {\r\n if (spec.format.scientificType === ScientificType.ZeroNormalized && posMagnitude > 1.0)\r\n expInt += 1.0;\r\n else if (spec.format.scientificType === ScientificType.Normalized && posMagnitude < 1.0)\r\n expInt += 1.0;\r\n\r\n if (negativeExp)\r\n expInt = -expInt;\r\n }\r\n\r\n const factor = Math.pow(10.0, -expInt);\r\n posMagnitude *= factor;\r\n }\r\n\r\n let formattedValue = \"\";\r\n if (isDecimal) {\r\n const actualVal = isPrecisionZero ? posMagnitude + FPV_ROUNDFACTOR : posMagnitude + Formatter.FPV_MINTHRESHOLD;\r\n let wholePart = Math.floor(actualVal);\r\n let fractionPart = actualVal - wholePart;\r\n if (!isPrecisionZero) {\r\n fractionPart = Math.abs(fractionPart) * precisionScale + FPV_ROUNDFACTOR;\r\n if (fractionPart >= precisionScale) {\r\n wholePart += 1;\r\n fractionPart -= precisionScale;\r\n }\r\n }\r\n\r\n formattedValue = Formatter.integerPartToText(wholePart, spec);\r\n if (isPrecisionZero) {\r\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint) && !isKeepSingleZero)\r\n formattedValue = formattedValue + spec.format.decimalSeparator;\r\n else if (isKeepSingleZero)\r\n formattedValue = `${formattedValue + spec.format.decimalSeparator}0`;\r\n } else {\r\n fractionPart = Math.floor(fractionPart) / precisionScale;\r\n let fractionString = fractionPart.toFixed(spec.format.precision);\r\n // remove leading \"0.\"\r\n fractionString = fractionString.substr(2).padEnd(spec.format.precision, \"0\");\r\n if (!isKeepTrailingZeroes)\r\n fractionString = Formatter.trimTrailingZeroes(fractionString);\r\n\r\n if (fractionString.length > 0)\r\n formattedValue = formattedValue + spec.format.decimalSeparator + fractionString;\r\n else {\r\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\r\n formattedValue = formattedValue + spec.format.decimalSeparator + (isKeepSingleZero ? \"0\" : \"\");\r\n }\r\n }\r\n\r\n if (isSci) {\r\n const expString = `e${expInt.toFixed(0)}`;\r\n formattedValue = formattedValue + expString;\r\n }\r\n } else if (isFractional) {\r\n const fn = new FractionalNumeric(posMagnitude, spec.format.precision as FractionalPrecision, true);\r\n formattedValue = fn.getIntegralString();\r\n\r\n if (!fn.isZero && fn.hasFractionPart) {\r\n const wholeFractionSeparator = spec.format.hasFormatTraitSet(FormatTraits.FractionDash) ? \"-\" : \" \";\r\n const fractionString = `${fn.getNumeratorString()}/${fn.getDenominatorString()}`;\r\n formattedValue = formattedValue + wholeFractionSeparator + fractionString;\r\n }\r\n } else /* if (usesStops)*/ {\r\n // we assume that stopping value is always positive\r\n posMagnitude = Math.floor(posMagnitude * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\r\n\r\n const denominator = (Math.pow(10, spec.format.stationOffsetSize!));\r\n const tVal = Math.floor(posMagnitude); // this is the integer part only\r\n const hiPart = Math.floor(tVal / denominator);\r\n const lowPart = tVal - hiPart * denominator;\r\n const fract = posMagnitude - tVal;\r\n const fractionPart = Math.floor(fract * precisionScale + FPV_ROUNDFACTOR);\r\n const stationString = hiPart.toFixed(0) + spec.format.stationSeparator + lowPart.toFixed(0).padStart(spec.format.stationOffsetSize!, \"0\");\r\n let fractionString = \"\";\r\n if (fractionPart > 0) {\r\n fractionString = (fractionPart/precisionScale).toFixed(spec.format.precision);\r\n // remove leading \"0.\"\r\n fractionString = fractionString.substr(2).padEnd(spec.format.precision, \"0\");\r\n if (!isKeepTrailingZeroes)\r\n fractionString = Formatter.trimTrailingZeroes(fractionString);\r\n\r\n formattedValue = stationString + spec.format.decimalSeparator + fractionString;\r\n } else {\r\n if (isKeepTrailingZeroes)\r\n fractionString = spec.format.decimalSeparator + \"\".padEnd(spec.format.precision, \"0\");\r\n else if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\r\n fractionString = spec.format.decimalSeparator;\r\n formattedValue = stationString + fractionString;\r\n }\r\n }\r\n return formattedValue;\r\n }\r\n\r\n /** Format a quantity value into a single text string based on the current format specification of this class.\r\n * @param magnitude defines the value to spec.format.\r\n * @param spec A FormatterSpec object the defines specification for the magnitude and unit conversions for the formatter.\r\n */\r\n public static formatQuantity(magnitude: number, spec: FormatterSpec): string {\r\n const valueIsNegative = magnitude < 0.0;\r\n let prefix = \"\";\r\n let suffix = \"\";\r\n let formattedValue = \"\";\r\n switch (spec.format.showSignOption) {\r\n case ShowSignOption.NegativeParentheses:\r\n if (valueIsNegative) {\r\n prefix = \"(\";\r\n suffix = \")\";\r\n }\r\n break;\r\n\r\n case ShowSignOption.OnlyNegative:\r\n if (valueIsNegative)\r\n prefix = \"-\";\r\n\r\n break;\r\n\r\n case ShowSignOption.SignAlways:\r\n if (valueIsNegative)\r\n prefix = \"-\";\r\n else\r\n prefix = \"+\";\r\n\r\n break;\r\n\r\n case ShowSignOption.NoSign:\r\n default:\r\n break;\r\n }\r\n\r\n let formattedMagnitude = \"\";\r\n\r\n if (spec.format.hasUnits) {\r\n formattedMagnitude = Formatter.formatComposite(magnitude, spec);\r\n } else {\r\n // unitless quantity\r\n formattedMagnitude = Formatter.formatMagnitude(magnitude, spec);\r\n if (formattedMagnitude.length > 0 && spec.unitConversions.length > 0 && spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\r\n if (spec.format.hasFormatTraitSet(FormatTraits.PrependUnitLabel))\r\n formattedMagnitude = spec.unitConversions[0].label + spec.format.uomSeparator + formattedMagnitude;\r\n else\r\n formattedMagnitude = formattedMagnitude + spec.format.uomSeparator + spec.unitConversions[0].label;\r\n }\r\n }\r\n // add Sign prefix and suffix as necessary\r\n if ((prefix.length > 0 || suffix.length > 0) && formattedMagnitude.length > 0)\r\n formattedValue = prefix + formattedMagnitude + suffix;\r\n else\r\n formattedValue = formattedMagnitude;\r\n\r\n if (spec.format.minWidth && spec.format.minWidth < formattedValue.length)\r\n formattedValue.padStart(spec.format.minWidth, \" \");\r\n\r\n return formattedValue;\r\n }\r\n\r\n}\r\n"]}
@@ -1,40 +1,40 @@
1
- /** @packageDocumentation
2
- * @module Quantity
3
- */
4
- import { UnitConversionSpec, UnitProps, UnitsProvider } from "../Interfaces";
5
- import { Format } from "./Format";
6
- /** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.
7
- * Once created the FormatterSpec will be able to format quantity values with synchronous calls.
8
- * @beta
9
- */
10
- export declare class FormatterSpec {
11
- protected _name: string;
12
- protected _conversions: UnitConversionSpec[];
13
- protected _format: Format;
14
- protected _persistenceUnit: UnitProps;
15
- /** Constructor
16
- * @param name The name of a format specification.
17
- * @param format Defines the output format for the quantity value.
18
- * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.
19
- * @param persistenceUnit The unit the magnitude value is input.
20
- */
21
- constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps);
22
- get name(): string;
23
- /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
24
- get unitConversions(): UnitConversionSpec[];
25
- get format(): Format;
26
- get persistenceUnit(): UnitProps;
27
- /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
28
- static getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]>;
29
- /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will
30
- * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make
31
- * async calls to lookup unit definitions.
32
- * @param name The name of a format specification.
33
- * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.
34
- * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.
35
- */
36
- static create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec>;
37
- /** Format a quantity value. */
38
- applyFormatting(magnitude: number): string;
39
- }
1
+ /** @packageDocumentation
2
+ * @module Quantity
3
+ */
4
+ import { UnitConversionSpec, UnitProps, UnitsProvider } from "../Interfaces";
5
+ import { Format } from "./Format";
6
+ /** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.
7
+ * Once created the FormatterSpec will be able to format quantity values with synchronous calls.
8
+ * @beta
9
+ */
10
+ export declare class FormatterSpec {
11
+ protected _name: string;
12
+ protected _conversions: UnitConversionSpec[];
13
+ protected _format: Format;
14
+ protected _persistenceUnit: UnitProps;
15
+ /** Constructor
16
+ * @param name The name of a format specification.
17
+ * @param format Defines the output format for the quantity value.
18
+ * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.
19
+ * @param persistenceUnit The unit the magnitude value is input.
20
+ */
21
+ constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps);
22
+ get name(): string;
23
+ /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
24
+ get unitConversions(): UnitConversionSpec[];
25
+ get format(): Format;
26
+ get persistenceUnit(): UnitProps;
27
+ /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
28
+ static getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]>;
29
+ /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will
30
+ * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make
31
+ * async calls to lookup unit definitions.
32
+ * @param name The name of a format specification.
33
+ * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.
34
+ * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.
35
+ */
36
+ static create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec>;
37
+ /** Format a quantity value. */
38
+ applyFormatting(magnitude: number): string;
39
+ }
40
40
  //# sourceMappingURL=FormatterSpec.d.ts.map
@@ -1,98 +1,98 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module Quantity
7
- */
8
- import { Formatter } from "./Formatter";
9
- // cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
10
- // cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
11
- /** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.
12
- * Once created the FormatterSpec will be able to format quantity values with synchronous calls.
13
- * @beta
14
- */
15
- export class FormatterSpec {
16
- /** Constructor
17
- * @param name The name of a format specification.
18
- * @param format Defines the output format for the quantity value.
19
- * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.
20
- * @param persistenceUnit The unit the magnitude value is input.
21
- */
22
- constructor(name, format, conversions, persistenceUnit) {
23
- this._conversions = []; // max four entries
24
- if (!persistenceUnit) {
25
- if (format.units) {
26
- const [props] = format.units[0];
27
- persistenceUnit = props;
28
- }
29
- else {
30
- throw new Error("Formatter Spec needs persistence unit to be specified");
31
- }
32
- }
33
- this._name = name;
34
- this._format = format;
35
- this._persistenceUnit = persistenceUnit;
36
- if (conversions)
37
- this._conversions = conversions;
38
- }
39
- get name() { return this._name; }
40
- /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
41
- get unitConversions() { return this._conversions; }
42
- get format() { return this._format; }
43
- get persistenceUnit() { return this._persistenceUnit; }
44
- /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
45
- static async getUnitConversions(format, unitsProvider, inputUnit) {
46
- const conversions = [];
47
- let persistenceUnit = inputUnit;
48
- if (!persistenceUnit) {
49
- if (format.units) {
50
- const [props] = format.units[0];
51
- persistenceUnit = props;
52
- }
53
- else {
54
- throw new Error("Formatter Spec needs persistence unit to be specified");
55
- }
56
- }
57
- if (format.units) {
58
- let convertFromUnit = inputUnit;
59
- for (const unit of format.units) {
60
- let unitConversion;
61
- if (convertFromUnit) {
62
- unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
63
- }
64
- else {
65
- unitConversion = { factor: 1.0, offset: 0.0 };
66
- }
67
- const unitLabel = (unit[1] && unit[1].length > 0) ? unit[1] : unit[0].label;
68
- const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system });
69
- conversions.push(spec);
70
- convertFromUnit = unit[0];
71
- }
72
- }
73
- else {
74
- // if format is only numeric and a input unit is defined set spec to use the input unit as the format unit
75
- if (inputUnit) {
76
- const spec = { name: inputUnit.name, label: inputUnit.label, system: inputUnit.system, conversion: { factor: 1.0, offset: 0.0 } };
77
- conversions.push(spec);
78
- }
79
- }
80
- return conversions;
81
- }
82
- /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will
83
- * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make
84
- * async calls to lookup unit definitions.
85
- * @param name The name of a format specification.
86
- * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.
87
- * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.
88
- */
89
- static async create(name, format, unitsProvider, inputUnit) {
90
- const conversions = await FormatterSpec.getUnitConversions(format, unitsProvider, inputUnit);
91
- return new FormatterSpec(name, format, conversions, inputUnit);
92
- }
93
- /** Format a quantity value. */
94
- applyFormatting(magnitude) {
95
- return Formatter.formatQuantity(magnitude, this);
96
- }
97
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Quantity
7
+ */
8
+ import { Formatter } from "./Formatter";
9
+ // cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
10
+ // cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
11
+ /** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.
12
+ * Once created the FormatterSpec will be able to format quantity values with synchronous calls.
13
+ * @beta
14
+ */
15
+ export class FormatterSpec {
16
+ /** Constructor
17
+ * @param name The name of a format specification.
18
+ * @param format Defines the output format for the quantity value.
19
+ * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.
20
+ * @param persistenceUnit The unit the magnitude value is input.
21
+ */
22
+ constructor(name, format, conversions, persistenceUnit) {
23
+ this._conversions = []; // max four entries
24
+ if (!persistenceUnit) {
25
+ if (format.units) {
26
+ const [props] = format.units[0];
27
+ persistenceUnit = props;
28
+ }
29
+ else {
30
+ throw new Error("Formatter Spec needs persistence unit to be specified");
31
+ }
32
+ }
33
+ this._name = name;
34
+ this._format = format;
35
+ this._persistenceUnit = persistenceUnit;
36
+ if (conversions)
37
+ this._conversions = conversions;
38
+ }
39
+ get name() { return this._name; }
40
+ /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
41
+ get unitConversions() { return this._conversions; }
42
+ get format() { return this._format; }
43
+ get persistenceUnit() { return this._persistenceUnit; }
44
+ /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
45
+ static async getUnitConversions(format, unitsProvider, inputUnit) {
46
+ const conversions = [];
47
+ let persistenceUnit = inputUnit;
48
+ if (!persistenceUnit) {
49
+ if (format.units) {
50
+ const [props] = format.units[0];
51
+ persistenceUnit = props;
52
+ }
53
+ else {
54
+ throw new Error("Formatter Spec needs persistence unit to be specified");
55
+ }
56
+ }
57
+ if (format.units) {
58
+ let convertFromUnit = inputUnit;
59
+ for (const unit of format.units) {
60
+ let unitConversion;
61
+ if (convertFromUnit) {
62
+ unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
63
+ }
64
+ else {
65
+ unitConversion = { factor: 1.0, offset: 0.0 };
66
+ }
67
+ const unitLabel = (unit[1] && unit[1].length > 0) ? unit[1] : unit[0].label;
68
+ const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system });
69
+ conversions.push(spec);
70
+ convertFromUnit = unit[0];
71
+ }
72
+ }
73
+ else {
74
+ // if format is only numeric and a input unit is defined set spec to use the input unit as the format unit
75
+ if (inputUnit) {
76
+ const spec = { name: inputUnit.name, label: inputUnit.label, system: inputUnit.system, conversion: { factor: 1.0, offset: 0.0 } };
77
+ conversions.push(spec);
78
+ }
79
+ }
80
+ return conversions;
81
+ }
82
+ /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will
83
+ * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make
84
+ * async calls to lookup unit definitions.
85
+ * @param name The name of a format specification.
86
+ * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.
87
+ * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.
88
+ */
89
+ static async create(name, format, unitsProvider, inputUnit) {
90
+ const conversions = await FormatterSpec.getUnitConversions(format, unitsProvider, inputUnit);
91
+ return new FormatterSpec(name, format, conversions, inputUnit);
92
+ }
93
+ /** Format a quantity value. */
94
+ applyFormatting(magnitude) {
95
+ return Formatter.formatQuantity(magnitude, this);
96
+ }
97
+ }
98
98
  //# sourceMappingURL=FormatterSpec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormatterSpec.js","sourceRoot":"","sources":["../../../src/Formatter/FormatterSpec.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC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AM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBACtJ,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACxB;SACF;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,MAAc,EAAE,aAA4B,EAAE,SAAqB;QAC1G,MAAM,WAAW,GAAyB,MAAM,aAAa,CAAC,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;QACnH,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,+BAA+B;IACxB,eAAe,CAAC,SAAiB;QACtC,OAAO,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { UnitConversion, UnitConversionSpec, UnitProps, UnitsProvider } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { Formatter } from \"./Formatter\";\n\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\n\n/** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.\n * Once created the FormatterSpec will be able to format quantity values with synchronous calls.\n * @beta\n */\nexport class FormatterSpec {\n protected _name: string;\n protected _conversions: UnitConversionSpec[] = []; // max four entries\n protected _format: Format;\n protected _persistenceUnit: UnitProps;\n\n /** Constructor\n * @param name The name of a format specification.\n * @param format Defines the output format for the quantity value.\n * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.\n * @param persistenceUnit The unit the magnitude value is input.\n */\n constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps) {\n if (!persistenceUnit) {\n if (format.units) {\n const [props] = format.units[0];\n persistenceUnit = props;\n } else {\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\n }\n }\n\n this._name = name;\n this._format = format;\n this._persistenceUnit = persistenceUnit;\n if (conversions)\n this._conversions = conversions;\n }\n\n public get name(): string { return this._name; }\n /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\n public get unitConversions(): UnitConversionSpec[] { return this._conversions; }\n public get format(): Format { return this._format; }\n public get persistenceUnit(): UnitProps { return this._persistenceUnit; }\n\n /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\n public static async getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]> {\n const conversions: UnitConversionSpec[] = [];\n let persistenceUnit = inputUnit;\n if (!persistenceUnit) {\n if (format.units) {\n const [props] = format.units[0];\n persistenceUnit = props;\n } else {\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\n }\n }\n\n if (format.units) {\n let convertFromUnit = inputUnit;\n for (const unit of format.units) {\n let unitConversion: UnitConversion;\n if (convertFromUnit) {\n unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);\n } else {\n unitConversion = { factor: 1.0, offset: 0.0 };\n }\n const unitLabel = (unit[1] && unit[1]!.length > 0) ? unit[1]! : unit[0].label;\n const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system }) as UnitConversionSpec;\n\n conversions.push(spec);\n convertFromUnit = unit[0];\n }\n } else {\n // if format is only numeric and a input unit is defined set spec to use the input unit as the format unit\n if (inputUnit) {\n const spec: UnitConversionSpec = { name: inputUnit.name, label: inputUnit.label, system: inputUnit.system, conversion: { factor: 1.0, offset: 0.0 } };\n conversions.push(spec);\n }\n }\n\n return conversions;\n }\n\n /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will\n * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make\n * async calls to lookup unit definitions.\n * @param name The name of a format specification.\n * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.\n * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.\n */\n public static async create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec> {\n const conversions: UnitConversionSpec[] = await FormatterSpec.getUnitConversions(format, unitsProvider, inputUnit);\n return new FormatterSpec(name, format, conversions, inputUnit);\n }\n\n /** Format a quantity value. */\n public applyFormatting(magnitude: number): string {\n return Formatter.formatQuantity(magnitude, this);\n }\n}\n"]}
1
+ {"version":3,"file":"FormatterSpec.js","sourceRoot":"","sources":["../../../src/Formatter/FormatterSpec.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,sFAAsF;AACtF,6JAA6J;AAE7J;;;GAGG;AACH,MAAM,OAAO,aAAa;IAMxB;;;;;OAKG;IACH,YAAY,IAAY,EAAE,MAAc,EAAE,WAAkC,EAAE,eAA2B;QAV/F,iBAAY,GAAyB,EAAE,CAAC,CAAE,mBAAmB;QAWrE,IAAI,CAAC,eAAe,EAAE;YACpB,IAAI,MAAM,CAAC,KAAK,EAAE;gBAChB,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChC,eAAe,GAAG,KAAK,CAAC;aACzB;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;aAC1E;SACF;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,eAAe,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AAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { UnitConversion, UnitConversionSpec, UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport { Format } from \"./Format\";\r\nimport { Formatter } from \"./Formatter\";\r\n\r\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\r\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\r\n\r\n/** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.\r\n * Once created the FormatterSpec will be able to format quantity values with synchronous calls.\r\n * @beta\r\n */\r\nexport class FormatterSpec {\r\n protected _name: string;\r\n protected _conversions: UnitConversionSpec[] = []; // max four entries\r\n protected _format: Format;\r\n protected _persistenceUnit: UnitProps;\r\n\r\n /** Constructor\r\n * @param name The name of a format specification.\r\n * @param format Defines the output format for the quantity value.\r\n * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.\r\n * @param persistenceUnit The unit the magnitude value is input.\r\n */\r\n constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps) {\r\n if (!persistenceUnit) {\r\n if (format.units) {\r\n const [props] = format.units[0];\r\n persistenceUnit = props;\r\n } else {\r\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\r\n }\r\n }\r\n\r\n this._name = name;\r\n this._format = format;\r\n this._persistenceUnit = persistenceUnit;\r\n if (conversions)\r\n this._conversions = conversions;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\r\n public get unitConversions(): UnitConversionSpec[] { return this._conversions; }\r\n public get format(): Format { return this._format; }\r\n public get persistenceUnit(): UnitProps { return this._persistenceUnit; }\r\n\r\n /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\r\n public static async getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]> {\r\n const conversions: UnitConversionSpec[] = [];\r\n let persistenceUnit = inputUnit;\r\n if (!persistenceUnit) {\r\n if (format.units) {\r\n const [props] = format.units[0];\r\n persistenceUnit = props;\r\n } else {\r\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\r\n }\r\n }\r\n\r\n if (format.units) {\r\n let convertFromUnit = inputUnit;\r\n for (const unit of format.units) {\r\n let unitConversion: UnitConversion;\r\n if (convertFromUnit) {\r\n unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);\r\n } else {\r\n unitConversion = { factor: 1.0, offset: 0.0 };\r\n }\r\n const unitLabel = (unit[1] && unit[1]!.length > 0) ? unit[1]! : unit[0].label;\r\n const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system }) as UnitConversionSpec;\r\n\r\n conversions.push(spec);\r\n convertFromUnit = unit[0];\r\n }\r\n } else {\r\n // if format is only numeric and a input unit is defined set spec to use the input unit as the format unit\r\n if (inputUnit) {\r\n const spec: UnitConversionSpec = { name: inputUnit.name, label: inputUnit.label, system: inputUnit.system, conversion: { factor: 1.0, offset: 0.0 } };\r\n conversions.push(spec);\r\n }\r\n }\r\n\r\n return conversions;\r\n }\r\n\r\n /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will\r\n * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make\r\n * async calls to lookup unit definitions.\r\n * @param name The name of a format specification.\r\n * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.\r\n * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.\r\n */\r\n public static async create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec> {\r\n const conversions: UnitConversionSpec[] = await FormatterSpec.getUnitConversions(format, unitsProvider, inputUnit);\r\n return new FormatterSpec(name, format, conversions, inputUnit);\r\n }\r\n\r\n /** Format a quantity value. */\r\n public applyFormatting(magnitude: number): string {\r\n return Formatter.formatQuantity(magnitude, this);\r\n }\r\n}\r\n"]}
@@ -1,63 +1,63 @@
1
- /** @packageDocumentation
2
- * @module Quantity
3
- */
4
- import { UnitProps } from "../Interfaces";
5
- import { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision } from "./FormatEnums";
6
- /** This interface defines the persistence format for describing the formatting of quantity values.
7
- * @beta
8
- */
9
- export interface FormatProps {
10
- readonly type: string;
11
- readonly precision?: number;
12
- readonly roundFactor?: number;
13
- readonly minWidth?: number;
14
- readonly showSignOption?: string;
15
- readonly formatTraits?: string | string[];
16
- readonly decimalSeparator?: string;
17
- readonly thousandSeparator?: string;
18
- readonly uomSeparator?: string;
19
- readonly scientificType?: string;
20
- readonly stationOffsetSize?: number;
21
- readonly stationSeparator?: string;
22
- readonly composite?: {
23
- readonly spacer?: string;
24
- readonly includeZero?: boolean;
25
- readonly units: Array<{
26
- readonly name: string;
27
- readonly label?: string;
28
- }>;
29
- };
30
- }
31
- /** This interface is used when supporting Custom Formatters that need more than the standard set of properties.
32
- * @beta
33
- */
34
- export interface CustomFormatProps extends FormatProps {
35
- readonly custom: any;
36
- }
37
- /** CustomFormatProps type guard.
38
- * @beta
39
- */
40
- export declare const isCustomFormatProps: (item: FormatProps) => item is CustomFormatProps;
41
- /** CloneFormat defines unit and label specification if primary unit is to be set during clone.
42
- * @beta
43
- */
44
- export interface CloneUnit {
45
- unit?: UnitProps;
46
- label?: string;
47
- }
48
- /** CloneOptions that define modifications that can be made during the cloning of a Format.
49
- * @beta
50
- */
51
- export interface CloneOptions {
52
- /** allows composite formats to be converted to only show primary unit */
53
- showOnlyPrimaryUnit?: boolean;
54
- /** allow format traits to be set */
55
- traits?: FormatTraits;
56
- /** allows new FormatType to be specified */
57
- type?: FormatType;
58
- /** allows precision to be set, this will throw if value is not valid for FormatType */
59
- precision?: DecimalPrecision | FractionalPrecision;
60
- /** allows primary unit and label to be specified */
61
- primaryUnit?: CloneUnit;
62
- }
1
+ /** @packageDocumentation
2
+ * @module Quantity
3
+ */
4
+ import { UnitProps } from "../Interfaces";
5
+ import { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision } from "./FormatEnums";
6
+ /** This interface defines the persistence format for describing the formatting of quantity values.
7
+ * @beta
8
+ */
9
+ export interface FormatProps {
10
+ readonly type: string;
11
+ readonly precision?: number;
12
+ readonly roundFactor?: number;
13
+ readonly minWidth?: number;
14
+ readonly showSignOption?: string;
15
+ readonly formatTraits?: string | string[];
16
+ readonly decimalSeparator?: string;
17
+ readonly thousandSeparator?: string;
18
+ readonly uomSeparator?: string;
19
+ readonly scientificType?: string;
20
+ readonly stationOffsetSize?: number;
21
+ readonly stationSeparator?: string;
22
+ readonly composite?: {
23
+ readonly spacer?: string;
24
+ readonly includeZero?: boolean;
25
+ readonly units: Array<{
26
+ readonly name: string;
27
+ readonly label?: string;
28
+ }>;
29
+ };
30
+ }
31
+ /** This interface is used when supporting Custom Formatters that need more than the standard set of properties.
32
+ * @beta
33
+ */
34
+ export interface CustomFormatProps extends FormatProps {
35
+ readonly custom: any;
36
+ }
37
+ /** CustomFormatProps type guard.
38
+ * @beta
39
+ */
40
+ export declare const isCustomFormatProps: (item: FormatProps) => item is CustomFormatProps;
41
+ /** CloneFormat defines unit and label specification if primary unit is to be set during clone.
42
+ * @beta
43
+ */
44
+ export interface CloneUnit {
45
+ unit?: UnitProps;
46
+ label?: string;
47
+ }
48
+ /** CloneOptions that define modifications that can be made during the cloning of a Format.
49
+ * @beta
50
+ */
51
+ export interface CloneOptions {
52
+ /** allows composite formats to be converted to only show primary unit */
53
+ showOnlyPrimaryUnit?: boolean;
54
+ /** allow format traits to be set */
55
+ traits?: FormatTraits;
56
+ /** allows new FormatType to be specified */
57
+ type?: FormatType;
58
+ /** allows precision to be set, this will throw if value is not valid for FormatType */
59
+ precision?: DecimalPrecision | FractionalPrecision;
60
+ /** allows primary unit and label to be specified */
61
+ primaryUnit?: CloneUnit;
62
+ }
63
63
  //# sourceMappingURL=Interfaces.d.ts.map