New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bignum/template

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bignum/template - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

31

lib/index.js

@@ -17,8 +17,12 @@ // src/index.mts

}
function identity(a) {
return a;
}
function buildEvaluator(evaluateForD, evaluateForB) {
const forB = evaluateForB || evaluateForD;
const forD = (a, b) => evaluateForD(BigNum.valueOf(a), b);
const forB = evaluateForB || forD;
return (a, b) => {
const na = normalize(a);
const nb = normalize(b);
return typeof na === "bigint" && typeof nb === "bigint" ? forB(na, nb) : evaluateForD(na, nb);
return typeof na === "bigint" && typeof nb === "bigint" ? forB(na, nb) : forD(na, nb);
};

@@ -36,3 +40,3 @@ }

function buildOperation(opForD, opForB) {
const forB = opForB || ((a) => a);
const forB = opForB || ((a, ...options) => opForD(BigNum.valueOf(a), ...options));
return (a, ...options) => {

@@ -46,20 +50,20 @@ const na = normalize(a);

"*": buildEvaluator(
(a, b) => BigNum.valueOf(a).multiply(b),
(a, b) => a.multiply(b),
(a, b) => a * b
),
"+": buildEvaluator(
(a, b) => BigNum.valueOf(a).add(b),
(a, b) => a.add(b),
(a, b) => a + b
),
"-": buildEvaluator(
(a, b) => BigNum.valueOf(a).subtract(b),
(a, b) => a.subtract(b),
(a, b) => a - b
),
"/": buildEvaluator((a, b) => BigNum.valueOf(a).divide(b)),
"/": buildEvaluator((a, b) => a.divide(b)),
"%": buildEvaluator(
(a, b) => BigNum.valueOf(a).modulo(b),
(a, b) => a.modulo(b),
(a, b) => a % b
),
"**": buildEvaluator(
(a, b) => BigNum.valueOf(a).pow(b),
(a, b) => a.pow(b),
(a, b) => a ** b

@@ -90,2 +94,3 @@ ),

functions: {
sqrt: buildOperation((a) => a.sqrt()),
abs: buildOperation(

@@ -95,6 +100,6 @@ (a) => a.abs(),

),
trunc: buildOperation((a) => a.trunc()),
round: buildOperation((a) => a.round()),
floor: buildOperation((a) => a.floor()),
ceil: buildOperation((a) => a.ceil())
trunc: buildOperation((a) => a.trunc(), identity),
round: buildOperation((a) => a.round(), identity),
floor: buildOperation((a) => a.floor(), identity),
ceil: buildOperation((a) => a.ceil(), identity)
}

@@ -101,0 +106,0 @@ };

{
"name": "@bignum/template",
"version": "0.1.2",
"version": "0.2.0",
"description": "Write formulas with template literals.",

@@ -51,3 +51,3 @@ "type": "module",

"dependencies": {
"@bignum/core": "^0.3.0",
"@bignum/core": "^0.4.0",
"@bignum/shared": "^0.1.0",

@@ -54,0 +54,0 @@ "@bignum/template-compiler": "^0.1.0"

Sorry, the diff of this file is not supported yet

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