Socket
Socket
Sign inDemoInstall

@aryth/math

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aryth/math - npm Package Compare versions

Comparing version 0.3.19 to 0.3.20

77

dist/index.cjs.js

@@ -5,19 +5,33 @@ 'use strict';

const abs = n => n < 0 ? 0 - n : n;
/**
*
* applicable for smaller number
* @param {number} x
* @returns {number}
*/
const E1 = 10; // E1
const round = x => x + (x > 0 ? 0.5 : -0.5) << 0;
const constraint = (x, min, max) => x > max ? max : x < min ? min : x;
const E2 = 1E+2;
const E4 = 1E+4;
const MILLION = 1E+6;
const roundD1 = x => Math.round(x * 10) / 10;
const roundD2 = x => Math.round(x * E2) / E2;
const roundD4 = x => Math.round(x * E4) / E4; // export const roundD2=x=>Math.round()
const E4 = 10_000; // E4
const E7 = 10_000_000; // E7
const E10 = 10_000_000_000; // E10
const E13 = 10_000_000_000_000; // E13
const E2 = 100; // E2
const E5 = 100_000; // E5
const E8 = 100_000_000; // E8
const E11 = 100_000_000_000; // E11
const E14 = 100_000_000_000_000; // E14
const E3 = 1_000; // E3
const E6 = 1_000_000; // E6
const E9 = 1_000_000_000; // E9
const E12 = 1_000_000_000_000; // E12
const E15 = 1_000_000_000_000_000; // E15
const abs = n => n < 0 ? 0 - n : n;
/**

@@ -33,4 +47,6 @@ * Get an integer absolute of a number

};
/**
*
* applicable for smaller number
* @param {number} x

@@ -40,9 +56,35 @@ * @returns {number}

const intExpon = x => ~~Math.log10(x);
const round = x => x + (x > 0 ? 0.5 : -0.5) << 0;
const roundD1 = x => Math.round(x * 10) / 10;
const roundD2 = x => Math.round(x * E2) / E2;
const roundD3 = x => Math.round(x * E3) / E3;
const roundD4 = x => Math.round(x * E4) / E4;
const almostEquals = (x, y, epsilon) => Math.abs(x - y) < epsilon;
const almostInt = (x, epsilon) => Math.abs(x - round(x)) < epsilon;
const constraint = (x, min, max) => x > max ? max : x < min ? min : x;
/**
*
* @param {number} x
* @returns {number}
*/
const intExpon = x => ~~Math.log10(x);
exports.E1 = E1;
exports.E10 = E10;
exports.E11 = E11;
exports.E12 = E12;
exports.E13 = E13;
exports.E14 = E14;
exports.E15 = E15;
exports.E2 = E2;
exports.E3 = E3;
exports.E4 = E4;
exports.MILLION = MILLION;
exports.E5 = E5;
exports.E6 = E6;
exports.E7 = E7;
exports.E8 = E8;
exports.E9 = E9;
exports.abs = abs;

@@ -57,2 +99,3 @@ exports.almostEquals = almostEquals;

exports.roundD2 = roundD2;
exports.roundD3 = roundD3;
exports.roundD4 = roundD4;

@@ -1,18 +0,32 @@

const abs = n => n < 0 ? 0 - n : n;
/**
*
* applicable for smaller number
* @param {number} x
* @returns {number}
*/
const E1 = 10; // E1
const round = x => x + (x > 0 ? 0.5 : -0.5) << 0;
const constraint = (x, min, max) => x > max ? max : x < min ? min : x;
const E2 = 1E+2;
const E4 = 1E+4;
const MILLION = 1E+6;
const roundD1 = x => Math.round(x * 10) / 10;
const roundD2 = x => Math.round(x * E2) / E2;
const roundD4 = x => Math.round(x * E4) / E4; // export const roundD2=x=>Math.round()
const E4 = 10_000; // E4
const E7 = 10_000_000; // E7
const E10 = 10_000_000_000; // E10
const E13 = 10_000_000_000_000; // E13
const E2 = 100; // E2
const E5 = 100_000; // E5
const E8 = 100_000_000; // E8
const E11 = 100_000_000_000; // E11
const E14 = 100_000_000_000_000; // E14
const E3 = 1_000; // E3
const E6 = 1_000_000; // E6
const E9 = 1_000_000_000; // E9
const E12 = 1_000_000_000_000; // E12
const E15 = 1_000_000_000_000_000; // E15
const abs = n => n < 0 ? 0 - n : n;
/**

@@ -28,4 +42,6 @@ * Get an integer absolute of a number

};
/**
*
* applicable for smaller number
* @param {number} x

@@ -35,6 +51,20 @@ * @returns {number}

const intExpon = x => ~~Math.log10(x);
const round = x => x + (x > 0 ? 0.5 : -0.5) << 0;
const roundD1 = x => Math.round(x * 10) / 10;
const roundD2 = x => Math.round(x * E2) / E2;
const roundD3 = x => Math.round(x * E3) / E3;
const roundD4 = x => Math.round(x * E4) / E4;
const almostEquals = (x, y, epsilon) => Math.abs(x - y) < epsilon;
const almostInt = (x, epsilon) => Math.abs(x - round(x)) < epsilon;
export { E2, E4, MILLION, abs, almostEquals, almostInt, constraint, intAbs, intExpon, round, roundD1, roundD2, roundD4 };
const constraint = (x, min, max) => x > max ? max : x < min ? min : x;
/**
*
* @param {number} x
* @returns {number}
*/
const intExpon = x => ~~Math.log10(x);
export { E1, E10, E11, E12, E13, E14, E15, E2, E3, E4, E5, E6, E7, E8, E9, abs, almostEquals, almostInt, constraint, intAbs, intExpon, round, roundD1, roundD2, roundD3, roundD4 };
{
"name": "@aryth/math",
"version": "0.3.19",
"version": "0.3.20",
"description": "A math util library",

@@ -32,3 +32,3 @@ "main": "dist/index.cjs.js",

"homepage": "https://github.com/hoyeungw/aryth#readme",
"gitHead": "577f88905f3e56b09bdd5680ecc8d91d68697931"
"gitHead": "227c4f9de2905851b0b403453942fe4c3a3ea01a"
}
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