我有一个文件路径列表file_paths
,我想检测哪个文件存在。 如果有任何文件存在,我想阅读那个文件。否则,请调用另一个函数,例如 not_found
。Node.js'未找到'async.detect回调?
我希望使用async.detect
,但是当所有迭代器返回false
时,我找不到添加'未找到'回调 的方法。
我试过这个,但没有工作。返回未定义,并没有输出。
async = require 'async'
async.detect [1,2,3], (item, callback) ->
callback true if item == 4
, (result) ->
console.log result ? result : 'Not Found'
如果还有其他方法可以做,请将其添加到答案中。
请包括您尝试过的代码块。 – mithunsatheesh