Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

convert-units

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-units - npm Package Compare versions

Comparing version 3.0.0-beta.3 to 3.0.0-beta.4

12

lib/cjs/convert.js

@@ -119,8 +119,9 @@ "use strict";

throw new Error('.toBest must be called after .from');
var isNegative = this.val < 0;
var exclude = [];
var cutOffNumber = 1;
var cutOffNumber = isNegative ? -1 : 1;
var system = this.origin.system;
if (typeof options === 'object') {
exclude = (_a = options.exclude) !== null && _a !== void 0 ? _a : [];
cutOffNumber = (_b = options.cutOffNumber) !== null && _b !== void 0 ? _b : 1;
cutOffNumber = (_b = options.cutOffNumber) !== null && _b !== void 0 ? _b : cutOffNumber;
system = (_c = options.system) !== null && _c !== void 0 ? _c : this.origin.system;

@@ -140,6 +141,9 @@ }

var result = this.to(possibility);
if (result < cutOffNumber) {
if (isNegative ? result > cutOffNumber : result < cutOffNumber) {
continue;
}
if (best == null || (result >= cutOffNumber && result < best.val)) {
if (best === null ||
(isNegative
? result <= cutOffNumber && result > best.val
: result >= cutOffNumber && result < best.val)) {
best = {

@@ -146,0 +150,0 @@ val: result,

import { Measure } from './../index';
export declare type EnergyUnits = EnergySIUnits;
export declare type EnergySystems = 'SI';
export declare type EnergySIUnits = 'Wh' | 'mWh' | 'kWh' | 'MWh' | 'GWh' | 'J' | 'kJ';
export declare type EnergySIUnits = 'Wh' | 'mWh' | 'kWh' | 'MWh' | 'GWh' | 'J' | 'kJ' | 'MJ' | 'GJ';
declare const measure: Measure<EnergySystems, EnergyUnits>;
export default measure;

@@ -53,2 +53,16 @@ "use strict";

},
MJ: {
name: {
singular: 'Megajoule',
plural: 'Megajoules',
},
to_anchor: 1000000,
},
GJ: {
name: {
singular: 'Gigajoule',
plural: 'Gigajoules',
},
to_anchor: 1000000000,
},
};

@@ -55,0 +69,0 @@ var measure = {

import { Measure } from './../index';
export declare type PartsPerUnits = PArtsPerSIUnits;
export declare type PartsPerUnits = PartsPerSIUnits;
export declare type PartsPerSystems = 'SI';
export declare type PArtsPerSIUnits = 'ppm' | 'ppb' | 'ppt' | 'ppq';
export declare type PartsPerSIUnits = 'ppm' | 'ppb' | 'ppt' | 'ppq';
declare const measure: Measure<PartsPerSystems, PartsPerUnits>;
export default measure;
import { Measure } from './../index';
export declare type VolumeUnits = VolumeMetricUnits | VolumeImperialUnits;
export declare type VolumeSystems = 'metric' | 'imperial';
export declare type VolumeMetricUnits = 'mm3' | 'cm3' | 'ml' | 'l' | 'kl' | 'm3' | 'km3' | 'cl' | 'dl' | 'krm' | 'tsk' | 'msk' | 'kkp' | 'glas' | 'kanna';
export declare type VolumeMetricUnits = 'mm3' | 'cm3' | 'ml' | 'l' | 'kl' | 'Ml' | 'Gl' | 'm3' | 'km3' | 'cl' | 'dl' | 'krm' | 'tsk' | 'msk' | 'kkp' | 'glas' | 'kanna';
export declare type VolumeImperialUnits = 'tsp' | 'Tbs' | 'in3' | 'fl-oz' | 'cup' | 'pnt' | 'qt' | 'gal' | 'ft3' | 'yd3';
declare const measure: Measure<VolumeSystems, VolumeUnits>;
export default measure;

@@ -53,2 +53,16 @@ "use strict";

},
Ml: {
name: {
singular: 'Megalitre',
plural: 'Megalitres',
},
to_anchor: 1000000,
},
Gl: {
name: {
singular: 'Gigalitre',
plural: 'Gigalitres',
},
to_anchor: 1000000000,
},
m3: {

@@ -55,0 +69,0 @@ name: {

@@ -116,8 +116,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

throw new Error('.toBest must be called after .from');
var isNegative = this.val < 0;
var exclude = [];
var cutOffNumber = 1;
var cutOffNumber = isNegative ? -1 : 1;
var system = this.origin.system;
if (typeof options === 'object') {
exclude = (_a = options.exclude) !== null && _a !== void 0 ? _a : [];
cutOffNumber = (_b = options.cutOffNumber) !== null && _b !== void 0 ? _b : 1;
cutOffNumber = (_b = options.cutOffNumber) !== null && _b !== void 0 ? _b : cutOffNumber;
system = (_c = options.system) !== null && _c !== void 0 ? _c : this.origin.system;

@@ -137,6 +138,9 @@ }

var result = this.to(possibility);
if (result < cutOffNumber) {
if (isNegative ? result > cutOffNumber : result < cutOffNumber) {
continue;
}
if (best == null || (result >= cutOffNumber && result < best.val)) {
if (best === null ||
(isNegative
? result <= cutOffNumber && result > best.val
: result >= cutOffNumber && result < best.val)) {
best = {

@@ -143,0 +147,0 @@ val: result,

import { Measure } from './../index';
export declare type EnergyUnits = EnergySIUnits;
export declare type EnergySystems = 'SI';
export declare type EnergySIUnits = 'Wh' | 'mWh' | 'kWh' | 'MWh' | 'GWh' | 'J' | 'kJ';
export declare type EnergySIUnits = 'Wh' | 'mWh' | 'kWh' | 'MWh' | 'GWh' | 'J' | 'kJ' | 'MJ' | 'GJ';
declare const measure: Measure<EnergySystems, EnergyUnits>;
export default measure;

@@ -51,2 +51,16 @@ var SI = {

},
MJ: {
name: {
singular: 'Megajoule',
plural: 'Megajoules',
},
to_anchor: 1000000,
},
GJ: {
name: {
singular: 'Gigajoule',
plural: 'Gigajoules',
},
to_anchor: 1000000000,
},
};

@@ -53,0 +67,0 @@ var measure = {

import { Measure } from './../index';
export declare type PartsPerUnits = PArtsPerSIUnits;
export declare type PartsPerUnits = PartsPerSIUnits;
export declare type PartsPerSystems = 'SI';
export declare type PArtsPerSIUnits = 'ppm' | 'ppb' | 'ppt' | 'ppq';
export declare type PartsPerSIUnits = 'ppm' | 'ppb' | 'ppt' | 'ppq';
declare const measure: Measure<PartsPerSystems, PartsPerUnits>;
export default measure;
import { Measure } from './../index';
export declare type VolumeUnits = VolumeMetricUnits | VolumeImperialUnits;
export declare type VolumeSystems = 'metric' | 'imperial';
export declare type VolumeMetricUnits = 'mm3' | 'cm3' | 'ml' | 'l' | 'kl' | 'm3' | 'km3' | 'cl' | 'dl' | 'krm' | 'tsk' | 'msk' | 'kkp' | 'glas' | 'kanna';
export declare type VolumeMetricUnits = 'mm3' | 'cm3' | 'ml' | 'l' | 'kl' | 'Ml' | 'Gl' | 'm3' | 'km3' | 'cl' | 'dl' | 'krm' | 'tsk' | 'msk' | 'kkp' | 'glas' | 'kanna';
export declare type VolumeImperialUnits = 'tsp' | 'Tbs' | 'in3' | 'fl-oz' | 'cup' | 'pnt' | 'qt' | 'gal' | 'ft3' | 'yd3';
declare const measure: Measure<VolumeSystems, VolumeUnits>;
export default measure;

@@ -51,2 +51,16 @@ var metric = {

},
Ml: {
name: {
singular: 'Megalitre',
plural: 'Megalitres',
},
to_anchor: 1000000,
},
Gl: {
name: {
singular: 'Gigalitre',
plural: 'Gigalitres',
},
to_anchor: 1000000000,
},
m3: {

@@ -53,0 +67,0 @@ name: {

@@ -128,8 +128,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

throw new Error('.toBest must be called after .from');
var isNegative = this.val < 0;
var exclude = [];
var cutOffNumber = 1;
var cutOffNumber = isNegative ? -1 : 1;
var system = this.origin.system;
if (typeof options === 'object') {
exclude = (_a = options.exclude) !== null && _a !== void 0 ? _a : [];
cutOffNumber = (_b = options.cutOffNumber) !== null && _b !== void 0 ? _b : 1;
cutOffNumber = (_b = options.cutOffNumber) !== null && _b !== void 0 ? _b : cutOffNumber;
system = (_c = options.system) !== null && _c !== void 0 ? _c : this.origin.system;

@@ -149,6 +150,9 @@ }

var result = this.to(possibility);
if (result < cutOffNumber) {
if (isNegative ? result > cutOffNumber : result < cutOffNumber) {
continue;
}
if (best == null || (result >= cutOffNumber && result < best.val)) {
if (best === null ||
(isNegative
? result <= cutOffNumber && result > best.val
: result >= cutOffNumber && result < best.val)) {
best = {

@@ -155,0 +159,0 @@ val: result,

import { Measure } from './../index';
export declare type EnergyUnits = EnergySIUnits;
export declare type EnergySystems = 'SI';
export declare type EnergySIUnits = 'Wh' | 'mWh' | 'kWh' | 'MWh' | 'GWh' | 'J' | 'kJ';
export declare type EnergySIUnits = 'Wh' | 'mWh' | 'kWh' | 'MWh' | 'GWh' | 'J' | 'kJ' | 'MJ' | 'GJ';
declare const measure: Measure<EnergySystems, EnergyUnits>;
export default measure;

@@ -62,2 +62,16 @@ (function (factory) {

},
MJ: {
name: {
singular: 'Megajoule',
plural: 'Megajoules',
},
to_anchor: 1000000,
},
GJ: {
name: {
singular: 'Gigajoule',
plural: 'Gigajoules',
},
to_anchor: 1000000000,
},
};

@@ -64,0 +78,0 @@ var measure = {

import { Measure } from './../index';
export declare type PartsPerUnits = PArtsPerSIUnits;
export declare type PartsPerUnits = PartsPerSIUnits;
export declare type PartsPerSystems = 'SI';
export declare type PArtsPerSIUnits = 'ppm' | 'ppb' | 'ppt' | 'ppq';
export declare type PartsPerSIUnits = 'ppm' | 'ppb' | 'ppt' | 'ppq';
declare const measure: Measure<PartsPerSystems, PartsPerUnits>;
export default measure;
import { Measure } from './../index';
export declare type VolumeUnits = VolumeMetricUnits | VolumeImperialUnits;
export declare type VolumeSystems = 'metric' | 'imperial';
export declare type VolumeMetricUnits = 'mm3' | 'cm3' | 'ml' | 'l' | 'kl' | 'm3' | 'km3' | 'cl' | 'dl' | 'krm' | 'tsk' | 'msk' | 'kkp' | 'glas' | 'kanna';
export declare type VolumeMetricUnits = 'mm3' | 'cm3' | 'ml' | 'l' | 'kl' | 'Ml' | 'Gl' | 'm3' | 'km3' | 'cl' | 'dl' | 'krm' | 'tsk' | 'msk' | 'kkp' | 'glas' | 'kanna';
export declare type VolumeImperialUnits = 'tsp' | 'Tbs' | 'in3' | 'fl-oz' | 'cup' | 'pnt' | 'qt' | 'gal' | 'ft3' | 'yd3';
declare const measure: Measure<VolumeSystems, VolumeUnits>;
export default measure;

@@ -62,2 +62,16 @@ (function (factory) {

},
Ml: {
name: {
singular: 'Megalitre',
plural: 'Megalitres',
},
to_anchor: 1000000,
},
Gl: {
name: {
singular: 'Gigalitre',
plural: 'Gigalitres',
},
to_anchor: 1000000000,
},
m3: {

@@ -64,0 +78,0 @@ name: {

{
"name": "convert-units",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"description": "Convert between quantities in different units",

@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js",

@@ -86,3 +86,3 @@ convert-units

The best is always the smallest number above `1`. That number can be changed to get different results:
The best is always the smallest number above `1`. If the value is a negative number, the best is always the largest number below `-1`. The cut off number of either `1` or `-1` can be changed to get different results:

@@ -932,2 +932,4 @@ ```js

* kl
* Ml
* Gl
* m3

@@ -1134,2 +1136,4 @@ * km3

* kJ
* MJ
* GJ
</details>

@@ -1136,0 +1140,0 @@

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