corva-convert-units
Advanced tools
Comparing version 1.16.0 to 1.16.1
# Changelog | ||
## [1.16.1](https://github.com/corva-ai/corva-convert-units/compare/v1.16.0...v1.16.1) (2024-06-04) | ||
### Bug Fixes | ||
* **dri-1031:** update index.d.ts, revert incompatible measures error ([#44](https://github.com/corva-ai/corva-convert-units/issues/44)) ([4643f8c](https://github.com/corva-ai/corva-convert-units/commit/4643f8cb40a25cbe35619b09a6667a32e871a54a)) | ||
## [1.16.0](https://github.com/corva-ai/corva-convert-units/compare/v1.15.1...v1.16.0) (2024-05-31) | ||
@@ -4,0 +11,0 @@ |
@@ -1,7 +0,8 @@ | ||
declare function convert(value: unknown): convert.Converter; | ||
declare function convert(value: unknown, measure?: string): convert.Converter; | ||
declare namespace convert { | ||
export class Converter { | ||
constructor(numerator: number, denominator: number); | ||
constructor(numerator: number, measure?: string); | ||
val: number; | ||
measure: string | undefined; | ||
from(from: string): this; | ||
@@ -11,8 +12,10 @@ to(to: string): number; | ||
measures(): string[]; | ||
getUnit(abbr: string): Unit | undefined; | ||
getUnitForPair(abbrOne: string, abbrTwo: string): [Unit, Unit] | null; | ||
getUnit(abbr: string, measure: string | undefined): Unit | undefined; | ||
describe(abbr: string): PlainUnit; | ||
list(measure: string): PlainUnit[]; | ||
list(measure: string | undefined): PlainUnit[]; | ||
throwUnsupportedUnitError(what: string): void; | ||
possibilities(measure: string): string[]; | ||
throwUnsupportedMeasureError(what: string): void; | ||
throwUnsupportedCompatibilityError(abbr: Unit['abbr'], measure: string): void; | ||
throwIncompatibleMeasuresError(destinationMeasure: string, originMeasure: string): void; | ||
possibilities(measure: string | undefined): string[]; | ||
} | ||
@@ -19,0 +22,0 @@ |
@@ -104,2 +104,7 @@ const unitBucketMapping = require('./definitions/unitBucketMapping'); | ||
// You can't go from liquid to mass, for example | ||
if (this.destination.measure != this.origin.measure) { | ||
this.throwIncompatibleMeasuresError(this.destination.measure, this.origin.measure); | ||
} | ||
/** | ||
@@ -315,6 +320,10 @@ * Convert from the source value to its anchor inside the system | ||
Converter.prototype.throwUnsupportedCompatibilityError = function(unit, measure) { | ||
throw new Error('Unsupported compatibility for unit ' + unit + ' and measure ' + measure); | ||
Converter.prototype.throwUnsupportedCompatibilityError = function(abbr, measure) { | ||
throw new Error('Unsupported compatibility for unit ' + abbr + ' and measure ' + measure); | ||
}; | ||
Converter.prototype.throwIncompatibleMeasuresError = function(destinationMeasure, originMeasure) { | ||
throw new Error('Cannot convert incompatible measures of ' + destinationMeasure + ' and ' + originMeasure); | ||
}; | ||
/** | ||
@@ -321,0 +330,0 @@ * Returns the abbreviated measures that the value can be |
{ | ||
"name": "corva-convert-units", | ||
"version": "1.16.0", | ||
"version": "1.16.1", | ||
"description": "Convert between quantities in different units", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85813
4222