Skip to content

Commit

Permalink
Merge pull request #23 from vend/typescript
Browse files Browse the repository at this point in the history
Add TypeScript types, update bignumber.js
  • Loading branch information
edsrzf authored Jun 21, 2018
2 parents 72ad987 + 029fe31 commit 253745a
Show file tree
Hide file tree
Showing 3 changed files with 2,738 additions and 1 deletion.
32 changes: 32 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
declare module 'vend-number' {
import { BigNumber, RoundingMode } from 'bignumber.js'

interface Stringable {
toString(): string
}

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

static readonly ROUNDING_MODES: {
ROUND_UP: RoundingMode,
ROUND_DOWN: RoundingMode,
ROUND_CEIL: RoundingMode,
ROUND_FLOOR: RoundingMode,
ROUND_HALF_UP: RoundingMode,
ROUND_HALF_DOWN: RoundingMode,
ROUND_HALF_EVEN: RoundingMode,
ROUND_HALF_CEIL: RoundingMode,
ROUND_HALF_FLOOR: RoundingMode
}

static vn(value?: Stringable): VendNumber
static round(value?: Stringable, decimalPoints?: number, roundingMode?: RoundingMode): string
static add(...values: Stringable[]): number
static subtract(...values: Stringable[]): number
static multiply(...values: Stringable[]): number
static divide(...values: Stringable[]): number
static sumBy<T, K extends keyof T>(collection: T[], property: K, decimalPoints: number): string
static isFinite(value: number | string | BigNumber): boolean
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "3.0.1",
"description": "A collection of utility methods for floating point Number operations",
"main": "dist/vend-number.js",
"types": "./index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/vend/vend-number.git"
Expand Down Expand Up @@ -40,7 +41,7 @@
],
"license": "MIT",
"dependencies": {
"bignumber.js": "~4.0.2"
"bignumber.js": "5.0.0"
},
"devDependencies": {
"babel": "~5.8.23",
Expand Down
Loading

0 comments on commit 253745a

Please sign in to comment.