refactor(web): 去冗余 cast(idx.valueOf / dict[error] as string)
stream/sse.ts SseFrameBuffer 去 idx.valueOf()(idx 本就是 number);jobs/job.ts 去 dict["error"] as string(typeof 守卫后 TS 自动收窄)。typecheck 绿。
This commit is contained in:
@@ -85,7 +85,7 @@ export class SseFrameBuffer {
|
||||
let idx: number;
|
||||
// 块之间以空行(\n\n,兼容 \r\n\r\n)分隔。
|
||||
while ((idx = this.findBoundary(this.buf)) !== -1) {
|
||||
const block = this.buf.slice(0, idx.valueOf());
|
||||
const block = this.buf.slice(0, idx);
|
||||
this.buf = this.buf.slice(this.boundaryEnd(this.buf, idx));
|
||||
const evt = parseSseBlock(block);
|
||||
if (evt) events.push(evt);
|
||||
|
||||
Reference in New Issue
Block a user