本文整理汇总了TypeScript中ramda.slice函数的典型用法代码示例。如果您正苦于以下问题:TypeScript slice函数的具体用法?TypeScript slice怎么用?TypeScript slice使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slice函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: map
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,
示例2: getSearchResult
export function* getSearchResult({
payload
}: ActionType<typeof bookmarkCreators.getSearchResult>): SagaIterator {
try {
if (!payload.searchKeyword) {
yield put(bookmarkCreators.initBookmarkTrees())
return
}
const {options}: RootState = yield select(R.identity)
const searchResult: Array<BookmarkInfo> = yield call(searchBookmarks, {
query: payload.searchKeyword
})
const isSearchTitleOnly = options[CST.OPTIONS.SEARCH_TARGET] === 1
const sortedPartialResult = R.compose(
sortByTitle,
R.slice(0, options[CST.OPTIONS.MAX_RESULTS] || 0),
(result: Array<BookmarkInfo>) => {
const filteredResult = result.filter(R.propEq('type', CST.BOOKMARK_TYPES.BOOKMARK))
if (isSearchTitleOnly) {
return filteredResult.filter((bookmarkInfo: BookmarkInfo) => {
return searchKeywordMatcher(payload.searchKeyword, bookmarkInfo.title)
})
}
return filteredResult
}
)(searchResult)
const searchResultTrees = [
{
children: sortedPartialResult,
parent: simulateBookmark({
id: CST.SEARCH_RESULT_ID,
type: CST.BOOKMARK_TYPES.FOLDER
})
}
]
yield put(bookmarkCreators.setBookmarkTrees(searchResultTrees))
} catch (err) {
console.error(err)
}
}
示例3: contains
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)
},
// adjust :: (a → a) → Number → [a] → [a]
示例4:
.map(([entities, to]) => R.slice(0, to)(entities));