Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Search 的 output 函数可以写成迭代器的形式, 这样增强可读性. #3

@hzhangxyz

Description

@hzhangxyz
this.engine.output((result: string) => {
    data.push(result); // 添加到待推送列表(结果已由 engine.output 自动保存)
    console.log(`Found data: ${result}`);
    return false; // 继续搜索
});

变成

for (const result : this.engine.output()) { // 直接调用execute()实现新的output
    data.push(result); // 添加到待推送列表(结果已由 engine.output 自动保存)
    console.log(`Found data: ${result}`);
}

由于我们使用方式的需要, output中的callback必须return false的, 不然会破坏数据结构.

所以我在此说明一下break的行为: 如果break, 则下次调用output(), 会继续上次的一次execute.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions