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

bignumberify

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bignumberify - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

12

index.js

@@ -10,6 +10,14 @@ const ethers = require("ethers");

};
const convert = (bn) => {
try {
bn = ethers.BigNumber.from(bn.hex);
} catch(e) {
// if it looks like a BigNumber but it is not
}
return bn;
}
const manage = (item, i) => {
if (isObject(item[i])) {
if (isBN(item[i])) {
item[i] = ethers.BigNumber.from(item[i].hex);
item[i] = convert(item[i]);
} else {

@@ -28,3 +36,3 @@ item[i] = bigNumberify(item[i]);

if (isBN(obj)) {
obj = ethers.BigNumber.from(obj.hex);
obj = convert(obj);
} else

@@ -31,0 +39,0 @@ for (let i in obj) {

2

package.json
{
"name": "bignumberify",
"version": "0.0.2",
"version": "0.0.3",
"description": "A parser to correctly recreate BigNumber items in a JSON",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/sullof/bignumberify#readme",

@@ -43,2 +43,5 @@ # bigNumberify

**0.0.3**
- Ignore object that look like a BigNumber but they are not
**0.0.2**

@@ -45,0 +48,0 @@ - No real change. Just a better README

@@ -53,2 +53,21 @@ const { assert } = require("chai");

});
it("should skip not-real BigNumber in the JSON", async function () {
let jsonStr = JSON.stringify(obj);
let bad = JSON.parse(jsonStr);
bad.e[0] = {
type: "BigNumber",
hex: "some wrong stuff"
}
let good = bigNumberify(bad);
assert.isTrue(ethers.BigNumber.isBigNumber(good.h));
assert.equal(good.b.c.toString(), "10");
assert.equal(good.e[0].hex, "some wrong stuff");
assert.equal(good.e[1].f.toString(), "30");
assert.equal(good.e[1].g[5].toString(), "40");
assert.equal(good.h.toString(), "50");
});
});
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