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

@exante/big-decimal

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exante/big-decimal - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

22

lib/bigDecimal.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getFractionalLength_1 = require("./getFractionalLength");
var getFractionalLength_1 = require("./getFractionalLength");
function isNumericValue(n) {

@@ -8,8 +8,8 @@ return !isNaN(Number(n) - parseFloat(n));

function fromBigDec(bigDec) {
const { scale, value } = bigDec;
var scale = bigDec.scale, value = bigDec.value;
if (!isNumericValue(scale) || !isNumericValue(value)) {
throw new Error('fromBigDec: both scale and value must be numeric. ' +
`Instead, ${scale} and ${value} were passed`);
("Instead, " + scale + " and " + value + " were passed"));
}
const floatVal = value * Math.pow(10, (-1 * scale));
var floatVal = value * Math.pow(10, (-1 * scale));
return Number(floatVal.toFixed(Math.abs(scale)));

@@ -20,9 +20,9 @@ }

if (!isNumericValue(numberRaw)) {
throw new Error(`Bad value passed to toBigDec: ${numberRaw}`);
throw new Error("Bad value passed to toBigDec: " + numberRaw);
}
const number = Number(numberRaw);
const scale = getFractionalLength_1.getFractionalLength(numberRaw);
let value;
var number = Number(numberRaw);
var scale = getFractionalLength_1.getFractionalLength(numberRaw);
var value;
if (scale > 0) {
const withoutSymbols = String(number)
var withoutSymbols = String(number)
.split(/[eE]/)[0]

@@ -36,4 +36,4 @@ .replace('.', '');

return {
value,
scale,
value: value,
scale: scale,
};

@@ -40,0 +40,0 @@ }

@@ -7,8 +7,8 @@ "use strict";

*/
const match = String(Number(number)).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
var match = String(Number(number)).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
if (!match) {
return 0;
}
const digitsAfterDot = match[1] ? match[1].length : 0;
const powerOfTen = match[2] ? Number(match[2]) : 0;
var digitsAfterDot = match[1] ? match[1].length : 0;
var powerOfTen = match[2] ? Number(match[2]) : 0;
return Math.max(0, digitsAfterDot - powerOfTen);

@@ -15,0 +15,0 @@ }

{
"name": "@exante/big-decimal",
"version": "1.0.0",
"version": "1.0.1",
"description": "Utility functions to convert numbers to and from big decimal objects.",

@@ -30,2 +30,6 @@ "main": "lib/bigDecimal.js",

"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/exante/big-decimal.git"
},
"devDependencies": {

@@ -32,0 +36,0 @@ "@types/tape": "^4.2.31",

@@ -7,3 +7,3 @@ # BigDecimal number converter

[![version][version-badge]][package]
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

@@ -10,0 +10,0 @@

{
"compilerOptions": {
"target": "es6",
"target": "es5",
"module":"commonjs",

@@ -5,0 +5,0 @@ "lib": ["es2015", "es2016", "es2017"],

Sorry, the diff of this file is not supported yet

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