本文整理匯總了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));