gpt4 book ai didi

Javascript 停止一个事件

转载 作者:搜寻专家 更新时间:2023-10-31 23:45:55 24 4
gpt4 key购买 nike

有没有可能停止一个事件并强制它结束?

string rows // Correctly formatted csv string.

csv
.fromString(rows, { headers: false })
.on('data', (data) => {
if (condition) {
// force to end.
}
}
.on('end', () => cb(units));

因此,我希望尽早脱离 csv 文件。

最佳答案

您似乎正在使用 node-csvtojson .

我认为你可以像这样停止发送数据事件:

const converter = csv.fromString(rows, { headers: false })
converter.on('data', (data) => {
if (condition) {
converter.removeAllListeners('data');// where 'data' is the name of the event. If called without any arguments, all listeners added to csv converter will be removed
}
}

来源:this thread on Github .

关于Javascript 停止一个事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43318983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com