当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.slice函数代码示例

本文整理汇总了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,
开发者ID:nick121212,项目名称:reactotron,代码行数:8,代码来源:reactotron-mst.ts

示例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)
  }
}
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:44,代码来源:getSearchResult.ts

示例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]
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts

示例4:

	.map(([entities, to]) => R.slice(0, to)(entities));
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:1,代码来源:index.ts


注:本文中的ramda.slice函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。