Skip to content

Commit 761d584

Browse files
committed
feat: progress value to touch functio
1 parent 540b8d6 commit 761d584

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/job/touch.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { JobError } from 'src/utils';
12
import { Job } from '.';
23

34
export type TouchMethod = (progress?: number) => Promise<Job>;
@@ -8,6 +9,9 @@ export type TouchMethod = (progress?: number) => Promise<Job>;
89
* @param progress 0 to 100
910
*/
1011
export const touch: TouchMethod = async function (this: Job, progress?): Promise<Job> {
12+
if (progress && (progress < 0 || progress > 100)) {
13+
throw new JobError('Progress must be a number between 0 and 100');
14+
}
1115
this.attrs.lockedAt = new Date();
1216
this.attrs.progress = progress;
1317
return this.save();

0 commit comments

Comments
 (0)