UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

24 lines (22 loc) 598 B
function findCurrentStage(list, now) { if (!(list === null || list === void 0 ? void 0 : list.length)) { return {}; } if (now < list[0].start_time) { return list[0]; } if (now > list[list.length - 1].end_time) { return list[list.length - 1]; } for (var i = 0; i < list.length; i++) { var stage = list[i]; if (now > stage.start_time && now < stage.end_time) { return stage; } if (list[i + 1] && now > stage.end_time && now < list[i + 1].start_time) { return list[i + 1]; } } return list[list.length - 1]; } export { findCurrentStage };