1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | Promise.resolve(1) .tap(console.log) .then(v => v + 1) .then(console.log); Promise.resolve({ sayHi: () => 'hi', }).call('sayHi').then(console.log); Promise.resolve({ a: 'hello', b: 1, }).get('b').then(console.log); Promise.resolve(1) .return(2) .then(console.log); Promise.resolve(1) .throw(new TypeError('type error')) .catch(console.error); Promise.reject(new TypeError('type error')) .catchReturn('default value') .then(console.log); |
1 2 3 4 | Promise.reject(new TypeError('error')) .then(console.log); process.on('unhandledRejection', (reason, promise) => console.error(`unhandled ${reason} |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |