lock-promise

1.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i lock-promise

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.19 kB

Total Files

3

Last publish

Collaborators

  • jishunyu