1.0.0 • Published 2 years ago

lock-promise v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Example

You could use like this:

    lockPromise({lockOthers: true,callback:()=>{
        console.log('error 锁请求1');
    }},async ()=>{
        const res = await promise('锁请求1',5000)
        console.log('锁请求1');
    })
    lockPromise({lockOthers: true, callback: async () => {
        const res = await promise('error 锁请求2',3000)
        console.log(res);
    }},async ()=>{
        const res = await promise('锁请求2',3000)
        console.log('锁请求2',1111);
        console.log(a);
    })

    lockPromise(undefined,async ()=>{
        console.log('非锁请求');
    })

    function promise(name,time){
        return new Promise(resolve=>{
            setTimeout(() => {
                resolve(name)
            }, time);
        })
    }
    // log
    // 锁请求2 1111
    // 锁请求1
    // error 锁请求2