當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ramda.lensPath函數代碼示例

本文整理匯總了TypeScript中ramda.lensPath函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript lensPath函數的具體用法?TypeScript lensPath怎麽用?TypeScript lensPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了lensPath函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: update

 (state: State) => {
   const update = R.set(
     R.lensPath(['notes', noteId, 'label']),
     text
   )
   return update(state)
 })
開發者ID:JamesHageman,項目名稱:xstream-scrumbler,代碼行數:7,代碼來源:index.ts

示例2:

    (acc: Array<BookmarkTree>, bookmarkTree) => {
      if (!acc.length) return [bookmarkTree]

      const prevBookmarkTree = R.last(acc)
      if (!prevBookmarkTree) throw new Error('prevBookmarkTree must exist')
      const updatedBookmarkTree = R.set(
        R.lensPath(['parent', 'parentId']),
        prevBookmarkTree.parent.id,
        bookmarkTree
      )
      return [...acc, updatedBookmarkTree]
    },
開發者ID:foray1010,項目名稱:Popup-my-Bookmarks,代碼行數:12,代碼來源:getters.test.ts

示例3: simulateBookmark

    [getType(bookmarkCreators.setDragIndicator)]: (
      state: BookmarkState,
      {payload}: ReturnType<typeof bookmarkCreators.setDragIndicator>
    ) => {
      const parentIndex = state.trees.findIndex((tree) => tree.parent.id === payload.parentId)
      if (parentIndex === -1) return state

      return R.over(
        R.lensPath(['trees', parentIndex, 'children']),
        R.insert(payload.index, simulateBookmark({type: CST.BOOKMARK_TYPES.DRAG_INDICATOR})),
        removeDragIndicator(state)
      )
    }
開發者ID:foray1010,項目名稱:Popup-my-Bookmarks,代碼行數:13,代碼來源:reducer.ts

示例4: over

import { BrowserOptions, captureException, init } from '@sentry/browser';
import { lensPath, over } from 'ramda';
import { SENTRY_URL } from 'src/constants';
import redactAccessTokenFromUrl from 'src/utilities/redactAccessTokenFromUrl';

const updateRequestUrl = over(
  lensPath(['request', 'url']),
  redactAccessTokenFromUrl
);

const beforeSend: BrowserOptions['beforeSend'] = (event, hint) => {
  return updateRequestUrl(event);
};

if (SENTRY_URL) {
  init({
    dsn: SENTRY_URL,
    release: process.env.VERSION,
    environment: process.env.NODE_ENV,
    beforeSend
  });
}

window.addEventListener('unhandledrejection', (err: PromiseRejectionEvent) => {
  captureException(err.reason);
});

export const reportException = (error: string | Error, extra?: any) => {
  if (process.env.NODE_ENV === 'production' && SENTRY_URL) {
    captureException(error);
  } else {
開發者ID:displague,項目名稱:manager,代碼行數:31,代碼來源:exceptionReporting.ts

示例5: lensPath

import Axios, { AxiosError, AxiosPromise, AxiosResponse } from 'axios';
import { compose, isEmpty, isNil, lensPath, not, omit, set, when } from 'ramda';
import { ObjectSchema, ValidationError } from 'yup';

const L = {
  url: lensPath(['url']),
  method: lensPath(['method']),
  params: lensPath(['params']),
  data: lensPath(['data']),
  xFilter: lensPath(['headers', 'X-Filter']),
  validationErrors: lensPath(['validationErrors']),
  headers: lensPath(['headers'])
};

const isNotEmpty = compose(
  not,
  (v: any) => isEmpty(v) || isNil(v)
);

/** URL */
export const setURL = (url: string) => set(L.url, url);

/** METHOD */
export const setMethod = (method: 'GET' | 'POST' | 'PUT' | 'DELETE') =>
  set(L.method, method);

/** Param */
export const setParams = (params: any = {}) =>
  when(() => isNotEmpty(params), set(L.params, params));

export const setHeaders = (headers: any = {}) =>
開發者ID:linode,項目名稱:manager,代碼行數:31,代碼來源:index.ts


注:本文中的ramda.lensPath函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。