Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A helper for pausing functions.

License

NotificationsYou must be signed in to change notification settings

kaaninel/asynclock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A helper for pausing functions.

Example Usage

constasynclock=require("asynclock")constal=asynclock();constsend=(data)=>{constRandom=123;// Generate Random IDconstPack=JSON.stringify({id:Random, data});// Pack Data with Id// Send Data Package// Socket.send(Pack);setTimeout(function(){onmessage(Pack);},1000);// For simulating response// Return Lockreturnal.Lock(Random);}constonmessage=(Pack)=>{constUnpacked=JSON.parse(Pack);al.UnLock(Unpacked.id,Unpacked.data);}consttest=asyncfunction(){constretValue=awaitsend({query:"getUsers"});console.log("retValue",retValue);}test();

Library

{Lock:function(Id){},// (Promise) call when you need to pauseUnLock:function(Id,Value){}// (undefined) call when you need to continue}

Id can be any javascript object key.

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp