SOURCE

var muts = [];

var res = [];
var firstLen = 3000;
var splitLen = 2000;
var nowBegin = 0;
var nowEnd = firstLen;
var len = 0;

// 处理首片mut
var temp = [];
muts.forEach((mut => {
    if (
        (mut.ty === 'is' || mut.ty === 'ms')
        || (mut.ty === 'mp' && (mut.mt === 'story' || mut.mt === 'section'))
        || (mut.ty === 'mp' && mut.ei <= nowEnd)
    ) {
        temp.push(mut);
        len++;
    }
}));

// 更新begin, end
// nowBegin = nowEnd;
// nowEnd = nowEnd + splitLen;

// 放入首片结果
// res.push(temp);
// temp = [];
// console.log(temp);

var hasFind = true;
// 当前片数
var index = 1;

// 处理后续分片
while(hasFind) {
    index++;
    // 更新begin, end
    nowBegin = nowEnd;
    nowEnd = nowEnd + splitLen;
    // console.log(`第${index}片范围:${nowBegin} - ${nowEnd}`)
    // 是否找到范围内的mut
    hasFind = false;
    res.push(temp);
    temp = [];
    muts.forEach((mut => {
        if (
            mut.ty === 'mp' 
            && mut.bi > nowBegin && mut.ei <= nowEnd
        ) {
            hasFind = true;
            temp.push(mut);
            len++;
        }
    }));
}
console.log(res);
//console.log('mutation分片总数:', len);
console 命令行工具 X clear

                    
>
console