在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kikito/cron.lua开源软件地址(OpenSource Url):https://github.com/kikito/cron.lua开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):cron.lua
API
Clock methods:
Exampleslocal cron = require 'cron'
local function printMessage()
print('Hello')
end
-- the following calls are equivalent:
local c1 = cron.after(5, printMessage)
local c2 = cron.after(5, print, 'Hello')
c1:update(2) -- will print nothing, the action is not done yet
c1:update(5) -- will print 'Hello' once
c1:reset() -- reset the counter to 0
-- prints 'hey' 5 times and then prints 'hello'
while not c1:update(1) do
print('hey')
end
-- Create a periodical clock:
local c3 = cron.every(10, printMessage)
c3:update(5) -- nothing (total time: 5)
c3:update(4) -- nothing (total time: 9)
c3:update(12) -- prints 'Hello' twice (total time is now 21) Gotchas / Warnings
InstallationJust copy the cron.lua file somewhere in your projects (maybe inside a /lib/ folder) and require it accordingly. Remember to store the value returned by require somewhere! (I suggest a local variable named local cron = require 'cron' Also, make sure to read the license file; the text of that license file must appear somewhere in your projects' files. SpecsThis project uses busted for its specs. If you want to run the specs, you will have to install it first. Then run: cd path/where/the/spec/folder/is
busted |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论