@itwin/core-quantity 3.0.0-dev.83 → 3.0.0-dev.87
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.
- package/CHANGELOG.md +823 -823
- package/LICENSE.md +9 -9
- package/README.md +11 -11
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Formatter/Format.js.map +1 -1
- package/lib/cjs/Formatter/FormatEnums.js.map +1 -1
- package/lib/cjs/Formatter/Formatter.js.map +1 -1
- package/lib/cjs/Formatter/FormatterSpec.js.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Quantity.js.map +1 -1
- package/lib/cjs/Unit.js.map +1 -1
- package/lib/cjs/core-quantity.js.map +1 -1
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Formatter/Format.js.map +1 -1
- package/lib/esm/Formatter/FormatEnums.js.map +1 -1
- package/lib/esm/Formatter/Formatter.js.map +1 -1
- package/lib/esm/Formatter/FormatterSpec.js.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Quantity.js.map +1 -1
- package/lib/esm/Unit.js.map +1 -1
- package/lib/esm/core-quantity.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","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\n/** This interface provides basic information about a Unit that is return from a UnitProvider. This info\n * uniquely identifies a unit by its name.\n * @beta\n */\nexport interface UnitProps {\n /** Unique name for unit. */\n readonly name: string;\n /** Default label for unit. */\n readonly label: string;\n /** Unique name of unit phenomenon. Example phenomenon names include 'Units.LENGTH', 'Units.AREA', and 'Units.VOLUME' */\n readonly phenomenon: string;\n /** This is set to true if the Unit is known by the UnitsProvider. */\n readonly isValid: boolean;\n /** Optionally defined set of unit labels that can be used to represent the unit. This is helpful when parsing quantity value strings */\n readonly alternateLabels?: string[];\n /** Unique system name. Example \"Units.USCUSTOM\",\" Units.METRIC\", \"Units.USSURVEY\", \"Units.IMPERIAL\" */\n readonly system: string;\n}\n\n/** This interface defines the required properties of a Quantity.\n * @beta\n */\nexport interface QuantityProps {\n readonly magnitude: number;\n readonly unit: UnitProps;\n readonly isValid: boolean;\n}\n\n/** Interface that defines how to convert between a specific unit an another in synchronous formatting or parsing processing.\n * @beta\n */\nexport interface UnitConversionSpec {\n /** Unit name that was used to locate the unit by the Unit Provider */\n name: string;\n /** The default label that is used to display unit */\n label: string;\n /** Unit system name, used to when finding preferred parse unit */\n system: string;\n /** the information necessary to convert the unit to a specific display unit */\n conversion: UnitConversion;\n /** Labels that may be used to represent the unit in a string that is to be parsed. */\n parseLabels?: string[];\n}\n\n/** This interface defines the properties required to convert a quantity value from one unit to another such as from meters to feet\n * or from Celsius to Fahrenheit.\n * @beta\n */\nexport interface UnitConversion {\n factor: number;\n offset: number;\n}\n\n/** Interface that defines potential parse units that may be found in user's string input of a quantity value.\n * @beta\n */\nexport interface PotentialParseUnit {\n unitName: string;\n altLabels?: string[];\n}\n\n/** This interface is implemented by the class that is responsible for locating units by name or label and providing conversion values between units.\n * The methods to be implemented are async allowing the UnitsProvider to query the backend when necessary to look up unit definition and conversion rules.\n * @beta\n */\nexport interface UnitsProvider {\n findUnit(unitLabel: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps>;\n getUnitsByFamily(phenomenon: string): Promise<UnitProps[]>;\n findUnitByName(unitName: string): Promise<UnitProps>;\n getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversion>;\n}\n\n/**\n * Used to uniquely identify a unit system.\n * @beta\n */\nexport type UnitSystemKey = \"metric\" | \"imperial\" | \"usCustomary\" | \"usSurvey\";\n"]}
|
|
1
|
+
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","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\n/** This interface provides basic information about a Unit that is return from a UnitProvider. This info\r\n * uniquely identifies a unit by its name.\r\n * @beta\r\n */\r\nexport interface UnitProps {\r\n /** Unique name for unit. */\r\n readonly name: string;\r\n /** Default label for unit. */\r\n readonly label: string;\r\n /** Unique name of unit phenomenon. Example phenomenon names include 'Units.LENGTH', 'Units.AREA', and 'Units.VOLUME' */\r\n readonly phenomenon: string;\r\n /** This is set to true if the Unit is known by the UnitsProvider. */\r\n readonly isValid: boolean;\r\n /** Optionally defined set of unit labels that can be used to represent the unit. This is helpful when parsing quantity value strings */\r\n readonly alternateLabels?: string[];\r\n /** Unique system name. Example \"Units.USCUSTOM\",\" Units.METRIC\", \"Units.USSURVEY\", \"Units.IMPERIAL\" */\r\n readonly system: string;\r\n}\r\n\r\n/** This interface defines the required properties of a Quantity.\r\n * @beta\r\n */\r\nexport interface QuantityProps {\r\n readonly magnitude: number;\r\n readonly unit: UnitProps;\r\n readonly isValid: boolean;\r\n}\r\n\r\n/** Interface that defines how to convert between a specific unit an another in synchronous formatting or parsing processing.\r\n * @beta\r\n */\r\nexport interface UnitConversionSpec {\r\n /** Unit name that was used to locate the unit by the Unit Provider */\r\n name: string;\r\n /** The default label that is used to display unit */\r\n label: string;\r\n /** Unit system name, used to when finding preferred parse unit */\r\n system: string;\r\n /** the information necessary to convert the unit to a specific display unit */\r\n conversion: UnitConversion;\r\n /** Labels that may be used to represent the unit in a string that is to be parsed. */\r\n parseLabels?: string[];\r\n}\r\n\r\n/** This interface defines the properties required to convert a quantity value from one unit to another such as from meters to feet\r\n * or from Celsius to Fahrenheit.\r\n * @beta\r\n */\r\nexport interface UnitConversion {\r\n factor: number;\r\n offset: number;\r\n}\r\n\r\n/** Interface that defines potential parse units that may be found in user's string input of a quantity value.\r\n * @beta\r\n */\r\nexport interface PotentialParseUnit {\r\n unitName: string;\r\n altLabels?: string[];\r\n}\r\n\r\n/** This interface is implemented by the class that is responsible for locating units by name or label and providing conversion values between units.\r\n * The methods to be implemented are async allowing the UnitsProvider to query the backend when necessary to look up unit definition and conversion rules.\r\n * @beta\r\n */\r\nexport interface UnitsProvider {\r\n findUnit(unitLabel: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps>;\r\n getUnitsByFamily(phenomenon: string): Promise<UnitProps[]>;\r\n findUnitByName(unitName: string): Promise<UnitProps>;\r\n getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversion>;\r\n}\r\n\r\n/**\r\n * Used to uniquely identify a unit system.\r\n * @beta\r\n */\r\nexport type UnitSystemKey = \"metric\" | \"imperial\" | \"usCustomary\" | \"usSurvey\";\r\n"]}
|
package/lib/cjs/Quantity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quantity.js","sourceRoot":"","sources":["../../src/Quantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;;GAGG;AACH,MAAa,QAAQ;IASnB;;;OAGG;IACH,YAAmB,IAAgB,EAAE,SAAkB;QAZ7C,eAAU,GAAW,GAAG,CAAC;QAEzB,aAAQ,GAAY,KAAK,CAAC;QAWlC,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;SAC9G;QAED,IAAI,SAAS,KAAK,SAAS;YACzB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAlBD,IAAW,IAAI,KAAgB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,IAAW,OAAO,KAAc,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAkBvD;;;;OAIG;IACI,SAAS,CAAC,MAAiB,EAAE,UAA0B;QAC5D,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC;QAC9E,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;CACF;AAlCD,4BAkCC","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 { QuantityProps, UnitConversion, UnitProps } from \"./Interfaces\";\n\n/** The Quantity class is convenient container to specify both the magnitude and unit of a quantity. This class is commonly\n * returned as the result of parsing a string that represents a quantity.\n * @beta\n */\nexport class Quantity implements QuantityProps {\n protected _magnitude: number = 0.0;\n protected _unit: UnitProps;\n protected _isValid: boolean = false;\n\n public get unit(): UnitProps { return this._unit; }\n public get magnitude(): number { return this._magnitude; }\n public get isValid(): boolean { return this._isValid; }\n\n /** Constructor. The Quantity will only be set as valid if a unit is specified.\n * @param unit Defines the quantity's unit.\n * @param magnitude Defines the magnitude of the quantity.\n */\n public constructor(unit?: UnitProps, magnitude?: number) {\n if (undefined !== unit) {\n this._unit = unit;\n this._isValid = true;\n } else {\n this._unit = { name: \"unknown\", label: \"unknown\", phenomenon: \"unknown\", isValid: false, system: \"unknown\" };\n }\n\n if (undefined !== magnitude)\n this._magnitude = magnitude;\n }\n\n /** Convert a Quantity to the specified unit given the UnitConversion.\n * @param toUnit The new unit for the quantity.\n * @param conversion Defines the information needed to convert the Quantity's magnitude from the current unit to another unit. This conversion info is usually\n * returned from the UnitsProvider.\n */\n public convertTo(toUnit: UnitProps, conversion: UnitConversion): Quantity | undefined {\n const newMagnitude = (this.magnitude * conversion.factor) + conversion.offset;\n return new Quantity(toUnit, newMagnitude);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Quantity.js","sourceRoot":"","sources":["../../src/Quantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;;GAGG;AACH,MAAa,QAAQ;IASnB;;;OAGG;IACH,YAAmB,IAAgB,EAAE,SAAkB;QAZ7C,eAAU,GAAW,GAAG,CAAC;QAEzB,aAAQ,GAAY,KAAK,CAAC;QAWlC,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;SAC9G;QAED,IAAI,SAAS,KAAK,SAAS;YACzB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAlBD,IAAW,IAAI,KAAgB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,IAAW,OAAO,KAAc,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAkBvD;;;;OAIG;IACI,SAAS,CAAC,MAAiB,EAAE,UAA0B;QAC5D,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC;QAC9E,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;CACF;AAlCD,4BAkCC","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 { QuantityProps, UnitConversion, UnitProps } from \"./Interfaces\";\r\n\r\n/** The Quantity class is convenient container to specify both the magnitude and unit of a quantity. This class is commonly\r\n * returned as the result of parsing a string that represents a quantity.\r\n * @beta\r\n */\r\nexport class Quantity implements QuantityProps {\r\n protected _magnitude: number = 0.0;\r\n protected _unit: UnitProps;\r\n protected _isValid: boolean = false;\r\n\r\n public get unit(): UnitProps { return this._unit; }\r\n public get magnitude(): number { return this._magnitude; }\r\n public get isValid(): boolean { return this._isValid; }\r\n\r\n /** Constructor. The Quantity will only be set as valid if a unit is specified.\r\n * @param unit Defines the quantity's unit.\r\n * @param magnitude Defines the magnitude of the quantity.\r\n */\r\n public constructor(unit?: UnitProps, magnitude?: number) {\r\n if (undefined !== unit) {\r\n this._unit = unit;\r\n this._isValid = true;\r\n } else {\r\n this._unit = { name: \"unknown\", label: \"unknown\", phenomenon: \"unknown\", isValid: false, system: \"unknown\" };\r\n }\r\n\r\n if (undefined !== magnitude)\r\n this._magnitude = magnitude;\r\n }\r\n\r\n /** Convert a Quantity to the specified unit given the UnitConversion.\r\n * @param toUnit The new unit for the quantity.\r\n * @param conversion Defines the information needed to convert the Quantity's magnitude from the current unit to another unit. This conversion info is usually\r\n * returned from the UnitsProvider.\r\n */\r\n public convertTo(toUnit: UnitProps, conversion: UnitConversion): Quantity | undefined {\r\n const newMagnitude = (this.magnitude * conversion.factor) + conversion.offset;\r\n return new Quantity(toUnit, newMagnitude);\r\n }\r\n}\r\n"]}
|
package/lib/cjs/Unit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unit.js","sourceRoot":"","sources":["../../src/Unit.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;GAEG;AACH,MAAa,SAAS;IAQpB,YAAY,IAAY,EAAE,KAAa,EAAE,UAAkB,EAAE,eAA0B,EAAE,MAAe;QAPjG,SAAI,GAAG,EAAE,CAAC;QACV,UAAK,GAAG,EAAE,CAAC;QACX,eAAU,GAAG,EAAE,CAAC;QAChB,YAAO,GAAG,KAAK,CAAC;QAEhB,WAAM,GAAW,SAAS,CAAC;QAGhC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;YAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;YACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,MAAM;gBACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;IACH,CAAC;CACF;AAnBD,8BAmBC;AAED;;GAEG;AACH,MAAa,OAAO;IAApB;QACS,SAAI,GAAG,EAAE,CAAC;QACV,UAAK,GAAG,EAAE,CAAC;QACX,eAAU,GAAG,EAAE,CAAC;QAChB,YAAO,GAAG,KAAK,CAAC;QAChB,WAAM,GAAG,SAAS,CAAC;IAC5B,CAAC;CAAA;AAND,0BAMC","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 { UnitProps } from \"./Interfaces\";\n\n/** This class provides basic implementation of UnitProps interface.\n * @beta\n */\nexport class BasicUnit implements UnitProps {\n public name = \"\";\n public label = \"\";\n public phenomenon = \"\";\n public isValid = false;\n public alternateLabels?: string[];\n public system: string = \"unknown\";\n\n constructor(name: string, label: string, phenomenon: string, alternateLabels?: string[], system?: string) {\n if (name && name.length > 0 && label && label.length > 0 && phenomenon && phenomenon.length > 0) {\n this.name = name;\n this.label = label;\n this.phenomenon = phenomenon;\n this.alternateLabels = alternateLabels;\n this.isValid = true;\n if (system)\n this.system = system;\n }\n }\n}\n\n/** This class is a convenience class that can be returned when a valid Unit cannot be determined.\n * @beta\n */\nexport class BadUnit implements UnitProps {\n public name = \"\";\n public label = \"\";\n public phenomenon = \"\";\n public isValid = false;\n public system = \"unknown\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Unit.js","sourceRoot":"","sources":["../../src/Unit.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;GAEG;AACH,MAAa,SAAS;IAQpB,YAAY,IAAY,EAAE,KAAa,EAAE,UAAkB,EAAE,eAA0B,EAAE,MAAe;QAPjG,SAAI,GAAG,EAAE,CAAC;QACV,UAAK,GAAG,EAAE,CAAC;QACX,eAAU,GAAG,EAAE,CAAC;QAChB,YAAO,GAAG,KAAK,CAAC;QAEhB,WAAM,GAAW,SAAS,CAAC;QAGhC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;YAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;YACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,MAAM;gBACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;IACH,CAAC;CACF;AAnBD,8BAmBC;AAED;;GAEG;AACH,MAAa,OAAO;IAApB;QACS,SAAI,GAAG,EAAE,CAAC;QACV,UAAK,GAAG,EAAE,CAAC;QACX,eAAU,GAAG,EAAE,CAAC;QAChB,YAAO,GAAG,KAAK,CAAC;QAChB,WAAM,GAAG,SAAS,CAAC;IAC5B,CAAC;CAAA;AAND,0BAMC","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 { UnitProps } from \"./Interfaces\";\r\n\r\n/** This class provides basic implementation of UnitProps interface.\r\n * @beta\r\n */\r\nexport class BasicUnit implements UnitProps {\r\n public name = \"\";\r\n public label = \"\";\r\n public phenomenon = \"\";\r\n public isValid = false;\r\n public alternateLabels?: string[];\r\n public system: string = \"unknown\";\r\n\r\n constructor(name: string, label: string, phenomenon: string, alternateLabels?: string[], system?: string) {\r\n if (name && name.length > 0 && label && label.length > 0 && phenomenon && phenomenon.length > 0) {\r\n this.name = name;\r\n this.label = label;\r\n this.phenomenon = phenomenon;\r\n this.alternateLabels = alternateLabels;\r\n this.isValid = true;\r\n if (system)\r\n this.system = system;\r\n }\r\n }\r\n}\r\n\r\n/** This class is a convenience class that can be returned when a valid Unit cannot be determined.\r\n * @beta\r\n */\r\nexport class BadUnit implements UnitProps {\r\n public name = \"\";\r\n public label = \"\";\r\n public phenomenon = \"\";\r\n public isValid = false;\r\n public system = \"unknown\";\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-quantity.js","sourceRoot":"","sources":["../../src/core-quantity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB;AACzB,+CAA6B;AAC7B,6CAA2B;AAC3B,yCAAuB;AAEvB,qDAAmC;AACnC,4DAA0C;AAC1C,0DAAwC;AACxC,wDAAsC;AACtC,yDAAuC;AAEvC;;GAEG;AAEH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./Constants\";\nexport * from \"./Exception\";\nexport * from \"./Interfaces\";\nexport * from \"./Parser\";\nexport * from \"./ParserSpec\";\nexport * from \"./Quantity\";\nexport * from \"./Unit\";\n\nexport * from \"./Formatter/Format\";\nexport * from \"./Formatter/FormatterSpec\";\nexport * from \"./Formatter/FormatEnums\";\nexport * from \"./Formatter/Formatter\";\nexport * from \"./Formatter/Interfaces\";\n\n/** @docs-package-description\n * The core-quantity package always runs in a web browser. It contains classes, interfaces, and definitions for formatting and parsing quantity values.\n */\n\n/**\n * @docs-group-description Quantity\n * Classes, Interfaces, and definitions used to format and parse quantity values.\n */\n"]}
|
|
1
|
+
{"version":3,"file":"core-quantity.js","sourceRoot":"","sources":["../../src/core-quantity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB;AACzB,+CAA6B;AAC7B,6CAA2B;AAC3B,yCAAuB;AAEvB,qDAAmC;AACnC,4DAA0C;AAC1C,0DAAwC;AACxC,wDAAsC;AACtC,yDAAuC;AAEvC;;GAEG;AAEH;;;GAGG","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\nexport * from \"./Constants\";\r\nexport * from \"./Exception\";\r\nexport * from \"./Interfaces\";\r\nexport * from \"./Parser\";\r\nexport * from \"./ParserSpec\";\r\nexport * from \"./Quantity\";\r\nexport * from \"./Unit\";\r\n\r\nexport * from \"./Formatter/Format\";\r\nexport * from \"./Formatter/FormatterSpec\";\r\nexport * from \"./Formatter/FormatEnums\";\r\nexport * from \"./Formatter/Formatter\";\r\nexport * from \"./Formatter/Interfaces\";\r\n\r\n/** @docs-package-description\r\n * The core-quantity package always runs in a web browser. It contains classes, interfaces, and definitions for formatting and parsing quantity values.\r\n */\r\n\r\n/**\r\n * @docs-group-description Quantity\r\n * Classes, Interfaces, and definitions used to format and parse quantity values.\r\n */\r\n"]}
|
package/lib/esm/Constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,yDAAyD;AAEzD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAoB5B,2DAA2D;IACpD,MAAM,KAAK,8BAA8B;QAC9C,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,MAAM,GAAG,CAAC;YACxD,OAAO,iBAAiB,CAAC,yBAAyB,CAAC;QAErD,iBAAiB,CAAC,yBAAyB,GAAG,GAAG,CAAC;QAClD,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,EAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAClE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAC/B,iBAAiB,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3D,OAAO,iBAAiB,CAAC,yBAAyB,CAAC;IACrD,CAAC;IAED,4DAA4D;IACrD,MAAM,KAAK,+BAA+B;QAC/C,IAAI,iBAAiB,CAAC,0BAA0B,CAAC,MAAM,GAAG,CAAC;YACzD,OAAO,iBAAiB,CAAC,0BAA0B,CAAC;QAEtD,iBAAiB,CAAC,0BAA0B,GAAG,GAAG,CAAC;QACnD,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,EAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAClE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAC/B,iBAAiB,CAAC,0BAA0B,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE5D,OAAO,iBAAiB,CAAC,0BAA0B,CAAC;IACtD,CAAC;;AA3CsB,4BAAU,GAAG,EAAE,CAAC;AAChB,4BAAU,GAAG,EAAE,CAAC;AAChB,6BAAW,GAAG,EAAE,CAAC;AACjB,2BAAS,GAAG,EAAE,CAAC;AACf,4BAAU,GAAG,EAAE,CAAC;AAChB,6BAAW,GAAG,EAAE,CAAC;AACjB,4BAAU,GAAG,EAAE,CAAC;AAChB,qCAAmB,GAAG,IAAI,CAAC;AAC3B,qCAAmB,GAAG,IAAI,CAAC;AAC3B,kCAAgB,GAAG,GAAG,CAAC;AACvB,+BAAa,GAAG,GAAG,CAAC;AACpB,oCAAkB,GAAG,GAAG,CAAC;AACzB,iCAAe,GAAG,EAAE,CAAC;AACrB,iCAAe,GAAG,EAAE,CAAC;AACrB,8BAAY,GAAG,EAAE,CAAC;AAClB,8BAAY,GAAG,GAAG,CAAC;AAC3B,2CAAyB,GAAG,EAAE,CAAC;AAC/B,4CAA0B,GAAG,EAAE,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\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/** Constants used internally for both formatting and parsing.\n * @internal\n */\nexport class QuantityConstants {\n public static readonly CHAR_COMMA = 44;\n public static readonly CHAR_SPACE = 32;\n public static readonly CHAR_NUMBER = 35;\n public static readonly CHAR_PLUS = 43;\n public static readonly CHAR_MINUS = 45;\n public static readonly CHAR_PERIOD = 46;\n public static readonly CHAR_SLASH = 47;\n public static readonly CHAR_DIVISION_SLASH = 8725;\n public static readonly CHAR_FRACTION_SLASH = 8260;\n public static readonly CHAR_ONE_QUARTER = 188;\n public static readonly CHAR_ONE_HALF = 189;\n public static readonly CHAR_THREE_QUARTER = 190;\n public static readonly CHAR_DIGIT_ZERO = 48;\n public static readonly CHAR_DIGIT_NINE = 57;\n public static readonly CHAR_UPPER_E = 69;\n public static readonly CHAR_LOWER_E = 101;\n private static _LOCALE_DECIMAL_SEPARATOR = \"\";\n private static _LOCALE_THOUSAND_SEPARATOR = \"\";\n\n /** Return the decimal separator for the current locale. */\n public static get LocaleSpecificDecimalSeparator(): string {\n if (QuantityConstants._LOCALE_DECIMAL_SEPARATOR.length > 0)\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\n\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = \".\";\n const matches = (12345.6789).toLocaleString()!.match(/345(.*)67/);\n if (matches && matches.length > 1)\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = matches[1];\n\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\n }\n\n /** Return the thousand separator for the current locale. */\n public static get LocaleSpecificThousandSeparator(): string {\n if (QuantityConstants._LOCALE_THOUSAND_SEPARATOR.length > 0)\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\n\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = \",\";\n const matches = (12345.6789).toLocaleString()!.match(/12(.*)345/);\n if (matches && matches.length > 0)\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];\n\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Constants.js","s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4BAAU,GAAG,EAAE,CAAC;AAChB,qCAAmB,GAAG,IAAI,CAAC;AAC3B,qCAAmB,GAAG,IAAI,CAAC;AAC3B,kCAAgB,GAAG,GAAG,CAAC;AACvB,+BAAa,GAAG,GAAG,CAAC;AACpB,oCAAkB,GAAG,GAAG,CAAC;AACzB,iCAAe,GAAG,EAAE,CAAC;AACrB,iCAAe,GAAG,EAAE,CAAC;AACrB,8BAAY,GAAG,EAAE,CAAC;AAClB,8BAAY,GAAG,GAAG,CAAC;AAC3B,2CAAyB,GAAG,EAAE,CAAC;AAC/B,4CAA0B,GAAG,EAAE,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\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/** Constants used internally for both formatting and parsing.\r\n * @internal\r\n */\r\nexport class QuantityConstants {\r\n public static readonly CHAR_COMMA = 44;\r\n public static readonly CHAR_SPACE = 32;\r\n public static readonly CHAR_NUMBER = 35;\r\n public static readonly CHAR_PLUS = 43;\r\n public static readonly CHAR_MINUS = 45;\r\n public static readonly CHAR_PERIOD = 46;\r\n public static readonly CHAR_SLASH = 47;\r\n public static readonly CHAR_DIVISION_SLASH = 8725;\r\n public static readonly CHAR_FRACTION_SLASH = 8260;\r\n public static readonly CHAR_ONE_QUARTER = 188;\r\n public static readonly CHAR_ONE_HALF = 189;\r\n public static readonly CHAR_THREE_QUARTER = 190;\r\n public static readonly CHAR_DIGIT_ZERO = 48;\r\n public static readonly CHAR_DIGIT_NINE = 57;\r\n public static readonly CHAR_UPPER_E = 69;\r\n public static readonly CHAR_LOWER_E = 101;\r\n private static _LOCALE_DECIMAL_SEPARATOR = \"\";\r\n private static _LOCALE_THOUSAND_SEPARATOR = \"\";\r\n\r\n /** Return the decimal separator for the current locale. */\r\n public static get LocaleSpecificDecimalSeparator(): string {\r\n if (QuantityConstants._LOCALE_DECIMAL_SEPARATOR.length > 0)\r\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\r\n\r\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = \".\";\r\n const matches = (12345.6789).toLocaleString()!.match(/345(.*)67/);\r\n if (matches && matches.length > 1)\r\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = matches[1];\r\n\r\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\r\n }\r\n\r\n /** Return the thousand separator for the current locale. */\r\n public static get LocaleSpecificThousandSeparator(): string {\r\n if (QuantityConstants._LOCALE_THOUSAND_SEPARATOR.length > 0)\r\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\r\n\r\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = \",\";\r\n const matches = (12345.6789).toLocaleString()!.match(/12(.*)345/);\r\n if (matches && matches.length > 0)\r\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];\r\n\r\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\r\n }\r\n}\r\n"]}
|
package/lib/esm/Exception.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB,qFAA4B,CAAA;IAC5B,yDAAW,CAAA;IACX,qEAAqC,CAAA;IACrC,2FAAgD,CAAA;IAChD,qGAAqD,CAAA;IACrD,mGAAoD,CAAA;IACpD,2GAAwD,CAAA;IACxD,qEAAqC,CAAA;IACrC,uHAA8D,CAAA;AAChE,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C,YAA4C,WAAmB,EAAE,OAAgB;QAC/E,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QADc,gBAAW,GAAX,WAAW,CAAQ;IAE/D,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 { BentleyError } from \"@itwin/core-bentley\";\n\n/**\n * Status codes used during Quantity parsing and formatting processing.\n * @beta\n */\nexport enum QuantityStatus {\n QUANTITY_ERROR_BASE = 0x88DF,\n Success = 0,\n InvalidJson = QUANTITY_ERROR_BASE + 1,\n InvalidCompositeFormat = QUANTITY_ERROR_BASE + 2,\n UnableToGenerateParseTokens = QUANTITY_ERROR_BASE + 3,\n NoValueOrUnitFoundInString = QUANTITY_ERROR_BASE + 4,\n UnitLabelSuppliedButNotMatched = QUANTITY_ERROR_BASE + 5,\n UnknownUnit = QUANTITY_ERROR_BASE + 6,\n UnableToConvertParseTokensToQuantity = QUANTITY_ERROR_BASE + 7,\n}\n\n/** The error type thrown by this module. See [[QuantityStatus]] for `errorNumber` values.\n * @beta\n */\nexport class QuantityError extends BentleyError {\n public constructor(public override readonly errorNumber: number, message?: string) {\n super(errorNumber, message);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB,qFAA4B,CAAA;IAC5B,yDAAW,CAAA;IACX,qEAAqC,CAAA;IACrC,2FAAgD,CAAA;IAChD,qGAAqD,CAAA;IACrD,mGAAoD,CAAA;IACpD,2GAAwD,CAAA;IACxD,qEAAqC,CAAA;IACrC,uHAA8D,CAAA;AAChE,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C,YAA4C,WAAmB,EAAE,OAAgB;QAC/E,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QADc,gBAAW,GAAX,WAAW,CAAQ;IAE/D,CAAC;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 { BentleyError } from \"@itwin/core-bentley\";\r\n\r\n/**\r\n * Status codes used during Quantity parsing and formatting processing.\r\n * @beta\r\n */\r\nexport enum QuantityStatus {\r\n QUANTITY_ERROR_BASE = 0x88DF,\r\n Success = 0,\r\n InvalidJson = QUANTITY_ERROR_BASE + 1,\r\n InvalidCompositeFormat = QUANTITY_ERROR_BASE + 2,\r\n UnableToGenerateParseTokens = QUANTITY_ERROR_BASE + 3,\r\n NoValueOrUnitFoundInString = QUANTITY_ERROR_BASE + 4,\r\n UnitLabelSuppliedButNotMatched = QUANTITY_ERROR_BASE + 5,\r\n UnknownUnit = QUANTITY_ERROR_BASE + 6,\r\n UnableToConvertParseTokensToQuantity = QUANTITY_ERROR_BASE + 7,\r\n}\r\n\r\n/** The error type thrown by this module. See [[QuantityStatus]] for `errorNumber` values.\r\n * @beta\r\n */\r\nexport class QuantityError extends BentleyError {\r\n public constructor(public override readonly errorNumber: number, message?: string) {\r\n super(errorNumber, message);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,E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C,IAAI,CAAC,YAAY,CAAC;YAC3D,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;YACpG,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS;SACV,CAAC;IACJ,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 { QuantityConstants } from \"../Constants\";\nimport { QuantityError, QuantityStatus } from \"../Exception\";\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"./FormatEnums\";\nimport { CloneOptions, CustomFormatProps, FormatProps, isCustomFormatProps } from \"./Interfaces\";\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 used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\n * @beta\n */\nexport class Format {\n private _name = \"\";\n protected _roundFactor: number = 0.0;\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\n protected _precision: number = DecimalPrecision.Six; // required\n protected _minWidth?: number; // optional; positive int\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\n protected _formatTraits: FormatTraits = 0x0;\n protected _spacer: string = \" \"; // optional; default is \" \"\n protected _includeZero: boolean = true; // optional; default is true\n protected _units?: Array<[UnitProps, string | undefined]>;\n protected _customProps?: any; // used by custom formatters and parsers\n\n /** Constructor\n * @param name The name of a format specification. TODO: make optional or remove\n */\n constructor(name: string) {\n this._name = name;\n }\n\n public get name(): string { return this._name; }\n public get roundFactor(): number { return this._roundFactor; }\n public get type(): FormatType { return this._type; }\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\n public get minWidth(): number | undefined { return this._minWidth; }\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\n public get decimalSeparator(): string { return this._decimalSeparator; }\n public get thousandSeparator(): string { return this._thousandSeparator; }\n public get uomSeparator(): string { return this._uomSeparator; }\n public get stationSeparator(): string { return this._stationSeparator; }\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\n public get formatTraits(): FormatTraits { return this._formatTraits; }\n public get spacer(): string { return this._spacer; }\n public get includeZero(): boolean { return this._includeZero; }\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\n public get customProps(): any { return this._customProps; }\n\n // parse and toString methods\n public static scientificTypeToString(scientificType: ScientificType): string {\n if (scientificType === ScientificType.Normalized)\n return \"Normalized\";\n else\n return \"ZeroNormalized\";\n }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ScientificType. Throws exception if not valid. */\n public static parseScientificType(scientificType: string, formatName: string): ScientificType {\n switch (scientificType.toLowerCase()) {\n case \"normalized\":\n return ScientificType.Normalized;\n case \"zeronormalized\":\n return ScientificType.ZeroNormalized;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'SCIENTIFIC_TYPE' attribute.`);\n }\n }\n\n /** Method used when generating a JSON object that represents this Format. */\n public static showSignOptionToString(showSign: ShowSignOption): string {\n switch (showSign) {\n case ShowSignOption.NegativeParentheses:\n return \"NegativeParentheses\";\n case ShowSignOption.NoSign:\n return \"NoSign\";\n case ShowSignOption.OnlyNegative:\n return \"OnlyNegative\";\n case ShowSignOption.SignAlways:\n return \"SignAlways\";\n }\n }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ShowSignOption. Throws exception if not valid. */\n public static parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\n switch (showSignOption.toLowerCase()) {\n case \"nosign\":\n return ShowSignOption.NoSign;\n case \"onlynegative\":\n return ShowSignOption.OnlyNegative;\n case \"signalways\":\n return ShowSignOption.SignAlways;\n case \"negativeparentheses\":\n return ShowSignOption.NegativeParentheses;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\n }\n }\n\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\n if (!formatProps.formatTraits)\n return false;\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\n const traitStr = Format.getTraitString(trait);\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\n }\n\n /** Get string used in FormatProps */\n public static getTraitString(trait: FormatTraits) {\n switch (trait) {\n case FormatTraits.TrailZeroes:\n return \"trailZeroes\";\n case FormatTraits.KeepSingleZero:\n return \"keepSingleZero\";\n case FormatTraits.ZeroEmpty:\n return \"zeroEmpty\";\n case FormatTraits.KeepDecimalPoint:\n return \"keepDecimalPoint\";\n case FormatTraits.ApplyRounding:\n return \"applyRounding\";\n case FormatTraits.FractionDash:\n return \"fractionDash\";\n case FormatTraits.ShowUnitLabel:\n return \"showUnitLabel\";\n case FormatTraits.PrependUnitLabel:\n return \"prependUnitLabel\";\n case FormatTraits.Use1000Separator:\n return \"use1000Separator\";\n case FormatTraits.ExponentOnlyNegative:\n default:\n return \"exponentOnlyNegative\";\n }\n }\n\n /** Method used when generating a JSON object that represents this Format. */\n public static formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\n const formatTraitsArr = Array<string>();\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes) formatTraitsArr.push(Format.getTraitString(FormatTraits.TrailZeroes));\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero) formatTraitsArr.push(Format.getTraitString(FormatTraits.KeepSingleZero));\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty) formatTraitsArr.push(Format.getTraitString(FormatTraits.ZeroEmpty));\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint) formatTraitsArr.push(Format.getTraitString(FormatTraits.KeepDecimalPoint));\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding) formatTraitsArr.push(Format.getTraitString(FormatTraits.ApplyRounding));\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash) formatTraitsArr.push(Format.getTraitString(FormatTraits.FractionDash));\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel) formatTraitsArr.push(Format.getTraitString(FormatTraits.ShowUnitLabel));\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel) formatTraitsArr.push(Format.getTraitString(FormatTraits.PrependUnitLabel));\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator) formatTraitsArr.push(Format.getTraitString(FormatTraits.Use1000Separator));\n // NOTE: the formatter does not current use trait ExponentOnlyNegative\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative) formatTraitsArr.push(Format.getTraitString(FormatTraits.ExponentOnlyNegative));\n\n return formatTraitsArr;\n }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatTrait. Throws exception if not valid. */\n public static parseFormatTrait(stringToCheck: string, currentFormatTrait: number): FormatTraits {\n switch (stringToCheck.toLowerCase()) {\n case \"trailzeroes\":\n return currentFormatTrait | FormatTraits.TrailZeroes;\n case \"keepsinglezero\":\n return currentFormatTrait | FormatTraits.KeepSingleZero; // keep single when format type is Decimal\n case \"zeroempty\":\n return currentFormatTrait | FormatTraits.ZeroEmpty;\n case \"keepdecimalpoint\":\n return currentFormatTrait | FormatTraits.KeepDecimalPoint; // add decimal point when no fractional part and format type is Decimal\n case \"applyrounding\":\n return currentFormatTrait | FormatTraits.ApplyRounding;\n case \"fractiondash\":\n return currentFormatTrait | FormatTraits.FractionDash;\n case \"showunitlabel\":\n return currentFormatTrait | FormatTraits.ShowUnitLabel;\n case \"prependunitlabel\":\n return currentFormatTrait | FormatTraits.PrependUnitLabel;\n case \"use1000separator\":\n return currentFormatTrait | FormatTraits.Use1000Separator;\n case \"exponentonlynegative\":\n return currentFormatTrait | FormatTraits.ExponentOnlyNegative;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `Format has an invalid 'formatTraits' option.`);\n }\n }\n\n /** Get FormatTrait from entry in FormatProps */\n public static parseFormatTraits(formatTraitsFromJson: string | string[] | undefined) {\n if (!formatTraitsFromJson)\n return undefined;\n\n const formatTraits = Array.isArray(formatTraitsFromJson) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\n let traits = 0;\n for (const traitStr of formatTraits) {\n traits = Format.parseFormatTrait(traitStr, traits);\n }\n if (0 === traits)\n return undefined;\n\n return traits as FormatTraits;\n }\n\n /** Method used when generating a JSON object that represents this Format. */\n public static formatTypeToString(type: FormatType): string {\n switch (type) {\n case FormatType.Decimal:\n return \"Decimal\";\n case FormatType.Scientific:\n return \"Scientific\";\n case FormatType.Station:\n return \"Station\";\n case FormatType.Fractional:\n return \"Fractional\";\n }\n }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\n public static parseFormatType(jsonObjType: string, formatName: string): FormatType {\n switch (jsonObjType.toLowerCase()) {\n case \"decimal\":\n return FormatType.Decimal;\n case \"scientific\":\n return FormatType.Scientific;\n case \"station\":\n return FormatType.Station;\n case \"fractional\":\n return FormatType.Fractional;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\n }\n }\n\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision. Throws exception if not valid. */\n public static parseDecimalPrecision(jsonObjPrecision: number): DecimalPrecision {\n switch (jsonObjPrecision) {\n case 0:\n return DecimalPrecision.Zero;\n case 1:\n return DecimalPrecision.One;\n case 2:\n return DecimalPrecision.Two;\n case 3:\n return DecimalPrecision.Three;\n case 4:\n return DecimalPrecision.Four;\n case 5:\n return DecimalPrecision.Five;\n case 6:\n return DecimalPrecision.Six;\n case 7:\n return DecimalPrecision.Seven;\n case 8:\n return DecimalPrecision.Eight;\n case 9:\n return DecimalPrecision.Nine;\n case 10:\n return DecimalPrecision.Ten;\n case 11:\n return DecimalPrecision.Eleven;\n case 12:\n return DecimalPrecision.Twelve;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The 'precision' attribute must be an integer in the range 0-12.`);\n }\n }\n\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision. Throws exception if not valid. */\n public static parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\n switch (jsonObjPrecision) {\n case 1:\n return FractionalPrecision.One;\n case 2:\n return FractionalPrecision.Two;\n case 4:\n return FractionalPrecision.Four;\n case 8:\n return FractionalPrecision.Eight;\n case 16:\n return FractionalPrecision.Sixteen;\n case 32:\n return FractionalPrecision.ThirtyTwo;\n case 64:\n return FractionalPrecision.SixtyFour;\n case 128:\n return FractionalPrecision.OneHundredTwentyEight;\n case 256:\n return FractionalPrecision.TwoHundredFiftySix;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n }\n\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. Throws exception if not valid. */\n public static parsePrecision(precision: number, formatName: string, type: FormatType): DecimalPrecision | FractionalPrecision {\n switch (type) { // type must be decimal, fractional, scientific, or station\n case FormatType.Decimal:\n case FormatType.Scientific:\n case FormatType.Station:\n return Format.parseDecimalPrecision(precision);\n case FormatType.Fractional:\n return Format.parseFractionalPrecision(precision, formatName);\n }\n }\n\n private verifyFormatTraitsOptions(formatTraitsFromJson: string | string[]) {\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\n this._formatTraits = Format.parseFormatTrait(formatTraitsString, this.formatTraits);\n });\n }\n\n /** This method returns true if the formatTrait is set in this Format object. */\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\n return (this._formatTraits & formatTrait) === formatTrait;\n }\n\n private async createUnit(unitsProvider: UnitsProvider, name: string, label?: string): Promise<void> {\n if (name === undefined || typeof (name) !== \"string\" || (label !== undefined && typeof (label) !== \"string\")) // throws if name is undefined or name isn't a string or if label is defined and isn't a string\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\n for (const unit of this.units!) {\n const unitObj = unit[0].name;\n if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\n }\n const newUnit: UnitProps = await unitsProvider.findUnitByName(name);\n if (!newUnit || !newUnit.isValid)\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\n this.units!.push([newUnit, label]);\n }\n\n /**\n * Clone Format\n */\n public clone(options?: CloneOptions): Format {\n const newFormat = new Format(this.name);\n newFormat._roundFactor = this._roundFactor;\n newFormat._type = this._type;\n newFormat._precision = this._precision;\n newFormat._minWidth = this._minWidth;\n newFormat._scientificType = this._scientificType;\n newFormat._showSignOption = this._showSignOption;\n newFormat._decimalSeparator = this._decimalSeparator;\n newFormat._thousandSeparator = this._thousandSeparator;\n newFormat._uomSeparator = this._uomSeparator;\n newFormat._stationSeparator = this._stationSeparator;\n newFormat._stationOffsetSize = this._stationOffsetSize;\n newFormat._formatTraits = this._formatTraits;\n newFormat._spacer = this._spacer;\n newFormat._includeZero = this._includeZero;\n newFormat._customProps = this._customProps;\n this._units && (newFormat._units = [...this._units]);\n\n if (newFormat._units) {\n if (options?.showOnlyPrimaryUnit) {\n if (newFormat._units.length > 1)\n newFormat._units.length = 1;\n }\n }\n\n if (undefined !== options?.traits)\n newFormat._formatTraits = options?.traits;\n\n if (undefined !== options?.type)\n newFormat._type = options.type;\n\n if (undefined !== options?.precision) {\n // ensure specified precision is valid\n const precision = Format.parsePrecision(options?.precision, \"clone\", newFormat._type);\n newFormat._precision = precision;\n }\n\n if (undefined !== options?.primaryUnit) {\n if (options.primaryUnit.unit) {\n const newUnits = new Array<[UnitProps, string | undefined]>();\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\n newFormat._units = newUnits;\n } else if (options.primaryUnit.label && newFormat._units?.length) {\n // update label only\n newFormat._units[0][1] = options.primaryUnit.label;\n }\n }\n return newFormat;\n }\n\n private loadFormatProperties(jsonObj: FormatProps) {\n if (isCustomFormatProps(jsonObj))\n this._customProps = jsonObj.custom;\n\n if (undefined === jsonObj.type) // type is required\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} does not have the required 'type' attribute.`);\n if (typeof (jsonObj.type) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'type' attribute. It should be of type 'string'.`);\n this._type = Format.parseFormatType(jsonObj.type, this.name);\n\n if (undefined === jsonObj.precision) // precision is required\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} does not have the required 'precision' attribute.`);\n else if (typeof (jsonObj.precision) !== \"number\") // must be a number\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be of type 'number'.`);\n else if (!Number.isInteger(jsonObj.precision)) // must be an integer\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\n this._precision = Format.parsePrecision(jsonObj.precision, this.name, this._type);\n\n if (this.type === FormatType.Scientific) {\n if (undefined === jsonObj.scientificType) // if format type is scientific and scientific type is undefined, throw\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has type 'Scientific' therefore attribute 'scientificType' is required.`);\n if (typeof (jsonObj.scientificType) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'scientificType' attribute. It should be of type 'string'.`);\n this._scientificType = Format.parseScientificType(jsonObj.scientificType.toLowerCase(), this.name);\n }\n\n if (this.type === FormatType.Station) {\n if (undefined === jsonObj.stationOffsetSize)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has type 'Station' therefore attribute 'stationOffsetSize' is required.`);\n if (typeof (jsonObj.stationOffsetSize) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);\n if (!Number.isInteger(jsonObj.stationOffsetSize) || jsonObj.stationOffsetSize <= 0) // must be a positive int > 0\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\n this._stationOffsetSize = jsonObj.stationOffsetSize;\n }\n\n if (undefined !== jsonObj.roundFactor) { // optional; default is 0.0\n if (typeof (jsonObj.roundFactor) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\n if (jsonObj.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\n this._roundFactor = jsonObj.roundFactor;\n }\n\n if (undefined !== jsonObj.minWidth) { // optional\n if (typeof (jsonObj.minWidth) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be of type 'number'.`);\n if (!Number.isInteger(jsonObj.minWidth) || jsonObj.minWidth < 0) // must be a positive int\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\n this._minWidth = jsonObj.minWidth;\n }\n\n if (undefined !== jsonObj.showSignOption) { // optional; default is \"onlyNegative\"\n if (typeof (jsonObj.showSignOption) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);\n this._showSignOption = Format.parseShowSignOption(jsonObj.showSignOption, this.name);\n }\n\n if (undefined !== jsonObj.formatTraits && jsonObj.formatTraits.length !== 0) { // FormatTraits is optional\n if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== \"string\") // must be either an array of strings or a string\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\n this.verifyFormatTraitsOptions(jsonObj.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\n }\n\n if (undefined !== jsonObj.decimalSeparator) { // optional\n if (typeof (jsonObj.decimalSeparator) !== \"string\") // not a string or not a one character string\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\n if (jsonObj.decimalSeparator.length !== 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It must be a one character string.`);\n this._decimalSeparator = jsonObj.decimalSeparator;\n }\n\n if (undefined !== jsonObj.thousandSeparator) { // optional\n if (typeof (jsonObj.thousandSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\n if (jsonObj.thousandSeparator.length !== 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It must be a one character string.`);\n this._thousandSeparator = jsonObj.thousandSeparator;\n }\n\n if (undefined !== jsonObj.uomSeparator) { // optional; default is \" \"\n if (typeof (jsonObj.uomSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\n if (jsonObj.uomSeparator.length < 0 || jsonObj.uomSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It must be empty or a string with a single character.`);\n this._uomSeparator = jsonObj.uomSeparator;\n }\n\n if (undefined !== jsonObj.stationSeparator) { // optional; default is \"+\"\n if (typeof (jsonObj.stationSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\n if (jsonObj.stationSeparator.length !== 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It must be a one character string.`);\n this._stationSeparator = jsonObj.stationSeparator;\n }\n }\n\n /**\n * Populates this Format with the values from the provided.\n */\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\n this.loadFormatProperties(jsonObj);\n\n if (undefined !== jsonObj.composite) { // optional\n this._units = new Array<[UnitProps, string | undefined]>();\n if (jsonObj.composite.includeZero !== undefined) {\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\n this._includeZero = jsonObj.composite.includeZero;\n }\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\n if (typeof (jsonObj.composite.spacer) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\n if (jsonObj.composite.spacer.length < 0 || jsonObj.composite.spacer.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be empty or a string with a single character.`);\n this._spacer = jsonObj.composite.spacer;\n }\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\n }\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\n try {\n const createUnitPromises: Array<Promise<void>> = [];\n for (const unit of jsonObj.composite.units) {\n createUnitPromises.push(this.createUnit(unitsProvider, unit.name, unit.label));\n }\n\n await Promise.all(createUnitPromises);\n } catch (e) {\n throw e;\n }\n }\n }\n if (undefined === this.units || this.units.length === 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\n }\n }\n\n /** Create a Format from FormatProps */\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\n const actualFormat = new Format(name);\n await actualFormat.fromJSON(unitsProvider, formatProps);\n return actualFormat;\n }\n\n /**\n * Returns a JSON object that contain the specification for this Format.\n */\n public toJSON(): FormatProps {\n let composite;\n if (this.units) {\n const units = this.units.map((value) => {\n if (undefined !== value[1])\n return { name: value[0].name, label: value[1] };\n else\n return { name: value[0].name };\n });\n\n composite = {\n spacer: this.spacer,\n includeZero: this.includeZero,\n units,\n };\n }\n\n if (this.customProps)\n return {\n type: Format.formatTypeToString(this.type),\n precision: this.precision,\n roundFactor: this.roundFactor,\n minWidth: this.minWidth,\n showSignOption: Format.showSignOptionToString(this.showSignOption),\n formatTraits: Format.formatTraitsToArray(this.formatTraits),\n decimalSeparator: this.decimalSeparator,\n thousandSeparator: this.thousandSeparator,\n uomSeparator: this.uomSeparator,\n scientificType: this.scientificType ? Format.scientificTypeToString(this.scientificType) : undefined,\n stationOffsetSize: this.stationOffsetSize,\n stationSeparator: this.stationSeparator,\n composite,\n custom: this.customProps,\n } as CustomFormatProps;\n\n return {\n type: Format.formatTypeToString(this.type),\n precision: this.precision,\n roundFactor: this.roundFactor,\n minWidth: this.minWidth,\n showSignOption: Format.showSignOptionToString(this.showSignOption),\n formatTraits: Format.formatTraitsToArray(this.formatTraits),\n decimalSeparator: this.decimalSeparator,\n thousandSeparator: this.thousandSeparator,\n uomSeparator: this.uomSeparator,\n scientificType: this.scientificType ? Format.scientificTypeToString(this.scientificType) : undefined,\n stationOffsetSize: this.stationOffsetSize,\n stationSeparator: this.stationSeparator,\n composite,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.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,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChI,OAAO,EAAgD,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjG,sFAAsF;AACtF,6JAA6J;AAE7J;;GAEG;AACH,MAAM,OAAO,MAAM;IAmBjB;;OAEG;IACH,YAAY,IAAY;QArBhB,UAAK,GAAG,EAAE,CAAC;QACT,iBAAY,GAA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vC,SAAS;SACV,CAAC;IACJ,CAAC;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 { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"./FormatEnums\";\r\nimport { CloneOptions, CustomFormatProps, FormatProps, isCustomFormatProps } from \"./Interfaces\";\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 used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n protected _formatTraits: FormatTraits = 0x0;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public get type(): FormatType { return this._type; }\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public get spacer(): string { return this._spacer; }\r\n public get includeZero(): boolean { return this._includeZero; }\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n // parse and toString methods\r\n public static scientificTypeToString(scientificType: ScientificType): string {\r\n if (scientificType === ScientificType.Normalized)\r\n return \"Normalized\";\r\n else\r\n return \"ZeroNormalized\";\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ScientificType. Throws exception if not valid. */\r\n public static parseScientificType(scientificType: string, formatName: string): ScientificType {\r\n switch (scientificType.toLowerCase()) {\r\n case \"normalized\":\r\n return ScientificType.Normalized;\r\n case \"zeronormalized\":\r\n return ScientificType.ZeroNormalized;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'SCIENTIFIC_TYPE' attribute.`);\r\n }\r\n }\r\n\r\n /** Method used when generating a JSON object that represents this Format. */\r\n public static showSignOptionToString(showSign: ShowSignOption): string {\r\n switch (showSign) {\r\n case ShowSignOption.NegativeParentheses:\r\n return \"NegativeParentheses\";\r\n case ShowSignOption.NoSign:\r\n return \"NoSign\";\r\n case ShowSignOption.OnlyNegative:\r\n return \"OnlyNegative\";\r\n case ShowSignOption.SignAlways:\r\n return \"SignAlways\";\r\n }\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ShowSignOption. Throws exception if not valid. */\r\n public static parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\r\n switch (showSignOption.toLowerCase()) {\r\n case \"nosign\":\r\n return ShowSignOption.NoSign;\r\n case \"onlynegative\":\r\n return ShowSignOption.OnlyNegative;\r\n case \"signalways\":\r\n return ShowSignOption.SignAlways;\r\n case \"negativeparentheses\":\r\n return ShowSignOption.NegativeParentheses;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\r\n }\r\n }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = Format.getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n /** Get string used in FormatProps */\r\n public static getTraitString(trait: FormatTraits) {\r\n switch (trait) {\r\n case FormatTraits.TrailZeroes:\r\n return \"trailZeroes\";\r\n case FormatTraits.KeepSingleZero:\r\n return \"keepSingleZero\";\r\n case FormatTraits.ZeroEmpty:\r\n return \"zeroEmpty\";\r\n case FormatTraits.KeepDecimalPoint:\r\n return \"keepDecimalPoint\";\r\n case FormatTraits.ApplyRounding:\r\n return \"applyRounding\";\r\n case FormatTraits.FractionDash:\r\n return \"fractionDash\";\r\n case FormatTraits.ShowUnitLabel:\r\n return \"showUnitLabel\";\r\n case FormatTraits.PrependUnitLabel:\r\n return \"prependUnitLabel\";\r\n case FormatTraits.Use1000Separator:\r\n return \"use1000Separator\";\r\n case FormatTraits.ExponentOnlyNegative:\r\n default:\r\n return \"exponentOnlyNegative\";\r\n }\r\n }\r\n\r\n /** Method used when generating a JSON object that represents this Format. */\r\n public static formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\r\n const formatTraitsArr = Array<string>();\r\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes) formatTraitsArr.push(Format.getTraitString(FormatTraits.TrailZeroes));\r\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero) formatTraitsArr.push(Format.getTraitString(FormatTraits.KeepSingleZero));\r\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty) formatTraitsArr.push(Format.getTraitString(FormatTraits.ZeroEmpty));\r\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint) formatTraitsArr.push(Format.getTraitString(FormatTraits.KeepDecimalPoint));\r\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding) formatTraitsArr.push(Format.getTraitString(FormatTraits.ApplyRounding));\r\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash) formatTraitsArr.push(Format.getTraitString(FormatTraits.FractionDash));\r\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel) formatTraitsArr.push(Format.getTraitString(FormatTraits.ShowUnitLabel));\r\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel) formatTraitsArr.push(Format.getTraitString(FormatTraits.PrependUnitLabel));\r\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator) formatTraitsArr.push(Format.getTraitString(FormatTraits.Use1000Separator));\r\n // NOTE: the formatter does not current use trait ExponentOnlyNegative\r\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative) formatTraitsArr.push(Format.getTraitString(FormatTraits.ExponentOnlyNegative));\r\n\r\n return formatTraitsArr;\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatTrait. Throws exception if not valid. */\r\n public static parseFormatTrait(stringToCheck: string, currentFormatTrait: number): FormatTraits {\r\n switch (stringToCheck.toLowerCase()) {\r\n case \"trailzeroes\":\r\n return currentFormatTrait | FormatTraits.TrailZeroes;\r\n case \"keepsinglezero\":\r\n return currentFormatTrait | FormatTraits.KeepSingleZero; // keep single when format type is Decimal\r\n case \"zeroempty\":\r\n return currentFormatTrait | FormatTraits.ZeroEmpty;\r\n case \"keepdecimalpoint\":\r\n return currentFormatTrait | FormatTraits.KeepDecimalPoint; // add decimal point when no fractional part and format type is Decimal\r\n case \"applyrounding\":\r\n return currentFormatTrait | FormatTraits.ApplyRounding;\r\n case \"fractiondash\":\r\n return currentFormatTrait | FormatTraits.FractionDash;\r\n case \"showunitlabel\":\r\n return currentFormatTrait | FormatTraits.ShowUnitLabel;\r\n case \"prependunitlabel\":\r\n return currentFormatTrait | FormatTraits.PrependUnitLabel;\r\n case \"use1000separator\":\r\n return currentFormatTrait | FormatTraits.Use1000Separator;\r\n case \"exponentonlynegative\":\r\n return currentFormatTrait | FormatTraits.ExponentOnlyNegative;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Format has an invalid 'formatTraits' option.`);\r\n }\r\n }\r\n\r\n /** Get FormatTrait from entry in FormatProps */\r\n public static parseFormatTraits(formatTraitsFromJson: string | string[] | undefined) {\r\n if (!formatTraitsFromJson)\r\n return undefined;\r\n\r\n const formatTraits = Array.isArray(formatTraitsFromJson) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n let traits = 0;\r\n for (const traitStr of formatTraits) {\r\n traits = Format.parseFormatTrait(traitStr, traits);\r\n }\r\n if (0 === traits)\r\n return undefined;\r\n\r\n return traits as FormatTraits;\r\n }\r\n\r\n /** Method used when generating a JSON object that represents this Format. */\r\n public static formatTypeToString(type: FormatType): string {\r\n switch (type) {\r\n case FormatType.Decimal:\r\n return \"Decimal\";\r\n case FormatType.Scientific:\r\n return \"Scientific\";\r\n case FormatType.Station:\r\n return \"Station\";\r\n case FormatType.Fractional:\r\n return \"Fractional\";\r\n }\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\r\n public static parseFormatType(jsonObjType: string, formatName: string): FormatType {\r\n switch (jsonObjType.toLowerCase()) {\r\n case \"decimal\":\r\n return FormatType.Decimal;\r\n case \"scientific\":\r\n return FormatType.Scientific;\r\n case \"station\":\r\n return FormatType.Station;\r\n case \"fractional\":\r\n return FormatType.Fractional;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\r\n }\r\n }\r\n\r\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision. Throws exception if not valid. */\r\n public static parseDecimalPrecision(jsonObjPrecision: number): DecimalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 0:\r\n return DecimalPrecision.Zero;\r\n case 1:\r\n return DecimalPrecision.One;\r\n case 2:\r\n return DecimalPrecision.Two;\r\n case 3:\r\n return DecimalPrecision.Three;\r\n case 4:\r\n return DecimalPrecision.Four;\r\n case 5:\r\n return DecimalPrecision.Five;\r\n case 6:\r\n return DecimalPrecision.Six;\r\n case 7:\r\n return DecimalPrecision.Seven;\r\n case 8:\r\n return DecimalPrecision.Eight;\r\n case 9:\r\n return DecimalPrecision.Nine;\r\n case 10:\r\n return DecimalPrecision.Ten;\r\n case 11:\r\n return DecimalPrecision.Eleven;\r\n case 12:\r\n return DecimalPrecision.Twelve;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The 'precision' attribute must be an integer in the range 0-12.`);\r\n }\r\n }\r\n\r\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision. Throws exception if not valid. */\r\n public static parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 1:\r\n return FractionalPrecision.One;\r\n case 2:\r\n return FractionalPrecision.Two;\r\n case 4:\r\n return FractionalPrecision.Four;\r\n case 8:\r\n return FractionalPrecision.Eight;\r\n case 16:\r\n return FractionalPrecision.Sixteen;\r\n case 32:\r\n return FractionalPrecision.ThirtyTwo;\r\n case 64:\r\n return FractionalPrecision.SixtyFour;\r\n case 128:\r\n return FractionalPrecision.OneHundredTwentyEight;\r\n case 256:\r\n return FractionalPrecision.TwoHundredFiftySix;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n }\r\n\r\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. Throws exception if not valid. */\r\n public static parsePrecision(precision: number, formatName: string, type: FormatType): DecimalPrecision | FractionalPrecision {\r\n switch (type) { // type must be decimal, fractional, scientific, or station\r\n case FormatType.Decimal:\r\n case FormatType.Scientific:\r\n case FormatType.Station:\r\n return Format.parseDecimalPrecision(precision);\r\n case FormatType.Fractional:\r\n return Format.parseFractionalPrecision(precision, formatName);\r\n }\r\n }\r\n\r\n private verifyFormatTraitsOptions(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n this._formatTraits = Format.parseFormatTrait(formatTraitsString, this.formatTraits);\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n private async createUnit(unitsProvider: UnitsProvider, name: string, label?: string): Promise<void> {\r\n if (name === undefined || typeof (name) !== \"string\" || (label !== undefined && typeof (label) !== \"string\")) // throws if name is undefined or name isn't a string or if label is defined and isn't a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n for (const unit of this.units!) {\r\n const unitObj = unit[0].name;\r\n if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\r\n }\r\n const newUnit: UnitProps = await unitsProvider.findUnitByName(name);\r\n if (!newUnit || !newUnit.isValid)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n this.units!.push([newUnit, label]);\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = Format.parsePrecision(options?.precision, \"clone\", newFormat._type);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n private loadFormatProperties(jsonObj: FormatProps) {\r\n if (isCustomFormatProps(jsonObj))\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined === jsonObj.type) // type is required\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} does not have the required 'type' attribute.`);\r\n if (typeof (jsonObj.type) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'type' attribute. It should be of type 'string'.`);\r\n this._type = Format.parseFormatType(jsonObj.type, this.name);\r\n\r\n if (undefined === jsonObj.precision) // precision is required\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} does not have the required 'precision' attribute.`);\r\n else if (typeof (jsonObj.precision) !== \"number\") // must be a number\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be of type 'number'.`);\r\n else if (!Number.isInteger(jsonObj.precision)) // must be an integer\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n this._precision = Format.parsePrecision(jsonObj.precision, this.name, this._type);\r\n\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === jsonObj.scientificType) // if format type is scientific and scientific type is undefined, throw\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has type 'Scientific' therefore attribute 'scientificType' is required.`);\r\n if (typeof (jsonObj.scientificType) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'scientificType' attribute. It should be of type 'string'.`);\r\n this._scientificType = Format.parseScientificType(jsonObj.scientificType.toLowerCase(), this.name);\r\n }\r\n\r\n if (this.type === FormatType.Station) {\r\n if (undefined === jsonObj.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has type 'Station' therefore attribute 'stationOffsetSize' is required.`);\r\n if (typeof (jsonObj.stationOffsetSize) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);\r\n if (!Number.isInteger(jsonObj.stationOffsetSize) || jsonObj.stationOffsetSize <= 0) // must be a positive int > 0\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = jsonObj.stationOffsetSize;\r\n }\r\n\r\n if (undefined !== jsonObj.roundFactor) { // optional; default is 0.0\r\n if (typeof (jsonObj.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (jsonObj.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = jsonObj.roundFactor;\r\n }\r\n\r\n if (undefined !== jsonObj.minWidth) { // optional\r\n if (typeof (jsonObj.minWidth) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be of type 'number'.`);\r\n if (!Number.isInteger(jsonObj.minWidth) || jsonObj.minWidth < 0) // must be a positive int\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = jsonObj.minWidth;\r\n }\r\n\r\n if (undefined !== jsonObj.showSignOption) { // optional; default is \"onlyNegative\"\r\n if (typeof (jsonObj.showSignOption) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);\r\n this._showSignOption = Format.parseShowSignOption(jsonObj.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== jsonObj.formatTraits && jsonObj.formatTraits.length !== 0) { // FormatTraits is optional\r\n if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== \"string\") // must be either an array of strings or a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.verifyFormatTraitsOptions(jsonObj.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\r\n }\r\n\r\n if (undefined !== jsonObj.decimalSeparator) { // optional\r\n if (typeof (jsonObj.decimalSeparator) !== \"string\") // not a string or not a one character string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.decimalSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It must be a one character string.`);\r\n this._decimalSeparator = jsonObj.decimalSeparator;\r\n }\r\n\r\n if (undefined !== jsonObj.thousandSeparator) { // optional\r\n if (typeof (jsonObj.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.thousandSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It must be a one character string.`);\r\n this._thousandSeparator = jsonObj.thousandSeparator;\r\n }\r\n\r\n if (undefined !== jsonObj.uomSeparator) { // optional; default is \" \"\r\n if (typeof (jsonObj.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.uomSeparator.length < 0 || jsonObj.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It must be empty or a string with a single character.`);\r\n this._uomSeparator = jsonObj.uomSeparator;\r\n }\r\n\r\n if (undefined !== jsonObj.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (jsonObj.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.stationSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It must be a one character string.`);\r\n this._stationSeparator = jsonObj.stationSeparator;\r\n }\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n this.loadFormatProperties(jsonObj);\r\n\r\n if (undefined !== jsonObj.composite) { // optional\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length < 0 || jsonObj.composite.spacer.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be empty or a string with a single character.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\r\n try {\r\n const createUnitPromises: Array<Promise<void>> = [];\r\n for (const unit of jsonObj.composite.units) {\r\n createUnitPromises.push(this.createUnit(unitsProvider, unit.name, unit.label));\r\n }\r\n\r\n await Promise.all(createUnitPromises);\r\n } catch (e) {\r\n throw e;\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { name: value[0].name, label: value[1] };\r\n else\r\n return { name: value[0].name };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n if (this.customProps)\r\n return {\r\n type: Format.formatTypeToString(this.type),\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: Format.showSignOptionToString(this.showSignOption),\r\n formatTraits: Format.formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? Format.scientificTypeToString(this.scientificType) : undefined,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n composite,\r\n custom: this.customProps,\r\n } as CustomFormatProps;\r\n\r\n return {\r\n type: Format.formatTypeToString(this.type),\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: Format.showSignOptionToString(this.showSignOption),\r\n formatTraits: Format.formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? Format.scientificTypeToString(this.scientificType) : undefined,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n composite,\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatEnums.js","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,YAAY;AACZ,MAAM,CAAN,IAAY,YAqBX;AArBD,WAAY,YAAY;IACtB,kDAAkD;IAClD,6DAAiB,CAAA;IACjB,6FAA6F;IAC7F,mEAAoB,CAAA;IACpB,iDAAiD;IACjD,yDAAe,CAAA;IACf,iEAAiE;IACjE,uEAAsB,CAAA;IACtB,kDAAkD;IAClD,kEAAoB,CAAA;IACpB,2DAA2D;IAC3D,gEAAmB,CAAA;IACnB,uCAAuC;IACvC,kEAAoB,CAAA;IACpB,4CAA4C;IAC5C,yEAAuB,CAAA;IACvB,6CAA6C;IAC7C,yEAAwB,CAAA;IACxB,8IAA8I;IAC9I,iFAA4B,CAAA;AAC9B,CAAC,EArBW,YAAY,KAAZ,YAAY,QAqBvB;AAED;WACW;AACX,MAAM,CAAN,IAAY,mBAUX;AAVD,WAAY,mBAAmB;IAC7B,2DAAO,CAAA;IACP,2DAAO,CAAA;IACP,6DAAQ,CAAA;IACR,+DAAS,CAAA;IACT,oEAAY,CAAA;IACZ,wEAAc,CAAA;IACd,wEAAc,CAAA;IACd,iGAA2B,CAAA;IAC3B,2FAAwB,CAAA;AAC1B,CAAC,EAVW,mBAAmB,KAAnB,mBAAmB,QAU9B;AAED;WACW;AACX,MAAM,CAAN,IAAY,gBAcX;AAdD,WAAY,gBAAgB;IAC1B,uDAAQ,CAAA;IACR,qDAAO,CAAA;IACP,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,uDAAQ,CAAA;IACR,uDAAQ,CAAA;IACR,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,yDAAS,CAAA;IACT,uDAAQ,CAAA;IACR,sDAAQ,CAAA;IACR,4DAAW,CAAA;IACX,4DAAW,CAAA;AACb,CAAC,EAdW,gBAAgB,KAAhB,gBAAgB,QAc3B;AAED;YACY;AACZ,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB,iCAAiC;IACjC,iDAAO,CAAA;IACP,oCAAoC;IACpC,uDAAU,CAAA;IACV,sCAAsC;IACtC,uDAAU,CAAA;IACV,8CAA8C;IAC9C,iDAAO,CAAA;AACT,CAAC,EATW,UAAU,KAAV,UAAU,QASrB;AAED;WACW;AACX,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yDAAyD;IACzD,+DAAU,CAAA;IACV,sDAAsD;IACtD,uEAAc,CAAA;AAChB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED;WACW;AACX,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB,uDAAuD;IACvD,uDAAM,CAAA;IACN,mDAAmD;IACnD,mEAAY,CAAA;IACZ,oEAAoE;IACpE,+DAAU,CAAA;IACV,2IAA2I;IAC3I,iFAAmB,CAAA;AACrB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB","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\n/** @beta */\nexport enum FormatTraits {\n /** Show trailing zeroes to requested precision */\n TrailZeroes = 0x1,\n /** Indicates that the fractional part of the number is required when the fraction is zero */\n KeepSingleZero = 0x2,\n /** Zero magnitude returns blank display value */\n ZeroEmpty = 0x4,\n /** Show decimal point when value to right of decimal is empty */\n KeepDecimalPoint = 0x8,\n /** Use the rounding factor. Not yet supported */\n ApplyRounding = 0x10,\n /** Show a dash between whole value and fractional value */\n FractionDash = 0x20,\n /** Append the quantity's unit label */\n ShowUnitLabel = 0x40,\n /** Prepend unit label. Not yet supported */\n PrependUnitLabel = 0x80,\n /** show a grouping in each group of 1000. */\n Use1000Separator = 0x100,\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\n ExponentOnlyNegative = 0x200,\n}\n\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\n * @beta */\nexport enum FractionalPrecision {\n One = 1,\n Two = 2,\n Four = 4,\n Eight = 8,\n Sixteen = 16,\n ThirtyTwo = 32,\n SixtyFour = 64,\n OneHundredTwentyEight = 128,\n TwoHundredFiftySix = 256,\n}\n\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\n * @beta */\nexport enum DecimalPrecision {\n Zero = 0,\n One = 1,\n Two = 2,\n Three = 3,\n Four = 4,\n Five = 5,\n Six = 6,\n Seven = 7,\n Eight = 8,\n Nine = 9,\n Ten = 10,\n Eleven = 11,\n Twelve = 12,\n}\n\n/** Supported format types\n * @beta */\nexport enum FormatType {\n /** Decimal display (ie 2.125) */\n Decimal,\n /** Fractional display (ie 2-1/8) */\n Fractional,\n /** Scientific Notation (ie 1.04e3) */\n Scientific,\n /** Civil Engineering Stationing (ie 1+00). */\n Station,\n}\n\n/** required if type is scientific\n * @beta */\nexport enum ScientificType {\n /** Non-zero value left of decimal point (ie 1.2345e3) */\n Normalized,\n /** Zero value left of decimal point (ie 0.12345e4) */\n ZeroNormalized,\n}\n\n/** Determines how the sign of values are displayed\n * @beta */\nexport enum ShowSignOption {\n /** Never show a sign even if the value is negative. */\n NoSign,\n /** Only show a sign when the value is negative. */\n OnlyNegative,\n /** Always show a sign whether the value is positive or negative. */\n SignAlways,\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\n NegativeParentheses,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FormatEnums.js","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,YAAY;AACZ,MAAM,CAAN,IAAY,YAqBX;AArBD,WAAY,YAAY;IACtB,kDAAkD;IAClD,6DAAiB,CAAA;IACjB,6FAA6F;IAC7F,mEAAoB,CAAA;IACpB,iDAAiD;IACjD,yDAAe,CAAA;IACf,iEAAiE;IACjE,uEAAsB,CAAA;IACtB,kDAAkD;IAClD,kEAAoB,CAAA;IACpB,2DAA2D;IAC3D,gEAAmB,CAAA;IACnB,uCAAuC;IACvC,kEAAoB,CAAA;IACpB,4CAA4C;IAC5C,yEAAuB,CAAA;IACvB,6CAA6C;IAC7C,yEAAwB,CAAA;IACxB,8IAA8I;IAC9I,iFAA4B,CAAA;AAC9B,CAAC,EArBW,YAAY,KAAZ,YAAY,QAqBvB;AAED;WACW;AACX,MAAM,CAAN,IAAY,mBAUX;AAVD,WAAY,mBAAmB;IAC7B,2DAAO,CAAA;IACP,2DAAO,CAAA;IACP,6DAAQ,CAAA;IACR,+DAAS,CAAA;IACT,oEAAY,CAAA;IACZ,wEAAc,CAAA;IACd,wEAAc,CAAA;IACd,iGAA2B,CAAA;IAC3B,2FAAwB,CAAA;AAC1B,CAAC,EAVW,mBAAmB,KAAnB,mBAAmB,QAU9B;AAED;WACW;AACX,MAAM,CAAN,IAAY,gBAcX;AAdD,WAAY,gBAAgB;IAC1B,uDAAQ,CAAA;IACR,qDAAO,CAAA;IACP,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,uDAAQ,CAAA;IACR,uDAAQ,CAAA;IACR,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,yDAAS,CAAA;IACT,uDAAQ,CAAA;IACR,sDAAQ,CAAA;IACR,4DAAW,CAAA;IACX,4DAAW,CAAA;AACb,CAAC,EAdW,gBAAgB,KAAhB,gBAAgB,QAc3B;AAED;YACY;AACZ,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB,iCAAiC;IACjC,iDAAO,CAAA;IACP,oCAAoC;IACpC,uDAAU,CAAA;IACV,sCAAsC;IACtC,uDAAU,CAAA;IACV,8CAA8C;IAC9C,iDAAO,CAAA;AACT,CAAC,EATW,UAAU,KAAV,UAAU,QASrB;AAED;WACW;AACX,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yDAAyD;IACzD,+DAAU,CAAA;IACV,sDAAsD;IACtD,uEAAc,CAAA;AAChB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED;WACW;AACX,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB,uDAAuD;IACvD,uDAAM,CAAA;IACN,mDAAmD;IACnD,mEAAY,CAAA;IACZ,oEAAoE;IACpE,+DAAU,CAAA;IACV,2IAA2I;IAC3I,iFAAmB,CAAA;AACrB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB","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\n/** @beta */\r\nexport enum FormatTraits {\r\n /** Show trailing zeroes to requested precision */\r\n TrailZeroes = 0x1,\r\n /** Indicates that the fractional part of the number is required when the fraction is zero */\r\n KeepSingleZero = 0x2,\r\n /** Zero magnitude returns blank display value */\r\n ZeroEmpty = 0x4,\r\n /** Show decimal point when value to right of decimal is empty */\r\n KeepDecimalPoint = 0x8,\r\n /** Use the rounding factor. Not yet supported */\r\n ApplyRounding = 0x10,\r\n /** Show a dash between whole value and fractional value */\r\n FractionDash = 0x20,\r\n /** Append the quantity's unit label */\r\n ShowUnitLabel = 0x40,\r\n /** Prepend unit label. Not yet supported */\r\n PrependUnitLabel = 0x80,\r\n /** show a grouping in each group of 1000. */\r\n Use1000Separator = 0x100,\r\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\r\n ExponentOnlyNegative = 0x200,\r\n}\r\n\r\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\r\n * @beta */\r\nexport enum FractionalPrecision {\r\n One = 1,\r\n Two = 2,\r\n Four = 4,\r\n Eight = 8,\r\n Sixteen = 16,\r\n ThirtyTwo = 32,\r\n SixtyFour = 64,\r\n OneHundredTwentyEight = 128,\r\n TwoHundredFiftySix = 256,\r\n}\r\n\r\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\r\n * @beta */\r\nexport enum DecimalPrecision {\r\n Zero = 0,\r\n One = 1,\r\n Two = 2,\r\n Three = 3,\r\n Four = 4,\r\n Five = 5,\r\n Six = 6,\r\n Seven = 7,\r\n Eight = 8,\r\n Nine = 9,\r\n Ten = 10,\r\n Eleven = 11,\r\n Twelve = 12,\r\n}\r\n\r\n/** Supported format types\r\n * @beta */\r\nexport enum FormatType {\r\n /** Decimal display (ie 2.125) */\r\n Decimal,\r\n /** Fractional display (ie 2-1/8) */\r\n Fractional,\r\n /** Scientific Notation (ie 1.04e3) */\r\n Scientific,\r\n /** Civil Engineering Stationing (ie 1+00). */\r\n Station,\r\n}\r\n\r\n/** required if type is scientific\r\n * @beta */\r\nexport enum ScientificType {\r\n /** Non-zero value left of decimal point (ie 1.2345e3) */\r\n Normalized,\r\n /** Zero value left of decimal point (ie 0.12345e4) */\r\n ZeroNormalized,\r\n}\r\n\r\n/** Determines how the sign of values are displayed\r\n * @beta */\r\nexport enum ShowSignOption {\r\n /** Never show a sign even if the value is negative. */\r\n NoSign,\r\n /** Only show a sign when the value is negative. */\r\n OnlyNegative,\r\n /** Always show a sign whether the value is positive or negative. */\r\n SignAlways,\r\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\r\n NegativeParentheses,\r\n}\r\n"]}
|
|
@@ -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,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AAG,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;;AAxSD,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) return this._textParts[0];\n return \"\";\n }\n\n public getNumeratorString(): string {\n if (this._textParts.length >= 3) return this._textParts[1];\n return \"\";\n }\n\n public getDenominatorString(): string {\n if (this._textParts.length >= 3) return this._textParts[2];\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) 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)) 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)) 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) expInt += 1.0;\n else if (spec.format.scientificType === ScientificType.Normalized && posMagnitude < 1.0) expInt += 1.0;\n if (negativeExp) expInt = -expInt;\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) fractionString = Formatter.trimTrailingZeroes(fractionString);\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;\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) fractionString = Formatter.trimTrailingZeroes(fractionString);\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) prefix = \"-\";\n break;\n\n case ShowSignOption.SignAlways:\n if (valueIsNegative) prefix = \"-\";\n else prefix = \"+\";\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;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,aA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kB,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;;AAxSD,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) return this._textParts[0];\r\n return \"\";\r\n }\r\n\r\n public getNumeratorString(): string {\r\n if (this._textParts.length >= 3) return this._textParts[1];\r\n return \"\";\r\n }\r\n\r\n public getDenominatorString(): string {\r\n if (this._textParts.length >= 3) return this._textParts[2];\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) 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)) 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)) 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) expInt += 1.0;\r\n else if (spec.format.scientificType === ScientificType.Normalized && posMagnitude < 1.0) expInt += 1.0;\r\n if (negativeExp) expInt = -expInt;\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) fractionString = Formatter.trimTrailingZeroes(fractionString);\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;\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) fractionString = Formatter.trimTrailingZeroes(fractionString);\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) prefix = \"-\";\r\n break;\r\n\r\n case ShowSignOption.SignAlways:\r\n if (valueIsNegative) prefix = \"-\";\r\n else prefix = \"+\";\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"]}
|