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 33 "version" : " 1.1.8" ,
44 "description" : " React timer hook is a custom react hook built to handle timers(countdown), stopwatch and time logic/state in your react component." ,
55 "main" : " dist/index.js" ,
6+ "types" : " dist/index.d.ts" ,
67 "scripts" : {
78 "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 "
910 },
1011 "repository" : {
1112 "type" : " git" ,
4041 "babel-preset-react" : " ^6.24.1" ,
4142 "babel-preset-stage-1" : " ^6.24.1" ,
4243 "copy-webpack-plugin" : " ^4.6.0" ,
44+ "cpy-cli" : " ^3.0.0" ,
4345 "react" : " ^16.8.0" ,
4446 "react-dom" : " 16.8.0" ,
4547 "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