mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add typedefinition money-math
This commit is contained in:
parent
73218af4d7
commit
8e32bbb4b6
21
types/money-math/index.d.ts
vendored
Normal file
21
types/money-math/index.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Type definitions for money-math 2.5
|
||||
// Project: https://github.com/ikr/money-math#readme
|
||||
// Definitions by: taoqf <https://github.com/taoqf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace Money;
|
||||
|
||||
export function add(a: string, b: string): string;
|
||||
export function subtract(a: string, b: string): string;
|
||||
export function mul(a: string, b: string): string;
|
||||
export function div(a: string, b: string): string;
|
||||
export function percent(a: string, b: string): string;
|
||||
export function cmp(a: string, b: string): 0 | 1 | -1;
|
||||
export function isEqual(a: string, b: string): boolean;
|
||||
export function isZero(value: string): boolean;
|
||||
export function isNegative(value: string): boolean;
|
||||
export function isPositive(value: string): boolean;
|
||||
export function floatToAmount(value: number): string;
|
||||
export function format(currency: 'CHF' | 'CNY' | 'EUR' | 'GBP' | 'JPY' | 'LTL' | 'PLN' | 'SEK' | 'SKK' | 'UAH' | 'USD' | string, value: string): string;
|
||||
export function roundUpTo5Cents(value: string): string;
|
||||
export function roundTo5Cents(value: string): string;
|
||||
18
types/money-math/money-math-tests.ts
Normal file
18
types/money-math/money-math-tests.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import * as money from 'money-math';
|
||||
|
||||
money.add("16.11", "17.07"); // "33.18"
|
||||
money.subtract("16.00", "7.00"); // "9.00"
|
||||
money.mul("24.00", "0.25"); // "6.00"
|
||||
money.div("64.00", "2.00"); // "32.00"
|
||||
money.percent("200.00", "3.25"); // "6.50"
|
||||
money.cmp("100.00", "200.00"); // -1
|
||||
money.isEqual("100.00", "100.00"); // true
|
||||
money.isZero("0.00"); // true
|
||||
money.isNegative("-1.00"); // true
|
||||
money.isPositive("-1.00"); // false
|
||||
|
||||
money.format("JPY", "236800.00"); // "236,800"
|
||||
money.floatToAmount(56.345); // "56.35"
|
||||
|
||||
money.roundUpTo5Cents("42.02"); // "42.05"
|
||||
money.roundTo5Cents("442.26"); // "442.25"
|
||||
23
types/money-math/tsconfig.json
Normal file
23
types/money-math/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"money-math-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/money-math/tslint.json
Normal file
1
types/money-math/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user