3.0.15 • Published 9 months ago

@glif/filecoin-number v3.0.15

Weekly downloads
333
License
(Apache-2.0 OR MI...
Repository
github
Last release
9 months ago

Filecoin number

A wrapper class built around javascript's bignumber. Most questions are best answered from the bignumber readme and docs.

FilecoinNumber Usage

import { FilecoinNumber, Converter } from '@glif/filecoin-number'

// pass a valid bignumber argument, and a denomination ('fil', 'picofil', or 'attofil') to the constructor.
const filecoinNumber = new FilecoinNumber('10000', 'attofil')

// filecoinNumber is an instance of BigNumber, so you can use it as such
filecoinNumber.multiply(7)

// it comes with 2 additional instance methods for showing the filecoin number as a string in attofil or fil
const inPicoFil = filecoinNumber.toPicoFil()
const inAttoFil = filecoinNumber.toAttoFil()
const inFil = filecoinNumber.toFil()

Converter Usage

// Use the Converter to convert currencies
const optionalConfig = {
  apiURL: 'https://coinmarketproxy.com',
  apiKey: 'RIP Kobe',
}

const USDConverter = new Converter('USD', optionalConfig)

await USDConverter.cacheConversionRate()

const USD = USDConverter.fromFIL(1)
const FIL = USDConverter.toFIL(1)

// fromFIL and toFIL take numbers, strings, BigNumbers, and FilecoinNumbers as valid args
const USD = USDConverter.fromFIL(1)
const USD = USDConverter.fromFIL('1')
const USD = USDConverter.fromFIL(new BigNumber(1))
const USD = USDConverter.fromFIL(new FilecoinNumber('1', 'fil'))

Running tests locally

We use an APIADDR environment variable in the tests. You can either: (a) add the APIADDR environment variable locally, or (b) use a secrets.js file to export private information

3.0.15

9 months ago

3.0.8

12 months ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.0

1 year ago

2.0.74

2 years ago

2.0.71

2 years ago

2.0.72

2 years ago

2.0.70

2 years ago

2.0.68

2 years ago

2.0.69

2 years ago

2.0.67

2 years ago

2.0.66

2 years ago

2.0.64

2 years ago

2.0.65

2 years ago

2.0.62

2 years ago

2.0.63

2 years ago

2.0.60

2 years ago

2.0.57

2 years ago

2.0.56

2 years ago

2.0.53

2 years ago

2.0.54

2 years ago

2.0.51

2 years ago

2.0.52

2 years ago

2.0.50

2 years ago

2.0.39

2 years ago

2.0.48

2 years ago

2.0.49

2 years ago

2.0.47

2 years ago

2.0.45

2 years ago

2.0.34

2 years ago

2.0.5

3 years ago

2.0.1

3 years ago

2.0.0-beta.16

3 years ago

2.0.0-alpha.11

3 years ago

2.0.0-alpha.10

3 years ago

2.0.0-beta.0

3 years ago

2.0.0-alpha.13

3 years ago

1.1.0

4 years ago

1.1.0-beta.19

4 years ago

1.1.0-beta.17

4 years ago

1.1.0-beta.14

4 years ago

1.1.0-beta.11

5 years ago

1.1.0-beta.10

5 years ago

1.1.0-beta.9

5 years ago

1.1.0-beta.7

5 years ago

1.1.0-beta.2

5 years ago

1.1.0-beta.1

5 years ago

1.1.0-beta.0

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-lerna.4

5 years ago

1.0.0-lerna.2

5 years ago