How to use the filter function from async

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

GitHub: rf/nd

rf profile picture
59
60
61
62
63
64
65
66
67
68
      return path.join(root, item);
    });

    tries = _.uniq(tries);

    async.filter(tries, path.exists, function (result) { 
      done(null, result);
    });
  });
};
fork icon3
star icon86
watch icon5

135
136
137
138
139
140
141
142
143
144
.exec(function(err, rooms) {
  if (err) {
    console.log(err);
    throw err;
  }
  async.filter(
    rooms,
    function(room, filterCallback) {
      checkAvailability(room, booking, function(available) {
        filterCallback(null, available);
fork icon21
star icon9
watch icon3

+ 7 other calls in file

37
38
39
40
41
42
43
44
45
46
        poolOptions.paymentProcessing.enabled) {
        enabledPools.push(coin);
        logger.info("PP> Enabled %s for payment processing", coin);
    }
});
async.filter(enabledPools, function (coin, callback) {
    SetupForPool(poolConfigs[coin], function (setupResults) {
        logger.debug("PP> Payment processor initialized. Setup results %s", setupResults);
        callback(null, setupResults);
    });
fork icon2
star icon0
watch icon0

154
155
156
157
158
159
160
161
162
163
    })
  })
} 
async filter(coll, iteratee) {    
  return new Promise(async (resolve, reject) => { 
    async.filter(coll, iteratee, (err, res) => {
      if (err) { 
        reject(err)
      } else {
        resolve(res)
fork icon1
star icon0
watch icon1

+ 21 other calls in file

4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
* with a boolean argument once it has completed. Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results).
* @example
*
* async.filter(['file1','file2','file3'], function(filePath, callback) {
*     fs.access(filePath, function(err) {
*         callback(null, !err)
*     });
* }, function(err, results) {
fork icon0
star icon2
watch icon1

133
134
135
136
137
138
139
140
141
142
    callback(null, {documents: documents});
  });
},
// check if the required documents already exist on elasticsearch
function(res, callback) {
  async.filter(res.documents, function(doc, filterCallback) {
    client.exists({
      index: mainIndex,
      type: doc._type,
      id: doc._id
fork icon0
star icon1
watch icon1

210
211
212
213
214
215
216
217
218
219

const results = await db.sortedSetScores(`uid:${params.uid}:tids_read`, params.tids);

const userScores = _.zipObject(params.tids, results);

return await async.filter(params.tids, async tid => await doesTidHaveUnblockedUnreadPosts(tid, {
    blockedUids: params.blockedUids,
    topicTimestamp: topicScores[tid],
    userLastReadTimestamp: userScores[tid],
}));
fork icon0
star icon0
watch icon1

+ 7 other calls in file