文件名称:semaphore:基于小承诺的信号量库
文件大小:4KB
文件格式:ZIP
更新时间:2024-05-28 20:37:13
JavaScript
节点/浏览器的库。 入口点是ESM。 原料药 import make_semaphore from '@trex-arms/semaphore' const delay_1s = ( ) => new Promise ( resolve => setTimeout ( resolve , 1000 ) ) const semaphore = make_semaphore ( 2 ) const do_stuff = async ( ) => { const unlock = await semaphore . lock ( ) console . log ( `Totally doing work!` ) await delay_1s ( ) unlock ( ) } do_stuff ( ) // will start work right away do_stuff ( )
【文件预览】:
semaphore-master
----.gitignore(13B)
----p_defer.mjs(180B)
----package.json(615B)
----package-lock.json(5KB)
----index.mjs(546B)
----test.mjs(2KB)
----readme.md(1KB)