Skip to content

Commit

Permalink
Merge pull request #24 from vend/hax-up-ts-definition
Browse files Browse the repository at this point in the history
Copy and paste RoundingMode type since it's not exported
  • Loading branch information
Wal8800 authored Jul 25, 2018
2 parents 4a4ac7c + 05c0bd3 commit 4517f80
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
declare module 'vend-number' {
import { BigNumber, RoundingMode } from 'bignumber.js'
import { BigNumber } from 'bignumber.js'

interface Stringable {
toString(): string
}

declare export default class VendNumber extends BigNumber {
// RoundingMode is not exported in bignumber.js 5.0.0 so have to copy and paste the declaration from bignumber.js to
// here in order to use the type. RoundingMode is available in bignumber.js 6.0.0+
enum RoundingMode {
/** Rounds away from zero */
ROUND_UP = 0,
/** Rounds towards zero */
ROUND_DOWN = 1,
/** Rounds towards Infinity */
ROUND_CEIL = 2,
/** Rounds towards -Infinity */
ROUND_FLOOR = 3,
/**
* Rounds towards nearest neighbour. If equidistant, rounds away from zero
*/
ROUND_HALF_UP = 4,
/**
* Rounds towards nearest neighbour. If equidistant, rounds towards zero
*/
ROUND_HALF_DOWN = 5,
/**
* Rounds towards nearest neighbour. If equidistant, rounds towards even neighbour
*/
ROUND_HALF_EVEN = 6,
/**
* Rounds towards nearest neighbour. If equidistant, rounds towards `Infinity`
*/
ROUND_HALF_CEIL = 7,
/**
* Rounds towards nearest neighbour. If equidistant, rounds towards `-Infinity`
*/
ROUND_HALF_FLOOR = 8,
/**
* The remainder is always positive. Euclidian division: `q = sign(n) * floor(a / abs(n))`
*/
EUCLID = 9
}

export default class VendNumber extends BigNumber {
constructor (value?: Stringable)

static readonly ROUNDING_MODES: {
Expand Down

0 comments on commit 4517f80

Please sign in to comment.