Socket
Socket
Sign inDemoInstall

corva-convert-units

Package Overview
Dependencies
Maintainers
21
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

corva-convert-units - npm Package Compare versions

Comparing version 1.16.0 to 1.16.1

7

CHANGELOG.md
# 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 @@

15

index.d.ts

@@ -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 @@

13

lib/index.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc