本文整理汇总了TypeScript中ramda.compose函数的典型用法代码示例。如果您正苦于以下问题:TypeScript compose函数的具体用法?TypeScript compose怎么用?TypeScript compose使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compose函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: exec
exec('git branch --no-color -a', options, (error, stdout, stderr) => {
if (stderr || error) return reject(stderr || error);
const getCurrentBranch = R.compose(
R.trim,
R.replace('*', ''),
R.find(line => line.startsWith('*')),
R.split('\n')
);
const processBranches = R.compose(
R.filter(br => stdout.match(new RegExp(`remotes\/.*\/${br}`))),
R.uniq
);
const currentBranch = getCurrentBranch(stdout);
const branches = processBranches([currentBranch, defaultBranch]);
return excludeCurrentRevision
? resolve(branches)
: getCurrentRevision(exec, projectPath)
.then((currentRevision) => {
return resolve(branches.concat(currentRevision));
});
});
示例2: curry
export default curry((defaultValue: number, v?: null | string | number) =>
compose<
string | number | null | undefined,
number | null | undefined,
number>(
defaultTo(defaultValue),
when(compose(not, isEmpty), (value: string) => +value),
)(v));
示例3: compose
getIdOrNullFor = type => compose(
ifElse(isNil, always(null), compose(
ifElse(
contains(type),
compose<string, string[], string, number, Record<string, number>>(
objOf(`${type}_id`), Number, last, split('-'),
),
always(null),
),
)),
);
示例4:
const getBasePathFilter = (pathParts: string[]): ((data: object | object[]) => object) => {
return R.compose(
R.head,
R.filter(
R.compose(
R.equals(`/${R.propOr('', 0, pathParts)}`),
getRoute
)
),
wrap
);
};
示例5: 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 };
};
示例6: set
export const setData = <T>(
data: T,
/**
* If a schema is provided, execute its validate method. If the validation fails, the
* errors will be set at L.validationError's path.
*/
schema?: ObjectSchema<T>,
/**
* postValidationTransform will be applied to the data just before it's set on the configuration
* object, after the validation has happened. Use with caution: It was created as a trap door for
* merging IPv4 addresses and ports in the NodeBalancer creation flow.
*/
postValidationTransform?: (v: any) => any
) => {
if (!schema) {
return set(L.data, data);
}
const updatedData =
typeof postValidationTransform === 'function'
? postValidationTransform(data)
: data;
try {
schema.validateSync(data, { abortEarly: false });
return set(L.data, updatedData);
} catch (error) {
return compose(
set(L.data, updatedData),
set(L.validationErrors, convertYupToLinodeErrors(error))
);
}
};
示例7:
const extractItemsBy = primaryKey =>
R.compose(
R.uniqBy(R.prop(primaryKey)),
R.flatten,
R.map(R.path(['data', 'items'])),
R.flatten,
);
示例8: formatRemotes
export function formatRemotes(remotes: string[]) : string[] {
const process = R.compose(
R.uniq,
R.map(R.replace(/\/$/, '')),
R.reject(R.isEmpty),
R.map(R.replace(/\n/, '')),
R.map(R.trim),
R.map(rem => rem.replace(/\/\/(.+)@github/, '//github')),
R.map(rem =>
rem.match(/github\.com/)
? rem.replace(/\.git(\b|$)/, '')
: rem),
R.reject(R.isNil),
R.map(rem => {
if (rem.match(/^https?:/)) {
return rem.replace(/\.git(\b|$)/, '');
} else if (rem.match(/@/)) {
return 'https://' +
rem
.replace(/^.+@/, '')
.replace(/\.git(\b|$)/, '')
.replace(/:/g, '/');
} else if (rem.match(/^ftps?:/)) {
return rem.replace(/^ftp/, 'http');
} else if (rem.match(/^ssh:/)) {
return rem.replace(/^ssh/, 'https');
} else if (rem.match(/^git:/)) {
return rem.replace(/^git/, 'https');
}
})
);
return process(remotes);
}
示例9: isFeedItem
function isFeedItem(x:OutlineFeedParent|OutlineFolderParent):x is OutlineFeedParent {
return compose(
lt(0),
length,
path(['$', 'xmlUrl'])
)(x)
}
示例10: compose
process.nextTick(function () {
if (!state) { return; }
compose(
modulesCheckMessage,
compiledMessage
)(stats);
});