1.1.2 • Published 2 years ago

ydao v1.1.2

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

Function are

函数作用

compose function 将多个函数进行组合,支持async/promise

Using the example

使用例子

let {yili}= require('ydao')

 function a() {
    return  new Promise((res, rej) => {
        setTimeout(() => {
            rej();
            // res(22, 2);
        }, 300);
    })
}

function b(v, q) {
    console.log(v, q, 'vvb');
    return 'b'
}

let qq = yili("a-scope", a, 'b-scope', () => { throw new Error(22); console.log(qqqq); return 22 }, 'a-scope', 'b-scope', b);

qq.catch('a', async ({err, next, rej}) => {
    console.log(err, 'a报错', '根据对应函数名捕获');    
    next('a报错');//向后执行
})

qq.catch(1, async ({err, next, rej}) => {
    console.log(err, '匿名函数报错', '根据对应函数位置捕获');
    next('报错')//向后执行
})


r.scopecatch('a-scope',({err,i})=>{
    console.log(err,'a-scope范围内有错误')
})

qq.on('a-scope:end', (s, n) => {
    console.log(s, 222, n, 'end')
})



qq(33)
    .then((c) => {
        console.log('成功' + c)
    })
    .catch(a => {
        console.log('错误')
    })
1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago