// This is a helper to take object data and break it into rows add(data, {joiner = this.joiner, sort = this.sort} = {}) { _.forEach(sort ? _.sortBy(_.keys(data)) : _.keys(data), key => { // Do some special things for arrays if (_.isArray(data[key])) data[key] = data[key].join(joiner); // Do something special for objects if (_.isObject(data[key])) data[key] = util.inspect(data[key], {compact: true}); // Do the normal push this.push([(chalk[this.keyColor](_.toUpper(key))), data[key]]); }); }
const slowFunc = function (count) { const begin = Date.now(); // Deliberately unused variable. // eslint-disable-next-line no-unused-vars let values = _.times(count, () => _.random(0, count)); values = _.sortBy(values); return Date.now() - begin; }
// Helper to retrieve all github repoz const getAllRepos = (resolve, reject, slugs = []) => (err, res) => { // resolve([{name: 'seseg'}]) if (err) reject(err); // Add previous data to current slugs = slugs.concat(_.map(res.data, site => ({name: site.full_name, value: site.ssh_url}))); // IF we have more pages lets add them if (github.hasNextPage(res)) { return github.getNextPage(res, getAllRepos(resolve, reject, slugs)); // Return if we are done } else { resolve(_.sortBy(slugs, 'name')); } }
lando.Promise.try(() => { if (_.isEmpty(inquiry)) return {}; else { const inquirer = require('inquirer'); inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt')); // Try to rebuild the inquiry if this is app level bootstrap and we have an app if (!_.isEmpty(argv._app) && lando._bootstrap === 'app') { // NOTE: We need to clone deep here otherwise any apps with interactive options get 2x all their events // NOTE: Not exactly clear on why app here gets conflated with the app returned from lando.getApp const app = _.cloneDeep(lando.getApp(argv._app.root)); return app.init().then(() => { inquiry = exports.getInteractive(_.find(app.tasks.concat(lando.tasks), {command: command}).options, argv); return inquirer.prompt(_.sortBy(inquiry, 'weight')); }); // Otherwise just run } else { inquiry = exports.getInteractive(_.find(lando.tasks, {command: command}).options, argv); return inquirer.prompt(_.sortBy(inquiry, 'weight')); } } })
/* * 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); }
_.forEach(_.sortBy(tasks, 'command'), task => { if (_.has(task, 'handler')) yargs.command(task); else yargs.command(this.parseToYargs(task));
/** * Creates a new OptionsChain object. * @author Torrey Leonard <https://github.com/Ladinn> * @param {Array} array */ constructor(array) { this.array = _.sortBy(array, "date"); }
self.Params(_.sortBy(_.map(_.filter(Params,{IsShow:true}),function(P){ if (!CodeReport || Initial) P.InitParamSet = P.CodeParamSet; if (Override[P.CodeParam]){ P.NewCodeParamSet = Override[P.CodeParam]; P.CodeParamSet = Override[P.CodeParam]; } else { P.CodeParamSet = P.InitParamSet; P.NewCodeParamSet = P.InitParamSet; } return _.merge(P,{IsChanged:ko.observable(false)}); }),"IndexParam"));
var _parentsWithNode = function(node,tree){ return _.sortBy(_.filter(_.values(tree),function(check){ return check.lft <= node.lft && check.rgt >= node.rgt; }),"rgt"); }
getApiSummary() { const res = _.map(this.apiMap); this.mergeLockFns(res); return _.sortBy(res, d => -d.resp_time); }
_.sortBy(_.map( _.filter( ModuleManager.ModulesConfigs, function(M) { return M.config.places && M.config.places[type]; }), "config"), "sort_index")