@@ -29,6 +29,7 @@ function toPositiveNumber(value) {
29
29
if ( Number . isNaN ( number ) ) {
30
30
return 0 ;
31
31
}
32
+
32
33
return - number ;
33
34
}
34
35
@@ -53,16 +54,17 @@ class Cron {
53
54
if ( isAdm ) {
54
55
return this . runsArg ( args ) ;
55
56
}
56
- return this . runsArg ( args ) ; // 'staff only.'
57
+
58
+ return 'staff only.' ;
57
59
}
58
60
59
61
create ( ) {
60
62
if ( ! ( this . timer > 0 ) ) {
61
63
return 'you must add a valid time' ;
62
64
}
63
- const { message, text, timer } = this ;
64
- counter ++ ;
65
65
66
+ counter ++ ;
67
+ const { message, text, timer } = this ;
66
68
const thread = new Thread ( counter , text , message , timer ) ;
67
69
threads . push ( thread ) ;
68
70
@@ -73,14 +75,14 @@ class Cron {
73
75
if ( ! Cron . isIdValid ( this . text ) ) {
74
76
return 'thread not found' ;
75
77
}
78
+
76
79
const thread = threads . find ( ( t ) => t . id === Number ( this . text ) ) ;
77
80
this . stop ( ) ;
78
81
79
82
emitter . removeAllListeners ( `start-cron${ this . text } ` , thread . start ) ;
80
83
emitter . removeAllListeners ( `stop-cron${ this . text } ` , thread . stop ) ;
81
84
82
85
threads = threads . filter ( ( t ) => ! ( t . id === Number ( this . text ) ) ) ;
83
-
84
86
return 'thread destroyed successfully' ;
85
87
}
86
88
@@ -89,6 +91,7 @@ class Cron {
89
91
emitter . emit ( `start-cron${ this . text } ` ) ;
90
92
return `starting thread ${ this . text } ` ;
91
93
}
94
+
92
95
return 'thread not found' ;
93
96
}
94
97
@@ -97,6 +100,7 @@ class Cron {
97
100
emitter . emit ( `stop-cron${ this . text } ` ) ;
98
101
return `stopping thread ${ this . text } ` ;
99
102
}
103
+
100
104
return 'thread not found' ;
101
105
}
102
106
@@ -135,6 +139,7 @@ class Cron {
135
139
if ( seila [ args [ 0 ] ] ) {
136
140
return seila [ args [ 0 ] ] ( ) ;
137
141
}
142
+
138
143
return Cron . default ( ) ;
139
144
}
140
145
0 commit comments