|
5 | 5 |
|
6 | 6 | local lutetask = require("@lute/task") |
7 | 7 |
|
8 | | -local taskLib = {} |
| 8 | +local task = {} |
9 | 9 |
|
10 | 10 | --- Schedules `routine` to run immediately on the next resumption cycle, passing any additional arguments to it. Returns the thread. |
11 | | -function taskLib.spawn<T..., U...>(routine: ((T...) -> U...) | thread, ...: T...): thread |
| 11 | +function task.spawn<T..., U...>(routine: ((T...) -> U...) | thread, ...: T...): thread |
12 | 12 | return lutetask.spawn(routine, ...) |
13 | 13 | end |
14 | 14 |
|
15 | 15 | --- Schedules `routine` to run after the current thread yields, passing any additional arguments to it. Returns the thread. |
16 | | -function taskLib.defer<T..., U...>(routine: ((T...) -> U...) | thread, ...: T...): thread |
| 16 | +function task.defer<T..., U...>(routine: ((T...) -> U...) | thread, ...: T...): thread |
17 | 17 | return lutetask.defer(routine, ...) |
18 | 18 | end |
19 | 19 |
|
20 | 20 | --- Schedules `routine` to run after `dur` seconds, passing any additional arguments to it. Returns the thread. |
21 | | -function taskLib.delay<T..., U...>(dur: number, routine: ((T...) -> U...) | thread, ...: T...): thread |
| 21 | +function task.delay<T..., U...>(dur: number, routine: ((T...) -> U...) | thread, ...: T...): thread |
22 | 22 | return lutetask.delay(dur, routine, ...) |
23 | 23 | end |
24 | 24 |
|
25 | 25 | --- Yields the current thread for `dur` seconds (or until the next cycle if `dur` is omitted). Returns the actual time waited. |
26 | | -function taskLib.wait(dur: number?): number |
| 26 | +function task.wait(dur: number?): number |
27 | 27 | return lutetask.wait(dur) |
28 | 28 | end |
29 | 29 |
|
30 | 30 | --- Cancels `thread`, preventing it from being resumed again. |
31 | | -function taskLib.cancel(thread: thread) |
| 31 | +function task.cancel(thread: thread) |
32 | 32 | coroutine.close(thread) |
33 | 33 | end |
34 | 34 |
|
35 | | -return table.freeze(taskLib) |
| 35 | +return table.freeze(task) |
0 commit comments