File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 3
3
"version" : " 1.1.8" ,
4
4
"description" : " React timer hook is a custom react hook built to handle timers(countdown), stopwatch and time logic/state in your react component." ,
5
5
"main" : " dist/index.js" ,
6
+ "types" : " dist/index.d.ts" ,
6
7
"scripts" : {
7
8
"build:dev" : " webpack --config webpack.dev.js && webpack-dev-server --open --config webpack.dev.js" ,
8
- "build:prod" : " rm -rf ./dist && webpack --config webpack.prod.js"
9
+ "build:prod" : " rm -rf ./dist && webpack --config webpack.prod.js && cpy src/index.d.ts dist/index.d.ts "
9
10
},
10
11
"repository" : {
11
12
"type" : " git" ,
40
41
"babel-preset-react" : " ^6.24.1" ,
41
42
"babel-preset-stage-1" : " ^6.24.1" ,
42
43
"copy-webpack-plugin" : " ^4.6.0" ,
44
+ "cpy-cli" : " ^3.0.0" ,
43
45
"react" : " ^16.8.0" ,
44
46
"react-dom" : " 16.8.0" ,
45
47
"webpack" : " ^4.24.0" ,
Original file line number Diff line number Diff line change
1
+ interface TimerSettings {
2
+ expiryTimestamp : number ;
3
+ onExpire ?: ( ) => void ;
4
+ }
5
+
6
+ interface TimerResult {
7
+ seconds : number ;
8
+ minutes : number ;
9
+ hours : number ;
10
+ days : number ;
11
+ start : ( ) => void ;
12
+ pause : ( ) => void ;
13
+ resume : ( ) => void ;
14
+ restart : ( newExpiryTimestamp : number ) => void ;
15
+ }
16
+
17
+ export function useTimer ( settings : TimerSettings ) : TimerResult
18
+
19
+ interface StopwatchSettings {
20
+ autoStart ?: boolean ;
21
+ }
22
+
23
+ interface StopwatchResult {
24
+ seconds : number ;
25
+ minutes : number ;
26
+ hours : number ;
27
+ days : number ;
28
+ start : ( ) => void ;
29
+ pause : ( ) => void ;
30
+ reset : ( ) => void ;
31
+ }
32
+
33
+ export function useStopwatch ( settings ?: StopwatchSettings ) : StopwatchResult
34
+
35
+ interface TimeSettings {
36
+ format ?: '12-hour' ;
37
+ }
38
+
39
+ interface TimeResult {
40
+ seconds : number ;
41
+ minutes : number ;
42
+ hours : number ;
43
+ ampm : '' | 'pm' | 'am' ;
44
+ }
45
+
46
+ export function useTime ( settings ?: TimeSettings ) : TimeResult
You can’t perform that action at this time.
0 commit comments