本文整理汇总了TypeScript中lodash.reverse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript reverse函数的具体用法?TypeScript reverse怎么用?TypeScript reverse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reverse函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: makeBarSpecs
export function makeBarSpecs(
data: IMultipleCategoryBarPlotData[],
minorCategoryOrder:{[cat:string]:number} | undefined,
majorCategoryOrder:{[cat:string]:number} | undefined,
getColor:(minorCategory:string)=>string,
categoryCoord:(categoryIndex:number)=>number,
horizontalBars:boolean,
percentage:boolean
):{
fill: string,
data:{ x:number, y: number, majorCategory: string, minorCategory:string, count:number, percentage:number}[] // one data per major category, in correct order - either specified, or alphabetical
}[] // one bar spec per minor category, in correct order - either specified, or alphabetical
{
data = sortDataByCategory(data, d=>d.minorCategory, minorCategoryOrder);
// for vertical bars, reverse order, to put first on top
if (!horizontalBars) {
data = _.reverse(data);
}
return data.map(({ minorCategory, counts })=>{
const fill = getColor(minorCategory);
const sortedCounts = sortDataByCategory(counts, d=>d.majorCategory, majorCategoryOrder);
return {
fill,
data: sortedCounts.map((obj, index) => ({
x: categoryCoord(index),
y: percentage ? obj.percentage : obj.count,
majorCategory: obj.majorCategory,
minorCategory: minorCategory,
count: obj.count,
percentage: obj.percentage
}))
};
});
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:34,代码来源:MultipleCategoryBarPlotUtils.ts
示例2: configuration
configuration() {
const config = _.map(this.adjacentFaces(), 'numSides');
const allConfigs = getCycles(config).concat(
getCycles(_.reverse([...config])),
);
return _.reduce(allConfigs, arrayMin)!;
}
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:7,代码来源:Vertex.ts
示例3:
'_FINANCIAL_YEAR': (template, counts, tense) => {
const hypotheticalFinancialYearMonth = 10;
const currentFinancialYear = this._getThisFinancialYear();
let currentYear = currentDate.getFullYear();
let nthFinancialYears = [];
if (tense == 'LAST') {
for (let counter = 0; counter < counts; counter++) {
currentYear = currentYear - 1;
nthFinancialYears.push({
id: currentYear + 'Oct',
dimensionItem: currentYear + 'Oct',
displayName: currentYear + 'Oct',
dimensionItemType: 'PERIOD'
});
}
}
if (nthFinancialYears.length < 1) {
nthFinancialYears.push({
id: currentYear + 'Oct',
dimensionItem: currentYear + 'Oct',
displayName: currentYear + 'Oct',
dimensionItemType: 'PERIOD'
});
}
return _.reverse(nthFinancialYears);
}
开发者ID:hisptz,项目名称:scorecard,代码行数:27,代码来源:relative-period.service.ts
示例4: applySortDirection
private applySortDirection(res:IRow[]) {
if(this.direction == SortDirection.Descending){
res = _.reverse(res);
}
return res;
}
开发者ID:iamisti,项目名称:mdDataTable2,代码行数:7,代码来源:SortService.ts
示例5: _getMatchString
private _getMatchString(text: string, match: fuse.Match) {
_.each(_.reverse(match.indices), ([start, end]) => {
const endStr = text.substr(end + 1);
const replace = `<span class="character-match">${text.substr(start, end - start + 1)}</span>`;
const startStr = text.substr(0, start);
text = `${startStr}${replace}${endStr}`;
});
return text;
}
开发者ID:OmniSharp,项目名称:atom-languageclient,代码行数:9,代码来源:ReferenceView.ts
示例6: runMigrations
async function runMigrations(fromFolder: string, toFolder: string) {
toFolder = argv.to as string || '.';
if (!fromFolder) {
throw new Error('Must specify --from option when migrating.');
}
fromFolder = resolvePath(fromFolder);
toFolder = resolvePath(toFolder);
if (fromFolder === toFolder) {
logger.info(null, '[migrate] Migration source and destination identical, skipping.');
return;
}
await bootstrapDatabase();
logger.info(null, '[migrate] Migrating from %s to %s...', fromFolder, toFolder);
const fromRepo = await Git.Repository.open(fromFolder);
const toRepo = await Git.Repository.open(toFolder);
const fromCommit = await fromRepo.getHeadCommit();
try {
await toRepo.getCommit(fromCommit.sha());
} catch (err) {
logger.warn(null, '[migrate] Cannot find commit %s in repository %s. Assuming force-push, aborting migrations.', fromCommit.sha(), toFolder);
return;
}
let foundFromCommit = false;
const toCommit = await toRepo.getHeadCommit();
const commits = await new Promise<Commit[]>((resolve, reject) => {
const commitsSince: Commit[] = [];
const emitter = toCommit.history()
.on('end', () => resolve(commitsSince))
.on('error', reject)
.on('commit', (commit: Commit) => {
foundFromCommit = foundFromCommit || commit.sha() === fromCommit.sha();
if (!foundFromCommit) {
commitsSince.push(commit);
}
});
(emitter as any).start();
});
if (!foundFromCommit) {
logger.info(null, '[migrate] Initial commit not found, aborting (this can happen on a force push).');
return;
}
logger.info(null, '[migrate] Found %s commits between %s and %s.', commits.length, fromCommit.sha().substring(0, 7), toCommit.sha().substring(0, 7));
let numScripts = 0;
for (const commit of reverse(commits)) {
const script = scripts.find(filename => commit.sha().startsWith(filename.split('-')[1]));
if (!script) {
continue;
}
logger.info(null, '[migrate] Executing migration script %s for commit %s...', script, commit.sha());
const migrate = require(resolvePath(scriptFolder, script));
await migrate.up();
numScripts++;
}
logger.info(null, '[migrate] %s script%s executed.', numScripts, numScripts === 1 ? '' : 's');
}
开发者ID:freezy,项目名称:node-vpdb,代码行数:57,代码来源:migrate.ts
示例7: getDailyActiveUsers
getDailyActiveUsers() {
const ranges = _.reverse(this.getLastDaysRange())
return Promise.mapSeries(ranges, range => {
return this.knex('analytics_interactions as ai')
.select(this.knex.raw('count(*) as count, ai.channel'))
.join('srv_channel_users', 'srv_channel_users.user_id', 'ai.user_id')
.where(this.knex.date.isBetween('ts', range['start'], range['end']))
.where('direction', '=', 'in')
.groupBy(['ai.user_id', 'ai.channel'])
.then(results => {
return results.reduce(
function(acc, curr) {
const count = parseInt(curr.count)
acc.total += count
acc[curr.channel] = count
return acc
},
{ total: 0, name: range['date'] }
)
})
})
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:23,代码来源:stats.ts
注:本文中的lodash.reverse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论