// Helper to sort tokens const sortTokens = (...sources) => _(_.flatten([...sources])) .sortBy('date') .groupBy('user') .map(tokens => _.last(tokens)) .value()
/* * Helper to cleanse path */ const cleanLine = (line = '') => { const m = /.*\((.*)\).?/.exec(line) || []; return m[1] ? line.replace(m[1], _.last(m[1].split(path.sep))) : line; }
_.map(overrides.volumes, volume => { if (!_.includes(volume, ':')) { return volume; } else { const local = exports.getHostPath(volume); const remote = _.last(volume.split(':')); // @TODO: I don't think below does anything? const excludes = _.keys(volumes).concat(_.keys(volumes)); const host = exports.normalizePath(local, base, excludes); return [host, remote].join(':'); } })
// receiving metrics now would cause an emit sandbox.stub(metricsProvider, "emit").callsFake((key, data, discardEvent) => { if (discardEvent) { return; } expect(key) .to.be.a("string") .that.equals("metrics"); expect(data) .to.be.an("object") .that.deep.equals( _.last(metricsProvider._aggregation[metricsProvider.zoomLevelKey].data) ); });
_.map(this.series, (series, id) => { let seriesLabel = ""; if (this.seriesOptions[id].label) { seriesLabel = `${this.seriesOptions[id].label} `; } else if (!this.seriesOptions[id].hasOwnProperty("label")) { seriesLabel = `${id} `; } return util.format("%s(%d%s)", seriesLabel, _.last(this.series[id].y), this.unit); }).join(", ")
/** * 保存用户头像 * @returns {Promise.<void>} */ async saveAvatarAction() { const avatar = this.file('avatar'); if (think.isEmpty(avatar)) { return this.fail('保存失败'); } const avatarPath = think.RESOURCE_PATH + `/static/user/avatar/${this.getLoginUserId()}.` + _.last(_.split(avatar.path, '.')); fs.rename(avatar.path, avatarPath, function(res) { return this.success(); }); }
scanner(urls, {max: 1, waitCodes: []}) .filter(url => url.status === false) .map(port => _.last(port.url.split(':'))) .then(ports => ports[0])
/* * Helper to return a type and version from platform data */ const getPlatformServiceType = ({name = 'app', type} = {}) => ({ name, type: _.first(type.split(':')), version: _.last(type.split(':')), })
_.set(landoFile, `config.${key}`, _.last(option.split('='))); });
/* * Helper to get config defaults */ const getConfigDefaults = options => { // Get the viaconf if (_.startsWith(options.via, 'nginx')) options.defaultFiles.vhosts = 'default.conf.tpl'; // Get the default db conf const dbConfig = _.get(options, 'database', 'mysql'); const database = _.first(dbConfig.split(':')); const version = _.last(dbConfig.split(':')); if (database === 'mysql' || database === 'mariadb') { if (version === '8.0') { options.defaultFiles.database = 'mysql8.cnf'; } else { options.defaultFiles.database = 'mysql.cnf'; } } // Verify files exist and remove if it doesn't _.forEach(options.defaultFiles, (file, type) => { if (!fs.existsSync(`${options.confDest}/${file}`)) { delete options.defaultFiles[type]; } }); // Return return options.defaultFiles; }
this.highestAggregationKey = _.last(this.aggregationLevels);
if (code !== 0 && _.isEmpty(stderr)) stderr = _.trim(_.last(_.compact(stdout.split(os.EOL))));
_(_.flatten([...sources])) .sortBy('date') .groupBy('email') .map(tokens => _.last(tokens)) .value()
_(_.flatten([...sources])) .sortBy('date') .groupBy('email') .map(tokens => _.last(tokens)) .value()