*parallel(tasks, opts) { try { yield Promise.all(tasks.map(t => this.start(t, opts))); } catch (err) { // } }
task.plugin('clear', { every:false, files:false }, function * (_, globs, opts) { opts = opts || {}; yield Promise.all(toArr(globs).map(g => del(g, opts))); });
co(function * (o) { o = o || {}; const args = []; args.push.apply(args, arguments) && args.shift(); // grab alias to chosen source type const arr = this._[opts.files ? 'files' : 'globs']; // wrapper pass all arguments to plugin func const run = s => co(func).apply(this, [s, o].concat(args)); // loop thru EACH if `every`, else send full source array yield (opts.every ? Promise.all(arr.map(run)) : run(arr)); // send back instance allow chain return this; })
@Get('/collections/:id/edit.html') @UseGuards(ActiveGuard) async editView(@CurUser() user, @Param('id', MustIntPipe) id: number, @Res() res) { const [collection, uploadPolicy] = await bluebird.all([ this.collectionService.findById(id), this.ossService.requestPolicy(), ]); if (!collection) { throw new MyHttpException({ errorCode: ErrorCode.NotFound.CODE, }); } if (collection.creatorID !== user.id) { res.redirect(`/u/${user.id}.html`); return; } res.render('pages/collection/edit', { uploadPolicy, collection, }); }
co(function * (globs, opts) { globs = $.flatten($.toArray(globs)); const files = yield this.$.expand(globs, opts); if (globs.length && !files.length) { this.emit('globs_no_match', globs, opts); } // pre-fetch each file's content const datas = yield Promise.all(files.map(f => this.$.read(f))); // update known globs this._.globs = globs; // update known files, as (mod'd) `pathObject`s this._.files = files.map((el, idx) => { const obj = parse(el); return { dir: normalize(obj.dir), data: datas[idx], base: obj.base }; }); })
Promise.all( globs.map(g => glob(g.pattern, g.options)) ).then(all => getUniques([].concat.apply([], all)))
/* * Get list of sites */ getSites() { // Call to get user sites const pantheonUserSites = () => { const getSites = ['users', _.get(this.session, 'user_id'), 'memberships', 'sites']; return pantheonRequest(this.request, this.log, 'get', getSites, {params: {limit: MAX_SITES}}) .then(sites => _.map(sites, (site, id) => _.merge(site, site.site))); }; // Call to get org sites const pantheonOrgSites = () => { const getOrgs = ['users', _.get(this.session, 'user_id'), 'memberships', 'organizations']; return pantheonRequest(this.request, this.log, 'get', getOrgs) .map(org => { if (org.role !== 'unprivileged') { const getOrgsSites = ['organizations', org.id, 'memberships', 'sites']; return pantheonRequest(this.request, this.log, 'get', getOrgsSites, {params: {limit: MAX_SITES}}) .map(site => _.merge(site, site.site)); } }) .then(sites => _.flatten(sites)); }; // Run both requests return Promise.all([pantheonUserSites(), pantheonOrgSites()]) // Combine, cache and all the things .then(sites => _.compact(_.sortBy(_.uniqBy(_.flatten(sites), 'name'), 'name'))) // Filter out any BAAAAD BIZZZNIZZZ .filter(site => !site.frozen); }
}) .then(dummy, () => { return promise.all([
return yield Promise.all( $.flatten( files.map(obj => dirs.map(d => {
bb.coroutine(function * (src) { yield bb.all(toArray(src).map(g => rimraf(g))) })
*parallel(tasks, opts) { try { yield Promise.all(tasks.map(t => this.start(t, opts))); } catch (err) { // } }
co(function * (o) { o = o || {}; const args = []; args.push.apply(args, arguments) && args.shift(); // grab alias to chosen source type const arr = this._[opts.files ? 'files' : 'globs']; // wrapper pass all arguments to plugin func const run = s => co(func).apply(this, [s, o].concat(args)); // loop thru EACH if `every`, else send full source array yield (opts.every ? Promise.all(arr.map(run)) : run(arr)); // send back instance allow chain return this; })
bb.coroutine(function * (src) { yield bb.all(toArray(src).map(g => rimraf(g))) })
Promise.all( globs.map(g => glob(g.pattern, g.options)) ).then(all => getUniques([].concat.apply([], all)))
co(function * (globs, opts) { globs = $.flatten($.toArray(globs)); const files = yield this.$.expand(globs, opts); if (globs.length && !files.length) { this.emit('globs_no_match', globs, opts); } // pre-fetch each file's content const datas = yield Promise.all(files.map(f => this.$.read(f))); // update known globs this._.globs = globs; // update known files, as (mod'd) `pathObject`s this._.files = files.map((el, idx) => { const obj = parse(el); return { dir: normalize(obj.dir), data: datas[idx], base: obj.base }; }); })