Socket
Socket
Sign inDemoInstall

corva-convert-units

Package Overview
Dependencies
2
Maintainers
12
Versions
81
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.10.24 to 1.10.25

57

lib/index.js

@@ -89,4 +89,9 @@ var convert, keys = require('lodash.keys'),

if (this.destination.measure != this.origin.measure) {
throw new Error('Cannot convert incompatible measures of ' +
this.destination.measure + ' and ' + this.origin.measure);
var pair = this.getUnitForPair(this.destination.abbr, this.origin.abbr);
if (!pair) {
throw new Error('Cannot convert incompatible measures of ' +
this.destination.measure + ' and ' + this.origin.measure);
}
this.destination = pair[0];
this.origin = pair[1];
}

@@ -206,2 +211,50 @@

Converter.prototype.getUnitForPair = function(abbrOne, abbrTwo) {
var foundOne;
var foundTwo;
each(measures, function(systems, measure) {
each(systems, function(units, system) {
if (system === '_anchors')
return false;
each(units, function(unit, testAbbr) {
if (testAbbr === abbrOne) {
foundOne = {
abbr: abbrOne,
measure: measure,
system: system,
unit: unit
};
} else if (testAbbr === abbrTwo) {
foundTwo = {
abbr: abbrTwo,
measure: measure,
system: system,
unit: unit
};
}
if (foundOne && foundTwo) {
return false;
}
});
if (foundOne && foundTwo) {
return false;
}
});
if (foundOne && foundTwo) {
return false;
} else {
foundOne = null;
foundTwo = null;
}
});
return foundOne && foundTwo ? [foundOne, foundTwo] : null;
};
var describe = function(resp) {

@@ -208,0 +261,0 @@ return {

2

package.json
{
"name": "corva-convert-units",
"version": "1.10.24",
"version": "1.10.25",
"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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc