How to use the detectSeries function from async

Find comprehensive JavaScript async.detectSeries code examples handpicked from public code repositorys.

134
135
136
137
138
139
140
141
142
143

if (typeof (devices) === 'string') return this._open(devices, cb)

// Note: We're using detectSeries because we want to conserve device order,
// meaning we want to use the first devices in the list that's present.
async.detectSeries(devices, function (device, _cb) {
  fs.stat(device, function (err, stats) {
    if (err) return _cb(false)
    if (!stats.isCharacterDevice()) return _cb(false)
    _cb(true)
fork icon128
star icon98
watch icon17

GitHub: rf/nd

rf profile picture
117
118
119
120
121
122
123
124
125
126

    return memo;
  }, []);

  // find the first of the `tries` array which actually exists, and return it
  async.detectSeries(tries, path.exists, function (result) {
    if (result) fs.readFile(result, 'utf8', done);
    else done(new Error('no markdown files found matching query'));
  });
};
fork icon3
star icon86
watch icon5

15
16
17
18
19
20
21
22
23
24
// TODO: handle unknown types
//console.dir(req.highlight);
if(!list) list = req.highlight.default;
//console.dir(list);
var cmds = Object.keys(list);
async.detectSeries(cmds, function(cmd, callback) {
  which(cmd, function exists(err, path) {
    callback(!err && path);
  })
}, function(result) {
fork icon2
star icon25
watch icon3

20
21
22
23
24
25
26
27
28
29
    const paths = [];
    for (let i = 0; i < dirs.length; i++) {
        paths.push(path.resolve(dirs[i], bin));
    }

    async.detectSeries(paths, isExecutable, function (foundDir) {
        if (!foundDir) return done();
        done(foundDir);
    });
};
fork icon2
star icon6
watch icon5

31
32
33
34
35
36
37
38
39
40
const from = { lyric: null, sourceName: '', sourceUrl: ''};
const normalizedTitle = this.normalizer.normalize(title);
// run plugins on series
// if some returns success getting a lyric
// stop and save the lyric result
async.detectSeries(this.plugins, (plugin : SearchLyrics, callback) => {
    plugin.search(normalizedTitle, artist, (err, result) => {
        if (!err) {
            from.lyric = result.lyric;
            from.sourceName = plugin.name;
fork icon51
star icon0
watch icon1

44
45
46
47
48
49
50
51
52
53
    })
  })
}
async detectSeries(coll, iteratee) {    
  return new Promise(async (resolve, reject) => { 
    async.detectSeries(coll, iteratee, (err, res) => {
      if (err) { 
        reject(err)
      } else {
        resolve(res)
fork icon1
star icon0
watch icon1

+ 21 other calls in file