This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 简易洋葱模型 | |
// app.use(next => { | |
// console.log(1) | |
// next() | |
// }) | |
// app.use(next => { | |
// console.log(2) | |
// next() | |
// }) | |
// app.use(next => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 时间切片 generator fn实现 | |
// 包装器 | |
function timeSliceWrapper(task){ | |
if(typeof task !== 'function'){ | |
throw new Error('请输入生成器函数!') | |
} | |
const gen = task() | |
const sliceSize = 25 | |
return function next(){ | |
let start = performance.now() |