本文整理汇总了TypeScript中ramda.isEmpty函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isEmpty函数的具体用法?TypeScript isEmpty怎么用?TypeScript isEmpty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isEmpty函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: wrapForeignOpt
export const associationDecorator = ({ modelName, fields }: { modelName: string; fields }) => {
const TAG = '[associationDecorator]';
logger.log(TAG, { fields });
// prettier-ignore
const associationFields = R.filter(R.compose(R.not, R.isNil, R.prop('associations')))(fields);
logger.log(TAG, { associationFields }, R.not(R.isEmpty(associationFields)));
if (R.not(R.isEmpty(associationFields))) {
const wrapForeignOpt = R.map(opt => ({
...opt,
association: AppContext.adapters.models.getAssociationConfigs(opt.modelName),
}));
const withAssociations = R.mapObjIndexed(field => ({
...field,
foreignOpts: wrapForeignOpt(field.foreignOpts),
}))(associationFields);
logger.debug(TAG, { withAssociations, wrapForeignOpt });
const wrappedFields = R.mergeDeepRight(fields, withAssociations);
logger.debug(TAG, { wrappedFields });
return { modelName, fields: wrappedFields };
}
return { modelName, fields };
};
示例2: 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 };
};
示例3: mapProps
/**
* Return a object mapped with the source properties based on the rules
* @param rules The rules for mapping the properties
* @param source The source object to map from
* @param result The resulting object to map to
*/
static mapProps(rules, source, result) {
if (!R.isEmpty(rules) && !R.isEmpty(source)) {
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);
return result;
}
return result;
}
示例4: dispatch
.then(response => {
if (response.errors && !isEmpty(response.errors)) {
dispatch(handleEnableError(response));
}
else {
dispatch(handleEnableSuccess(response.success));
}
dispatch(updateMultipleLinodes(response.success));
})
示例5:
const create = (name) => {
if (!R.isEmpty(name)) {
this.store.dispatch(this.customerAction.createSuccess(name))
receipt.customer = name;
return true;
}
return false;
}
示例6: next
return next => action => {
if (!isPromise(action.payload)) {
return next(action);
}
const { types, payload, meta } = action;
const { promise, data } = payload;
const [ PENDING, FULFILLED, REJECTED ] = types;
/**
* Dispatch the pending action
*/
let pendingAction = {type: PENDING, payload: null, meta: null};
if (R.isEmpty(data)) {
pendingAction.payload = data;
}
if (R.isEmpty(meta)) {
pendingAction.meta = meta;
}
dispatch(pendingAction);
/**
* If successful, dispatch the fulfilled action, otherwise dispatch
* rejected action.
*/
return promise.then(
result => {
dispatch({
type: FULFILLED,
payload: result,
meta,
});
},
error => {
dispatch({
type: REJECTED,
payload: error,
meta,
});
}
);
};
示例7: Error
.then(([travels, reservations]: [Travel[], Reservation[]]) => {
if (R.isArrayLike(travels) && R.isArrayLike(reservations) && !R.isEmpty(travels)) {
const travel = R.head(travels);
if ((reservation.travelType === "OUT" && canOut(reservations)) || (reservation.travelType === "IN" && canIn(reservations, travel.placeLimit))) {
return Promise.resolve(this.respository.save(reservation));
}
return Promise.reject(getError(new Error("Place limit")));
}
return Promise.reject(getError(new Error("Travel not exist")));
}, rejected => {
示例8: getNextNumber
/**
* Return the next running number in an array of records
* @param {string} prop The property name
* @param data The array of records containing the property
*/
static getNextNumber(prop: string, data: Array<any>) {
if (R.isEmpty(data)) { return 1 }
const getNextNumber = R.pipe(
R.sortBy(R.prop(prop)),
R.pluck(prop),
R.last()
);
return parseInt(getNextNumber(data)) + 1;
}
示例9: countBusySlots
export function countBusySlots(reservations: Reservation[]): number {
if (!R.isEmpty(reservations)) {
const [_in, out] = reservations.map(x => x.travelType).reduce(([_in, out], x) => {
if (x === "IN") {
return [_in + 1, out]
}
return [_in, out + 1];
}, [0, 0]);
return _in - out;
}
return 0;
}