本文整理汇总了TypeScript中ramda.sortBy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sortBy函数的具体用法?TypeScript sortBy怎么用?TypeScript sortBy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sortBy函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: sort
/**
* Return a sorted array of records
*
* Example:
*
* ```
* res = (res) ? Array.sort('invoiceCode', 'number', 'desc', res) : undefined;
* ```
*/
static sort(prop, type, order = 'asc', array) {
const sortBy = R.sortBy(R.prop(prop));
if ('string' === type) {
const sortBy = R.sortBy(R.compose(R.toLower, R.prop(prop)));
}
if (order === 'desc') {
return R.reverse(sortBy(array));
}
return sortBy(array);
}
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:22,代码来源:array-helper.ts
示例2: sendSubscriptions
/**
* Sends all subscribed values to the Reactotron app.
*
* @param node The tree to grab the state data from
*/
function sendSubscriptions(state: any) {
// this is unreadable
const changes = pipe(
map(when(isNil, always(""))) as any,
filter(endsWith(".*")),
map((key: string) => {
const keyMinusWildcard = slice(0, -2, key)
const value = dotPath(keyMinusWildcard, state)
if (is(Object, value) && !isNilOrEmpty(value)) {
return pipe(keys, map(key => `${keyMinusWildcard}.${key}`))(value)
}
return []
}) as any,
concat(map(when(isNil, always("")), subscriptions)),
flatten,
reject(endsWith(".*")) as any,
uniq as any,
sortBy(identity) as any,
map((key: string) => ({
path: key,
value: isNilOrEmpty(key) ? state : dotPath(key, state),
})),
)(subscriptions)
reactotron.stateValuesChange(changes)
}
开发者ID:nick121212,项目名称:reactotron,代码行数:31,代码来源:reactotron-mst.ts
示例3: getMigrationStates
export function getMigrationStates(
migrations: Migration[], journalEntries: JournalEntry[]
): MigrationState[] {
let migrationIDSet: { [id: string]: boolean } = {};
let states: { [id: string]: MigrationState } = {};
R.forEach(function(migration) {
migrationIDSet[migration.id] = true;
states[migration.id] = {
migrationID: migration.id,
migrationName: migration.name,
state: State.pending
};
}, migrations);
R.forEach(function(entry) {
if (!migrationIDSet[entry.migrationID]) {
states[entry.migrationID] = {
migrationID: entry.migrationID,
migrationName: entry.migrationName,
state: State.missing
};
} else if (entry.operation === Operation.apply) {
states[entry.migrationID].state = State.applied;
} else if (entry.operation === Operation.revert) {
states[entry.migrationID].state = State.reverted;
} else {
throw new InvalidJournalOperationError(entry.operation);
}
}, journalEntries);
return R.sortBy(s => s.migrationID, R.values(states));
}
开发者ID:programble,项目名称:careen,代码行数:33,代码来源:status.ts
示例4: listMigrations
export function listMigrations(directory: string): Promise<Migration[]> {
return fs.readdirAsync(directory)
.map(R.match(MIGRATION_FILE_REGEXP))
.filter(R.identity)
.then(R.groupBy(R.nth<string>(1)))
.then(R.mapObj(R.partial(matchesToMigration, directory)))
.then(R.values)
.then(R.sortBy((migration: Migration) => migration.id));
}
开发者ID:programble,项目名称:careen,代码行数:9,代码来源:files.ts
示例5: getNextNumber
/**
* Return the next running number in an array of records
* @param {string} prop The property name
* @param data The array of records containing the property
*/
static getNextNumber(prop: string, data: Array<any>) {
if (R.isEmpty(data)) { return 1 }
const getNextNumber = R.pipe(
R.sortBy(R.prop(prop)),
R.pluck(prop),
R.last()
);
return parseInt(getNextNumber(data)) + 1;
}
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:15,代码来源:array-helper.ts
示例6: function
const getPaymentReminders = function(priority, subject) {
return fakeApi()
.then(R.filter(R.propEq('priority', priority)))
.then(R.filter(R.where({ subject: R.contains(subject)})))
.then(R.sortBy(R.prop('from')));
}
开发者ID:marley-js,项目名称:Mastering-TypeScript-Programming-Techniques,代码行数:6,代码来源:api-ramda.ts
示例7: curry
for (let key of Object.keys(rackCount)) {
if (wordCount[key] > rackCount[key]) {
return false;
}
}
return true;
});
const filterValid = curry((rack: string, words: string[]) =>
filter(isValid(rack), words),
);
const clean = pipe(
sortBy(prop('numChars')) as any,
reverse,
) as any;
const wordGraph = new MinimalWordGraph();
let loaded = false;
export const load = async () => {
if (loaded) return;
let words = await store.getItem<string[]>('words');
if (!words) {
const res = await fetch(url);
const text = await res.text();
words = text.split('\n');
开发者ID:kerlends,项目名称:word-solver,代码行数:30,代码来源:solver.worker.ts
示例8:
.map(res => R.sortBy(R.prop('name'))(res));
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:1,代码来源:receipt-form.ts
示例9:
.map((res: any) => R.sortBy(R.prop('name'))(res));
开发者ID:simbiosis-group,项目名称:ion2-member,代码行数:1,代码来源:application-form.ts
示例10: getAnswerMapFromRows
const answerRows = candidateAndAnswerRows[1];
const oneRow = answerRows[0];
return {
answers: getAnswerMapFromRows(answerRows),
id: candidateName,
name: candidateName,
party: oneRow[AnswerFileCols.PARTY],
reasons: getReasonsMapFromRows(answerRows),
regions: oneRow[AnswerFileCols.REGION].split(/,\s+/)
};
});
}
function parseRegions(fileContent: string): RegionMap {
const questionRows: Row[] = parse(fileContent);
const regions = questionRows.slice(1).map(row => ({
id: row[0],
name: row[1]
}));
return R.indexBy(r => r.id, regions) as RegionMap;
}
const questions = parseQuestions(fs.readFileSync('data/questions.csv', 'utf8'));
const candidates = R.sortBy(c => c.region, parseCandidateAnswers(fs.readFileSync('data/answers.csv', 'utf8')));
const regions = parseRegions(fs.readFileSync('data/regions.csv', 'utf8'));
const initialData: InitialData = { questions, candidates, regions };
console.log(JSON.stringify(initialData, null, 2));
开发者ID:shybyte,项目名称:wahlomat,代码行数:29,代码来源:convert.ts
注:本文中的ramda.sortBy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论