forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wnumb.d.ts
86 lines (79 loc) · 2.22 KB
/
wnumb.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Type definitions for nouislider v1.0.0
// Project: https://github.com/leongersen/wnumb
// Definitions by: Corey Jepperson <https://github.com/acoreyj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var wNumb: wNumb;
interface wNumbOptions {
/**
* decimals The number of decimals to include in the result. Limited to 7.
*/
decimals?: number;
/**
* The decimal separator.
* Defaults to '.' if thousand isn't already set to '.'.
*/
mark?: string;
/**
* Separator for large numbers. For example: ' ' would result in a formatted number of 1 000 000.
*/
thousand?: string;
/**
* A string to prepend to the number. Use cases include prefixing with money symbols such as '$' or '€'.
*/
prefix?: string;
/**
* A number to append to a number. For example: ',-'.
*/
postfix?: string;
/**
* The prefix for negative values. Defaults to '-' if negativeBefore isn't set.
*/
negative?: string;
/**
* The prefix for a negative number. Inserted before prefix.
*/
negativeBefore?: string;
/**This is a powerful option to manually modify the slider output.
*
*For example, to show a number in another currency:
* function( value ){
* return value * 1.32;
* }
*/
encoder?: (value: number) => number;
/**
* Reverse the operations set in encoder.
* Use this option to undo modifications made while encoding the value.
* function( value ){
* return value / 1.32;
* }
*/
decoder?: (value: number) => number;
/**
* Similar to encoder, but applied after all other formatting options are applied.
*/
edit?: (value: number) => number;
/**
* Similar to decoder and the reverse for edit.
* Applied before all other formatting options are applied.
*/
undo?: (value: number) => number;
}
interface wNumb {
/**
* Create a wNumb
*
* @param options - the options
*/
(options?: wNumbOptions): wNumbInstance;
}
interface wNumbInstance {
/**
* format to string
*/
to(val: number): string;
/**
* get number from formatted string
*/
from(val: string): number;
}