@requestnetwork/utils
Advanced tools
Comparing version 0.30.1-next.1391 to 0.30.1-next.1392
import { RequestLogicTypes } from '@requestnetwork/types'; | ||
import * as BigNumber from 'bn.js'; | ||
declare const _default: { | ||
@@ -18,3 +19,3 @@ add: typeof add; | ||
*/ | ||
declare function isValid(amount: RequestLogicTypes.Amount): boolean; | ||
declare function isValid(amount: RequestLogicTypes.Amount | BigNumber): boolean; | ||
/** | ||
@@ -21,0 +22,0 @@ * Function to add an amount by another |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("./utils"); | ||
const bigNumber = require('bn.js'); | ||
const BigNumber = require("bn.js"); | ||
/** | ||
@@ -23,3 +23,3 @@ * Function to manage amounts | ||
return ((utils_1.default.isString(amount) && regexInteger.test(amount)) || | ||
(typeof amount === 'number' && (Number.isSafeInteger(Number(amount)) && Number(amount) >= 0))); | ||
(typeof amount === 'number' && Number.isSafeInteger(Number(amount)) && Number(amount) >= 0)); | ||
} | ||
@@ -41,4 +41,4 @@ /** | ||
} | ||
const amountBN = new bigNumber(amount); | ||
const deltaBN = new bigNumber(delta); | ||
const amountBN = new BigNumber(amount); | ||
const deltaBN = new BigNumber(delta); | ||
return amountBN.add(deltaBN).toString(); | ||
@@ -63,4 +63,4 @@ } | ||
} | ||
const amountBN = new bigNumber(amount); | ||
const deltaBN = new bigNumber(delta); | ||
const amountBN = new BigNumber(amount); | ||
const deltaBN = new BigNumber(delta); | ||
const newAmount = amountBN.sub(deltaBN).toString(); | ||
@@ -67,0 +67,0 @@ // Check if the new amount is valid (basically it is not negative) |
@@ -0,1 +1,2 @@ | ||
/// <reference types="bn.js" /> | ||
/// <reference types="node" /> | ||
@@ -7,3 +8,3 @@ import SimpleLogger from './simple-logger'; | ||
add: (amount: import("@requestnetwork/types/dist/request-logic-types").Amount, delta: import("@requestnetwork/types/dist/request-logic-types").Amount) => string; | ||
isValid: (amount: import("@requestnetwork/types/dist/request-logic-types").Amount) => boolean; | ||
isValid: (amount: string | number | import("bn.js")) => boolean; | ||
reduce: (amount: import("@requestnetwork/types/dist/request-logic-types").Amount, delta: import("@requestnetwork/types/dist/request-logic-types").Amount) => string; | ||
@@ -10,0 +11,0 @@ }; |
{ | ||
"name": "@requestnetwork/utils", | ||
"version": "0.30.1-next.1391+f6489c22", | ||
"version": "0.30.1-next.1392+b953d323", | ||
"publishConfig": { | ||
@@ -43,3 +43,3 @@ "access": "public" | ||
"dependencies": { | ||
"@requestnetwork/types": "0.30.1-next.1391+f6489c22", | ||
"@requestnetwork/types": "0.30.1-next.1392+b953d323", | ||
"bn.js": "5.1.3", | ||
@@ -65,3 +65,3 @@ "eth-crypto": "1.8.0" | ||
}, | ||
"gitHead": "f6489c22c8af1776aadd730ae4b0e84995cf44a3" | ||
"gitHead": "b953d3236b80de4f7d680b30030789f97c24b82a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
134872
1652