文件名称:Hapax:在给定的上下文中仅运行一次函数
文件大小:2KB
文件格式:ZIP
更新时间:2024-05-30 05:47:26
JavaScript
哈帕克斯 轻松确保长时间运行的重复任务不会相互重叠。 npm i hapax-fn const myLongJob = ( ) => { return new Promise ( ( resolve ) => { // resolve the promise after 60 seconds to simulate a long running job setTimeout ( ( ) => resolve ( ) , 1000 * 60 ) ; } ) ; } ; const job = new Hapax ( myLongJob ) ; // The hapax job will only run if it is not already running setInterval ( ( ) => { job . run ( ) ; } , 1000 )
【文件预览】:
Hapax-master
----.gitignore(47B)
----hapax.js(351B)
----package.json(532B)
----index.js(58B)
----README.md(451B)