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


TypeScript ramda.update函数代码示例

本文整理汇总了TypeScript中ramda.update函数的典型用法代码示例。如果您正苦于以下问题:TypeScript update函数的具体用法?TypeScript update怎么用?TypeScript update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了update函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: findIndex

 .reduceRight((updatedArray, el) => {
   /**
    * We need to update in place to maintain the correct timeline of events. Update in-place
    * by finding the index then updating at that index.
    */
   const indexOfFoundEvent = findIndex(({ id }) => id === el.id, updatedArray);
   return indexOfFoundEvent > -1
     ? update(indexOfFoundEvent, el, updatedArray)
     : [el, ...updatedArray];
 }, prevArr)
开发者ID:displague,项目名称:manager,代码行数:10,代码来源:event.helpers.ts

示例2: append

export default <T extends { id: string | number }>(item: T, items: T[]) => {
  if (items.length === 0) {
    return [item];
  }

  const found = items.findIndex((i) => i.id === item.id);
  if (found < 0) {
    return append(item, items);
  };

  return update(found, item, items);
}
开发者ID:displague,项目名称:manager,代码行数:12,代码来源:updateOrAdd.ts

示例3: updateLastPosition

function* updateLastPosition({
  payload
}: ActionType<typeof lastPositionsCreator.updateLastPosition>): SagaIterator {
  try {
    const {lastPositions = []}: LocalStorage = yield call(getLocalStorage)

    const index = lastPositions.findIndex(R.propEq('id', payload.id))
    if (index >= 0) {
      const updatedLastPositions = R.update(index, payload, lastPositions)

      yield call(setLocalStorage, {
        lastPositions: updatedLastPositions
      })
    }
  } catch (err) {
    console.error(err)
  }
}
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:18,代码来源:saga.ts

示例4: slice

  // 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]
  adjust(index, fn, list) {
    return R.adjust(fn, index, list)
  },
  // remove :: Number → Number → [a] → [a] (drop / dropLast)
  remove(fromIndex, number, list) {
    return R.remove(fromIndex, number, list)
  },
  // without {a∣a∉xs ∩ a∈ys} :: [a] → [a] → [a]
  without(listA, listB) {
    return R.without(listA, listB)
  },

  // sum :: [Number] → Number
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts


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