@requestnetwork/utils
Advanced tools
Comparing version 0.31.0 to 0.31.1-next.1403
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) |
@@ -78,3 +78,3 @@ "use strict"; | ||
const hash = keccak256Hash(normalize(data)); | ||
// tslint:disable-next-line:no-magic-numbers | ||
// eslint-disable-next-line no-magic-numbers | ||
return `0x${hash.slice(-40)}`; | ||
@@ -92,3 +92,2 @@ } | ||
} | ||
// eslint-disable-next-line spellcheck/spell-checker | ||
/** | ||
@@ -95,0 +94,0 @@ * Generate 8 random bytes and return as a hexadecimal string. |
@@ -37,3 +37,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// tslint:disable-next-line:no-magic-numbers | ||
// eslint-disable-next-line no-magic-numbers | ||
return randomBytes(32); | ||
@@ -40,0 +40,0 @@ }); |
@@ -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 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// tslint:disable:no-console | ||
/* eslint-disable no-console */ | ||
const types_1 = require("@requestnetwork/types"); | ||
@@ -93,3 +93,3 @@ // The default log level to use if none is used at the constructor. | ||
checkForSeparator(tags, separator) { | ||
if (tags.some(tag => tag.includes(separator))) { | ||
if (tags.some((tag) => tag.includes(separator))) { | ||
throw new Error(`Log tags can't can't contain ${separator} character`); | ||
@@ -96,0 +96,0 @@ } |
@@ -48,3 +48,3 @@ "use strict"; | ||
if (nestedObject instanceof Array) { | ||
return nestedObject.map(i => deepSort(i)); | ||
return nestedObject.map((i) => deepSort(i)); | ||
} | ||
@@ -51,0 +51,0 @@ // sort data keys |
{ | ||
"name": "@requestnetwork/utils", | ||
"version": "0.31.0", | ||
"version": "0.31.1-next.1403+c3d74ee0", | ||
"publishConfig": { | ||
@@ -36,4 +36,3 @@ "access": "public" | ||
"clean": "shx rm -rf dist tsconfig.tsbuildinfo", | ||
"lint": "tslint --project . && eslint \"src/**/*.ts\"", | ||
"lint-staged": "lint-staged", | ||
"lint": "eslint \"src/**/*.ts\"", | ||
"prepare": "yarn run build", | ||
@@ -44,3 +43,3 @@ "test": "jest", | ||
"dependencies": { | ||
"@requestnetwork/types": "0.31.0", | ||
"@requestnetwork/types": "0.31.1-next.1403+c3d74ee0", | ||
"bn.js": "5.1.3", | ||
@@ -52,8 +51,3 @@ "eth-crypto": "1.8.0" | ||
"@types/jest": "26.0.13", | ||
"@typescript-eslint/parser": "4.1.1", | ||
"eslint": "7.9.0", | ||
"eslint-plugin-spellcheck": "0.0.17", | ||
"eslint-plugin-typescript": "0.14.0", | ||
"jest": "26.4.2", | ||
"lint-staged": "10.3.0", | ||
"prettier": "2.2.1", | ||
@@ -64,6 +58,5 @@ "shx": "0.3.2", | ||
"ts-node": "9.0.0", | ||
"tslint": "6.1.3", | ||
"typescript": "4.1.3" | ||
}, | ||
"gitHead": "07a78b313ce4dc8aefd7c44829b31e275a42a2eb" | ||
"gitHead": "c3d74ee025ab662fbd022f421106a3759d47a23b" | ||
} |
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
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
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9
1651
134953
8
+ Added@types/node@22.13.5(transitive)
- Removed@requestnetwork/types@0.31.0(transitive)
- Removed@types/node@22.13.4(transitive)
- Removedevents@3.2.0(transitive)