| Conditions | 2 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | 7 | import { Executor } from '@/core/executor'; |
|
| 4 | |||
| 5 | /** |
||
| 6 | * Assigns an execution order to a method |
||
| 7 | * @param order {number} |
||
| 8 | * @decorator |
||
| 9 | */ |
||
| 10 | 7 | export function Order<This>( |
|
| 11 | order: number, |
||
| 12 | ) { |
||
| 13 | 3 | return ( |
|
| 14 | method: AnyMethod, |
||
| 15 | _context: ClassMethodDecoratorContext<This, AnyMethod>, |
||
| 16 | ) => { |
||
| 17 | 3 | Executor.setExecution('register', () => { |
|
| 18 | 3 | const task = Executor.getTask(method); |
|
| 19 | 3 | if (task) { |
|
| 20 | 2 | task.order = order; |
|
| 21 | } else { |
||
| 22 | 1 | throw new Error('Method not registered for execution'); |
|
| 23 | } |
||
| 24 | }); |
||
| 25 | 3 | return method; |
|
| 26 | }; |
||
| 28 |