Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 0eb4c61

Browse files
hugomrdiasAlan Shaw
authored andcommitted
refactor: change from big to bignumber (#419)
1 parent b0f463e commit 0eb4c61

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

SPEC/BITSWAP.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ Note: `bitswap.stat` and `stats.bitswap` can be used interchangeably.
4545
- `provideBufLen` is an integer.
4646
- `wantlist` (array of CIDs)
4747
- `peers` (array of peer IDs)
48-
- `blocksReceived` is a [Big Int][1]
49-
- `dataReceived` is a [Big Int][1]
50-
- `blocksSent` is a [Big Int][1]
51-
- `dataSent` is a [Big Int][1]
52-
- `dupBlksReceived` is a [Big Int][1]
53-
- `dupDataReceived` is a [Big Int][1]
48+
- `blocksReceived` is a [BigNumber Int][1]
49+
- `dataReceived` is a [BigNumber Int][1]
50+
- `blocksSent` is a [BigNumber Int][1]
51+
- `dataSent` is a [BigNumber Int][1]
52+
- `dupBlksReceived` is a [BigNumber Int][1]
53+
- `dupDataReceived` is a [BigNumber Int][1]
5454

5555
If no `callback` is passed, a promise is returned.
5656

@@ -73,4 +73,4 @@ ipfs.bitswap.stat((err, stats) => console.log(stats))
7373
// dupDataReceived: 0 }
7474
```
7575

76-
[1]: https://github.com/MikeMcl/big.js/
76+
[1]: https://github.com/MikeMcl/bignumber.js/

SPEC/REPO.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ Where:
4545

4646
`callback` must follow `function (err, stats) {}` signature, where `err` is an Error if the operation was not successful and `stats` is an object containing the following keys:
4747

48-
- `numObjects` is a [Big Int][1].
49-
- `repoSize` is a [Big Int][1], in bytes.
48+
- `numObjects` is a [BigNumber Int][1].
49+
- `repoSize` is a [BigNumber Int][1], in bytes.
5050
- `repoPath` is a string.
5151
- `version` is a string.
52-
- `storageMax` is a [Big Int][1].
52+
- `storageMax` is a [BigNumber Int][1].
5353

5454
If no `callback` is passed, a promise is returned.
5555

@@ -85,4 +85,4 @@ ipfs.repo.version((err, version) => console.log(version))
8585
// "6"
8686
```
8787

88-
[1]: https://github.com/MikeMcl/big.js/
88+
[1]: https://github.com/MikeMcl/bignumber.js/

SPEC/STATS.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Where:
3838

3939
`stat` is, in both cases, an Object containing the following keys:
4040

41-
- `totalIn` - is a [Big Int][big], in bytes.
42-
- `totalOut` - is a [Big Int][big], in bytes.
43-
- `rateIn` - is a [Big Int][big], in bytes.
44-
- `rateOut` - is a [Big Int][big], in bytes.
41+
- `totalIn` - is a [BigNumber Int][bigNumber], in bytes.
42+
- `totalOut` - is a [BigNumber Int][bigNumber], in bytes.
43+
- `rateIn` - is a [BigNumber Int][bigNumber], in bytes.
44+
- `rateOut` - is a [BigNumber Int][bigNumber], in bytes.
4545

4646
If no `callback` is passed, a promise is returned.
4747

@@ -50,10 +50,10 @@ If no `callback` is passed, a promise is returned.
5050
```JavaScript
5151
ipfs.stats.bw((err, stats) => console.log(stats))
5252

53-
// { totalIn: Big {...},
54-
// totalOut: Big {...},
55-
// rateIn: Big {...},
56-
// rateOut: Big {...} }
53+
// { totalIn: BigNumber {...},
54+
// totalOut: BigNumber {...},
55+
// rateIn: BigNumber {...},
56+
// rateOut: BigNumber {...} }
5757
```
5858

5959
#### `stats.bwPullStream`
@@ -79,10 +79,10 @@ pull(
7979
log()
8080
)
8181

82-
// { totalIn: Big {...},
83-
// totalOut: Big {...},
84-
// rateIn: Big {...},
85-
// rateOut: Big {...} }
82+
// { totalIn: BigNumber {...},
83+
// totalOut: BigNumber {...},
84+
// rateIn: BigNumber {...},
85+
// rateOut: BigNumber {...} }
8686
// ...
8787
// Ad infinitum
8888
```
@@ -106,14 +106,14 @@ stream.on('data', (data) => {
106106
console.log(data)
107107
}))
108108

109-
// { totalIn: Big {...},
110-
// totalOut: Big {...},
111-
// rateIn: Big {...},
112-
// rateOut: Big {...} }
109+
// { totalIn: BigNumber {...},
110+
// totalOut: BigNumber {...},
111+
// rateIn: BigNumber {...},
112+
// rateOut: BigNumber {...} }
113113
// ...
114114
// Ad infinitum
115115
```
116116

117-
[big]: https://github.com/MikeMcl/big.js/
117+
[bigNumber]: https://github.com/MikeMcl/bignumber.js/
118118
[rs]: https://www.npmjs.com/package/readable-stream
119119
[ps]: https://www.npmjs.com/package/pull-stream

js/src/stats/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const { expect } = require('../utils/mocha')
44

55
const isBigInt = (n) => {
6-
return n.constructor.name === 'Big'
6+
return n.constructor.name === 'BigNumber'
77
}
88

99
exports.expectIsBitswap = (err, stats) => {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"homepage": "https://github.com/ipfs/interface-ipfs-core#readme",
3838
"dependencies": {
3939
"async": "^2.6.1",
40-
"big.js": "^5.2.2",
4140
"bl": "^2.1.2",
4241
"bs58": "^4.0.1",
4342
"chai": "^4.2.0",
@@ -49,7 +48,7 @@
4948
"into-stream": "^4.0.0",
5049
"ipfs-block": "~0.8.0",
5150
"ipfs-unixfs": "~0.1.16",
52-
"ipld-dag-cbor": "~0.13.0",
51+
"ipld-dag-cbor": "~0.13.1",
5352
"ipld-dag-pb": "~0.15.0",
5453
"is-ipfs": "~0.4.2",
5554
"is-plain-object": "^2.0.4",

0 commit comments

Comments
 (0)