本文整理汇总了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;未经允许,请勿转载。 |
请发表评论