本文整理汇总了TypeScript中ramda.path函数的典型用法代码示例。如果您正苦于以下问题:TypeScript path函数的具体用法?TypeScript path怎么用?TypeScript path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: curryN
export let forwardMessage = curryN(2, (options = {}, update: Update) => Request({
type: 'sink',
method: 'forwardMessage',
options: defaults(
{
from_chat_id: defaultTo(path(['message', 'chat', 'id'], update)),
message_id: defaultTo(path(['message', 'message_id'], update))
},
is(Number, options) ? {chat_id: options} : options)
}))
示例2: default
export default (
e: Linode.Event,
onUnfound?: (e: Linode.Event) => string | void,
onError?: (e: Linode.Event, err: Error) => void
) => {
const fn = path<EventMessageCreator>(
[e.action, e.status],
eventMessageCreators
);
if (!fn) {
if (onUnfound) {
return onUnfound(e);
}
return;
}
let message;
try {
message = fn(e);
} catch (error) {
if (onError) {
onError(e, error);
}
return;
}
return message;
};
示例3:
const extractItemsBy = primaryKey =>
R.compose(
R.uniqBy(R.prop(primaryKey)),
R.flatten,
R.map(R.path(['data', 'items'])),
R.flatten,
);
示例4: isFeedItem
function isFeedItem(x:OutlineFeedParent|OutlineFolderParent):x is OutlineFeedParent {
return compose(
lt(0),
length,
path(['$', 'xmlUrl'])
)(x)
}
示例5: callback
export const handleGeneralErrors = (
callback: Function,
errors: any,
defaultMessage: string = 'An error has occured.'
) => {
const apiErrors = path<Linode.ApiFieldError[]>(
['response', 'data', 'errors'],
errors
);
if (!apiErrors) {
return callback(defaultMessage);
}
const generalError = apiErrors
.reduce(
(result, { field, reason }) => (field ? result : [...result, reason]),
[]
)
.join(',');
if (!isNilOrEmpty(generalError)) {
return callback(generalError);
}
};
示例6:
R.map(field => {
// raw is the original value, if exists, means it's update request
if (field.value && !field.raw) {
const value = R.is(String, field.value) ? JSON.parse(field.value) : field.value;
return { ...field, value, raw: field.value };
}
return { ...field, value: R.path([current, 'value'])(fields), raw: field.value };
}),