How to use the filterSeries function from async

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

147
148
149
150
151
152
153
154
155
156
app.get('/-/search/:term?', function (req, res) {
  var searchTerm = req.params.term;

  storage.get_local(function(err, packages) {
    if (err) throw err // that function shouldn't produce any
    async.filterSeries(packages, function(package, cb) {
      auth.allow_access(package.name, req.remote_user, function(err, allowed) {
        setImmediate(function () {
          if (searchTerm) {
            cb(!err && allowed && package.name.indexOf(searchTerm) !== -1);
fork icon684
star icon0
watch icon4

45
46
47
48
49
50
51
52
53
54
  this.invalidInputFiles = 0;
}

async validateInputFiles() {
  const originalLength = this.inputFiles.length;
  this.inputFiles = await async.filterSeries(this.inputFiles, async (i) => { return (null, await fs.pathExists(i)); });
  if (this.inputFiles.length !== originalLength) {
    this.invalidInputFiles = originalLength - this.inputFiles.length;
    if (this.verbose) console.log(`${this.invalidInputFiles} file${this.invalidInputFiles === 1 ? '' : 's'} will be skipped because ${this.invalidInputFiles === 1 ? 'it does' : 'they do'} not exist`);
  }
fork icon18
star icon153
watch icon3

3
4
5
6
7
8
9
10
11
12
 * This helper runs actions of all the Handlers that the react-router
 * has said are active. This pre-populates the context with all the data
 * needed to render components.
 */
module.exports = function(state, context, done) {
    async.filterSeries(
        state.routes.filter(function(route) {
            // TODO: handler.loadAction is not present using ProxyView
            return route.handler.loadAction?true:false;
        }),
fork icon4
star icon20
watch icon2

176
177
178
179
180
181
182
183
184
185
    })
  })
}
async filterSeries(coll, iteratee) {    
  return new Promise(async (resolve, reject) => { 
    async.filterSeries(coll, iteratee, (err, res) => {
      if (err) { 
        reject(err)
      } else {
        resolve(res)
fork icon1
star icon0
watch icon1

+ 21 other calls in file

87
88
89
90
91
92
93
94
95
// If the script is being run directly we need to initialize
if (!module.parent)
        asyncFns.push(init);

var filesFilter = function (_cb) {
        async.filterSeries(strmFiles, checkSTRMFile, function (results) {
                _cb(null, results);
        });
};
fork icon0
star icon3
watch icon2

166
167
168
169
170
171
172
173
174
175
  if (value === 'n' || value === 'no')
    return 'no';
  throw new Error('Enter yes or no.');
};

async.filterSeries(res.documents, function(doc, filterCallback) {
  if (!documentExists(doc)) {
    filterCallback(true);
    return;
  }
fork icon0
star icon1
watch icon1

15
16
17
18
19
20
21
22
23
24
function filter (err, containers) {
  if (err) {
    throw err;
  }
  console.log('LIST', containers.map(id));
  async.filterSeries(containers, top, applyHolyWater)
}

function id (container) {
  return container.Id;
fork icon0
star icon0
watch icon6