Socket
Socket
Sign inDemoInstall

measure-fns

Package Overview
Dependencies
1
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.1 to 0.4.2

94

dist/index.js

@@ -113,9 +113,2 @@ 'use strict';

}
/**
* 四舍五入
*/
function round(num, ratio) {
var base = Math.pow(10, ratio);
return divide(Math.round(times(num, base)), base);
}
var _boundaryCheckingState = true;

@@ -130,3 +123,2 @@ /**

}
var index = { strip: strip, plus: plus, minus: minus, times: times, divide: divide, round: round, digitLength: digitLength, float2Fixed: float2Fixed, enableBoundaryChecking: enableBoundaryChecking };

@@ -160,3 +152,3 @@ var MeasurementType;

function round$1(value, roundAmount) {
function round(value, roundAmount) {
if (roundAmount === 0 || roundAmount === true) {

@@ -173,3 +165,3 @@ return Math.round(value);

// TODO: verify round is 0> int
return round$1(value, options.round);
return round(value, options.round);
}

@@ -180,3 +172,3 @@

index.enableBoundaryChecking(false);
enableBoundaryChecking(false);

@@ -193,19 +185,19 @@ (function (LengthUnit) {

function centimetresToMetres(value) {
return index.divide(value, CENTIMETRES_IN_METRE);
return divide(value, CENTIMETRES_IN_METRE);
}
function feetToMetres(value) {
return index.divide(value, FEET_IN_METRE);
return divide(value, FEET_IN_METRE);
}
function inchesToMetres(value) {
return index.divide(value, INCHES_IN_METRE);
return divide(value, INCHES_IN_METRE);
}
function kilometresToMetres(value) {
return index.divide(value, KILOMETRES_IN_METRE);
return divide(value, KILOMETRES_IN_METRE);
}
function milesToMetres(value) {
return index.divide(value, MILES_IN_METRE);
return divide(value, MILES_IN_METRE);
}

@@ -259,18 +251,18 @@

function lengthToCentimetres(_length, options = {}) {
return applyOptions(index.times(_length.value, CENTIMETRES_IN_METRE), options);
return applyOptions(times(_length.value, CENTIMETRES_IN_METRE), options);
}
function lengthToFeet(_length, options = {}) {
return applyOptions(index.times(_length.value, FEET_IN_METRE), options);
return applyOptions(times(_length.value, FEET_IN_METRE), options);
}
function lengthToInches(_length, options = {}) {
return applyOptions(index.times(_length.value, INCHES_IN_METRE), options);
return applyOptions(times(_length.value, INCHES_IN_METRE), options);
}
function lengthToKilometres(_length, options = {}) {
return applyOptions(index.times(_length.value, KILOMETRES_IN_METRE), options);
return applyOptions(times(_length.value, KILOMETRES_IN_METRE), options);
}
function lengthToMiles(_length, options = {}) {
return applyOptions(index.times(_length.value, MILES_IN_METRE), options);
return applyOptions(times(_length.value, MILES_IN_METRE), options);
}
index.enableBoundaryChecking(false);
enableBoundaryChecking(false);

@@ -285,11 +277,11 @@ (function (MassUnit) {

function gramsToKilograms(value) {
return index.divide(value, GRAMS_IN_KILOGRAM);
return divide(value, GRAMS_IN_KILOGRAM);
}
function poundsToKilograms(value) {
return index.divide(value, POUNDS_IN_KILOGRAM);
return divide(value, POUNDS_IN_KILOGRAM);
}
function ouncesToKilograms(value) {
return index.divide(value, OUNCES_IN_KILOGRAM);
return divide(value, OUNCES_IN_KILOGRAM);
}

@@ -331,12 +323,12 @@

function massToGrams(_mass, options = {}) {
return applyOptions(index.times(_mass.value, GRAMS_IN_KILOGRAM), options);
return applyOptions(times(_mass.value, GRAMS_IN_KILOGRAM), options);
}
function massToPounds(_mass, options = {}) {
return applyOptions(index.times(_mass.value, POUNDS_IN_KILOGRAM), options);
return applyOptions(times(_mass.value, POUNDS_IN_KILOGRAM), options);
}
function massToOunces(_mass, options = {}) {
return applyOptions(index.times(_mass.value, OUNCES_IN_KILOGRAM), options);
return applyOptions(times(_mass.value, OUNCES_IN_KILOGRAM), options);
}
index.enableBoundaryChecking(false);
enableBoundaryChecking(false);

@@ -352,15 +344,15 @@ (function (PressureUnit) {

function hectopascalToPascal(value) {
return index.times(value, PASCALS_IN_HECTOPASCAL);
return times(value, PASCALS_IN_HECTOPASCAL);
}
function barToPascal(value) {
return index.times(value, PASCALS_IN_BAR);
return times(value, PASCALS_IN_BAR);
}
function millibarToPascal(value) {
return index.times(value, PASCALS_IN_MILLIBAR);
return times(value, PASCALS_IN_MILLIBAR);
}
function mmhgToPascal(value) {
return index.times(value, PASCALS_IN_MMHG);
return times(value, PASCALS_IN_MMHG);
}

@@ -408,15 +400,15 @@

function pressureToHectopascal(pressure, options = {}) {
return applyOptions(index.divide(pressure.value, PASCALS_IN_HECTOPASCAL), options);
return applyOptions(divide(pressure.value, PASCALS_IN_HECTOPASCAL), options);
}
function pressureToBar(pressure, options = {}) {
return applyOptions(index.divide(pressure.value, PASCALS_IN_BAR), options);
return applyOptions(divide(pressure.value, PASCALS_IN_BAR), options);
}
function pressureToMillibar(pressure, options = {}) {
return applyOptions(index.divide(pressure.value, PASCALS_IN_MILLIBAR), options);
return applyOptions(divide(pressure.value, PASCALS_IN_MILLIBAR), options);
}
function pressureToMmhg(pressure, options = {}) {
return applyOptions(index.divide(pressure.value, PASCALS_IN_MMHG), options);
return applyOptions(divide(pressure.value, PASCALS_IN_MMHG), options);
}
index.enableBoundaryChecking(false);
enableBoundaryChecking(false);

@@ -432,11 +424,11 @@ (function (SpeedUnit) {

function kmhToMs(value) {
return index.divide(value, SECONDS_IN_HOUR, KILOMETRES_IN_METRE);
return divide(value, SECONDS_IN_HOUR, KILOMETRES_IN_METRE);
}
function mphToMs(value) {
return index.divide(value, SECONDS_IN_HOUR, MILES_IN_METRE);
return divide(value, SECONDS_IN_HOUR, MILES_IN_METRE);
}
function knotsToMs(value) {
return index.divide(value, SECONDS_IN_HOUR, NAUTICAL_MILES_IN_METRE);
return divide(value, SECONDS_IN_HOUR, NAUTICAL_MILES_IN_METRE);
}

@@ -446,3 +438,3 @@

// eslint-disable-next-line no-magic-numbers
return index.divide(value, FEET_IN_METRE);
return divide(value, FEET_IN_METRE);
}

@@ -490,15 +482,15 @@

function speedToKmh(speed, options = {}) {
return applyOptions(index.times(speed.value, SECONDS_IN_HOUR, KILOMETRES_IN_METRE), options);
return applyOptions(times(speed.value, SECONDS_IN_HOUR, KILOMETRES_IN_METRE), options);
}
function speedToMph(speed, options = {}) {
return applyOptions(index.times(speed.value, SECONDS_IN_HOUR, MILES_IN_METRE), options);
return applyOptions(times(speed.value, SECONDS_IN_HOUR, MILES_IN_METRE), options);
}
function speedToKnots(speed, options = {}) {
return applyOptions(index.times(speed.value, SECONDS_IN_HOUR, NAUTICAL_MILES_IN_METRE), options);
return applyOptions(times(speed.value, SECONDS_IN_HOUR, NAUTICAL_MILES_IN_METRE), options);
}
function speedToFps(speed, options = {}) {
return applyOptions(index.times(speed.value, FEET_IN_METRE), options);
return applyOptions(times(speed.value, FEET_IN_METRE), options);
}
index.enableBoundaryChecking(false);
enableBoundaryChecking(false);

@@ -514,3 +506,3 @@ (function (TemperatureUnit) {

function celsiusToKelvin(value) {
return index.plus(value, KELIN_OFFSET);
return plus(value, KELIN_OFFSET);
}

@@ -520,3 +512,3 @@

// eslint-disable-next-line no-magic-numbers
return index.plus(index.times(index.minus(value, 32), index.divide(5, 9)), KELIN_OFFSET);
return plus(times(minus(value, 32), divide(5, 9)), KELIN_OFFSET);
}

@@ -552,7 +544,7 @@

function temperatureToCelsius(temperature, options = {}) {
return applyOptions(index.minus(temperature.value, KELIN_OFFSET), options);
return applyOptions(minus(temperature.value, KELIN_OFFSET), options);
}
function temperatureToFahrenheit(temperature, options = {}) {
return applyOptions( // eslint-disable-next-line no-magic-numbers
index.plus(index.times(index.minus(temperature.value, KELIN_OFFSET), index.divide(9, 5)), 32), options);
plus(times(minus(temperature.value, KELIN_OFFSET), divide(9, 5)), 32), options);
}

@@ -559,0 +551,0 @@

{
"name": "measure-fns",
"version": "0.4.1",
"version": "0.4.2",
"description": "Functions for conversion and handling of measurements",

@@ -27,23 +27,23 @@ "main": "dist/index.js",

"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-object-rest-spread": "^7.9.0",
"@babel/plugin-transform-async-to-generator": "^7.8.3",
"@babel/preset-env": "^7.9.0",
"@babel/preset-typescript": "^7.9.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.3",
"@types/jest": "^25.1.4",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"eslint-config-fishbrain": "^0.15.0",
"eslint-plugin-jest-formatting": "^1.2.0",
"fast-check": "^2.13.0",
"jest": "^25.1.0",
"prettier": "^2.0.1",
"rollup": "^2.6.1",
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
"@babel/plugin-transform-async-to-generator": "^7.14.5",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@types/jest": "^27.0.1",
"babel-jest": "^27.1.1",
"eslint": "^7.32.0",
"eslint-config-lukehansford-base": "^1.1.0",
"eslint-plugin-jest-formatting": "^3.0.0",
"fast-check": "^2.17.0",
"jest": "^27.1.1",
"prettier": "^2.4.0",
"rollup": "^2.56.3",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-typescript2": "^0.27.0",
"typescript": "^3.8.3"
"rollup-plugin-typescript2": "^0.30.0",
"typescript": "^4.4.3"
},

@@ -50,0 +50,0 @@ "bugs": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc