本文整理汇总了TypeScript中ramda.nth函数的典型用法代码示例。如果您正苦于以下问题:TypeScript nth函数的具体用法?TypeScript nth怎么用?TypeScript nth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nth函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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));
}
示例2: readDownSQL
export function readDownSQL(migration: Migration): Promise<string> {
if (migration.split) {
return fs.readFileAsync(migration.downPath, {encoding: 'utf8'})
.then(R.trim);
}
return fs.readFileAsync(migration.path, {encoding: 'utf8'})
.then(R.split(MIGRATION_SQL_SPLIT_REGEXP))
.tap(R.partial(assertSQLSections, migration))
.then(R.nth(1))
.then(R.trim);
}
示例3: compose
import { NoContent } from './no-content';
import { DataResolver } from './app.resolver';
import { routes as blogRoutes, asyncRoutes as blogAsyncRoutes } from './blog/blog.routing';
import { prop, compose, split, find, trim, equals, nth, ifElse, identity } from 'ramda';
export const appNavLinks: NavigationConfig = [
...Pages.navLinks,
...Layouts.navLinks,
...Authentication.navLinks,
];
const layout = compose(
ifElse(identity, compose(nth(1), split('=')), identity),
find(compose(equals('layout'), trim, nth(0), split('='))),
split(';')
)(document.cookie);
const layouts = {
'horizontal': HorizontalLayout,
'vertical' : VerticalLayout
};
export const routes: RouterConfig = [
{
path: '',
component: layouts[layout],
children: [
...Pages.routes,
示例4: contains
import * as R from 'ramda'
const UtilsR = {
R,
//// [] ////
// contains :: a → [a] → Boolean
contains(val, list) {
return R.contains(val, list)
},
// nth :: Number → [a] → a | Undefined (head 0 /last -1)
nth(index, list) {
return R.nth(index, list)
},
// slice :: Number → Number → [a] → [a] (init / tail / take / takeLast)
slice(fromIndex, toIndex, list) {
return R.slice(fromIndex, toIndex, list)
},
// difference {a∣a∈xs ∩ a∉ys} :: [a] → [a] → [a]
difference(listA, listB) {
return R.difference(listA, listB)
},
// insert :: Number → a → [a] → [a] (append / prepend)
insert(insertIndex, val, list) {
return R.insert(insertIndex, val, list)
},
// update :: Number → a → [a] → [a]
update(index, val, list) {
return R.update(index, val, list)
},
示例5: add
[isStrike, rolls => add(add(nth(1, rolls), nth(2, rolls)), bonus(drop(1, rolls)))],
示例6: nth
[isSpare, rolls => nth(2, rolls) + bonus(drop(2, rolls))],
示例7:
const selectFun: any = (n) => R.nth(R.modulo(R.dec(n), 15), funs);