本文整理汇总了TypeScript中ramda.is函数的典型用法代码示例。如果您正苦于以下问题:TypeScript is函数的具体用法?TypeScript is怎么用?TypeScript is使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: catch
const toJson = value => {
if (R.is(String, value) && value.length) {
try {
return JSON.parse(value);
} catch (e) {
logger.warn(TAG, e, { jsonFields });
return null;
}
}
if (R.is(Object, value)) {
return value;
}
return null;
};
示例2: 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,
示例3:
const assignFields = R.forEach(n => {
if (R.is(Object, n)) {
const key = R.pipe(R.keys, R.head)(n);
const value = R.pipe(R.values, R.head)(n);
return result[key] = source[value];
}
return result[n] = source[n];
})(rules);
示例4:
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 };
}),
示例5: dispatch
/**
* Dispatches a payload to all registered callbacks
* @param {object} payload Must contain an actionType property
*/
public dispatch(payload) {
if (R.is(Object, payload) && R.prop('actionType')) {
this._dispatcherObsv.onNext(payload);
} else {
throw new Error('payload must be an object with at least an actionType property');
}
}
示例6: 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)
}))
示例7: is
apiResponse: (request, response, duration) => {
const ok =
response &&
response.status &&
is(Number, response.status) &&
response.status >= 200 &&
response.status <= 299
const important = !ok
reactotron.send("api.response", { request, response, duration }, important)
},
示例8:
this[actionType] = (_payload) => {
// Check to see if the payload is an object or not
let payload = R.is(Object, _payload) ? _payload : {};
// Attach action type to the payload
payload = R.merge(_payload, { actionType: actionType });
this.dispatcher.dispatch(payload);
// return payload for testing
return payload;
};
示例9: path
const linearMatch = target => {
const value = path(modifierPath, target)
if (is(Boolean, value)) {
return value
}
if (isNil(value)) {
return false
}
return !isEmpty(value)
}