本文整理汇总了TypeScript中ramda.isNil函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNil函数的具体用法?TypeScript isNil怎么用?TypeScript isNil使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNil函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
export const getStatus = (application) => {
if (R.isNil(application.firstReviewer) || R.isNil(application.secondReviewer)) {
return application.status
}
if (application.firstReviewerStatus === STATUS_APPROVED && application.secondReviewerStatus === STATUS_APPROVED) {
return STATUS_APPROVED;
}
return STATUS_REJECTED;
}
示例2: filter
return configs.map((config: NodeBalancerConfigFields) => {
return filter(
/* remove the (key: value) pairs that we set to undefined */
el => el !== undefined,
{
check_path: config.check_path || undefined,
protocol:
/*
* If the provided protocol is "https" and the cert and key are set
* to "<REDACTED", don't try to set the protocol, it has already
* been set to "https".
*/
config.protocol === 'https' &&
config.ssl_cert === '<REDACTED>' &&
config.ssl_key === '<REDACTED>'
? undefined
: config.protocol || undefined,
algorithm: config.algorithm || undefined,
stickiness: config.stickiness || undefined,
check: config.check || undefined,
check_interval: !isNil(config.check_interval)
? +config.check_interval
: undefined,
check_timeout: !isNil(config.check_timeout)
? +config.check_timeout
: undefined,
check_attempts: !isNil(config.check_attempts)
? +config.check_attempts
: undefined,
port: config.port ? +config.port : undefined,
check_body: config.check_body || undefined,
check_passive: config.check_passive /* will be boolean or undefined */,
cipher_suite: config.cipher_suite || undefined,
ssl_cert:
config.ssl_cert === '<REDACTED>'
? undefined
: config.ssl_cert || undefined,
ssl_key:
config.ssl_key === '<REDACTED>'
? undefined
: config.ssl_key || undefined,
nodes: config.nodes.map(nodeForRequest),
id: undefined,
nodebalancer_id: undefined,
nodes_status: undefined,
ssl_fingerprint: undefined,
ssl_commonname: undefined
}
) as any;
}) as NodeBalancerConfigFields[];
示例3: castModelKey
export const hiddenComponentDecorator = ({
modelName,
fields,
}: {
modelName: string;
fields: Fields;
}): { modelName; fields: Fields & WithHidden } => {
const TAG = '[hiddenComponentDecorator]';
logger.log(TAG, { fields });
let wrappedFields = R.omit([castModelKey('createdAt'), castModelKey('updatedAt')])(fields);
if (R.has('id', wrappedFields)) {
const hidden = R.isNil(wrappedFields.id.value);
wrappedFields = R.mergeDeepRight(wrappedFields, { id: { options: { hidden } } });
}
const positions = R.filter(R.pathEq(['options', 'type'], 'SortPosition'))(wrappedFields);
if (!R.isEmpty(positions)) {
const hiddenPositions = R.map(position => ({
...position,
options: { hidden: true },
}))(positions);
wrappedFields = R.mergeDeepRight(wrappedFields, { ...hiddenPositions });
}
logger.log(TAG, 'wrappedFields', { wrappedFields }, diff(fields, wrappedFields));
return { modelName, fields: wrappedFields };
};
示例4: Error
export const result = (error: string, data: any): never | any => {
if (isNil(data)) {
throw new Error(error);
}
return data;
};
示例5: function
return function(...args: any[]) {
for (let fun of funcs) {
let ret = fun(...args);
if (!isNil(ret)) return ret;
}
return undefined;
};
示例6: modelReducer
function modelReducer(acc, key) {
if (!R.isNil(model.tableAttributes[key].references)) {
acc.push(model.tableAttributes[key].references.model);
// references.model here is the name of the table
}
return acc;
}
示例7: objOf
const createTypeRecord = (value?: string): null | DiskRecord | VolumeRecord => {
if (isNil(value) || value === 'none') {
return null;
}
// Given: volume-123
const [type, id] = split('-', value); // -> [volume, 123]
const key = `${type}_id`; // -> `volume_id`
const idAsNumber = Number(id); // -> 123
return objOf(key, idAsNumber); // -> { volume_id: 123 }
};
示例8: path
const linearMatch = target => {
const value = path(modifierPath, target)
if (is(Boolean, value)) {
return value
}
if (isNil(value)) {
return false
}
return !isEmpty(value)
}
示例9:
fields.forEach(field => {
if (!toFilter) {
if (R.is(Object, field)) {
const key = R.head(R.keys(field));
const value = R.values(field);
if (key === 'eq') {
toFilter = (obj[value] === query);
}
} else {
if (!R.isNil(obj[field])) {
toFilter = obj[field].toString()
.toLowerCase().indexOf(query) > -1
}
}
}
});
示例10: getBasePathFilter
const findRouteConfig = (config: any, pathParts: string[]) => {
const getBasePath = getBasePathFilter(pathParts);
if (
!pathParts.length ||
R.isNil(config.paths) ||
(pathParts.length === 1 && getBasePath(config))
) {
return config;
}
const newConfig = getBasePath(config.paths);
const newPathParts = [pathParts.slice(0, 2).join('/')].concat(pathParts.slice(2));
return findRouteConfig(newConfig, newPathParts);
};
示例11:
.filter(res => !R.isNil(res))
示例12: isNil
export const isNilOrEmpty = (v: any) => isNil(v) || isEmpty(v);
示例13: compose
const isNotEmpty = compose(not, (v: any) => isEmpty(v) || isNil(v));
示例14:
const isCreateSocketValid = (createSocket: (path: string) => WebSocket) => !isNil(createSocket)
示例15:
Object.keys(raw).filter((key) => {
return !R.isNil(model.options.scopes[key]);
})